HTML Table Generator | CodeGuru

HTML Table Generator

Environment: VC6 SP3, NT4 SP5 During my project, I made HTML table generator. Currently, I developed only 2 HTML subset classes, Button & Table what I need at my report report form. HTML Table Generator class can be used in various way. In case of me, I make this class for simulation result form. If […]

Written By
CodeGuru Staff
CodeGuru Staff
Dec 17, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6 SP3, NT4 SP5

HTMLTableGen.gif (29721 bytes)

During my project, I made HTML table generator. Currently, I developed only 2 HTML
subset classes, Button & Table what I need at my report report form.
HTML Table Generator class can be used in various way. In case of me, I make this class
for simulation result form. If I make result form table with grid or other way, I have to
worry about print, separate page, view class, scroll etc.. Theses burden make me decide to
make HTML table generator which can solve all problems and my program users like this HTML
result form. 🙂

!!

How can I use this HTML Table Generator?

1. Include HtmlFile.h, HtmlFile.cpp, HtmlTable.h, HtmlTable.cpp to your project.
   Make Style directory and Put HtmlFile.dat file at Style directory.

2. Define CHtmlFile variable and create HTML file with CreateHtmlFile()

	CHtmlFile m_HtmlFile;
	CHtmlTable *pButton, *pTable;

	// Create Html File
	m_HtmlFile.CreateHtmlFile(_T(result\\result.htm), _T(Simulation Result));

3. Add Button or Table to HtmlFile

    In case of Button, I didn’t make text file but do all job at source
code.

	pButton = new CHtmlTable();
	pButton->m_iTableType = HTML_TABLE_BITMAP;
	pButton->m_iColumn = 2;
	pButton->m_iRow = 1;
	pButton->m_iFixedRow = 0;
	pButton->m_iFixedColumn = 0;
	pButton->m_iWidth = 50;

	// Write Header Data

	pButton->m_sAddressArray.Add(_T(http://www.rist.re.kr/eng));

	pButton->m_sAddressArray.Add(_T(https://www.codeguru.com));

	// Write Table Data
	pButton->m_sDataArray.Add(_T(image\\rist.gif));
	pButton->m_sDataArray.Add(_T(image\\codeguru.gif));

	pButton->MakeHtmlTable();
	m_HtmlFile.AddTable(pButton);
	delete pButton;

    In case of data Table, You can use text file in a data table format.

    This means your program have to write data file in data table format

	pTable = new CHtmlTable();
	pTable->ReadDataFile(_T("slab.txt"));
	m_HtmlFile.AddTable(pTable);
	delete pTable;

4. Write HTML File

	m_HtmlFile.WriteHtmlFile();

Defined Table Type

Constant Value Comment
HTML_TABLE_GRAY 0 1 fixed column with gray background color
HTML_TABLE_WHITE 1 no border, all white
HTML_TABLE_GRAYBAND 2 1 fixed column with gray, 1 fixed row with gray
HTML_TABLE_GRAY2BAND 3 1 fixed column with gray, 1fixed row with gray, 1fixed row with dark gray
& colored text
HTML_TABLE_DARKGRAYBAND 4 1 fixed column with gray, 1 fixed row with dark gray
HTML_TABLE_BITMAP 5 no border, figure buttons in 1 row

!!

Data Table Format

[TITLE]
Mill Edger Train // You can ignore title
[TYPE]
3		// Table Type
[COLUMN]
9		// Table column number include fixed column
[ROW]
7		// Table Row include fixed row
[FIXEDROW]
1		// Fixed row
[FIXEDCOLUMN]
2		// Fixed column
[WIDTH]
100		// Table width percentage (%)
[DATA]		// All data should be separated with comma
Pass,Mill No.,HRatio (%),Height (mm),dH (mm),EtaH (%),dWh (mm),Temperature (!I),Angle (!F),
1,4Mill 1,0.100,208.32,20.78,0.0887,4.61,1240.69,10.07,
2,4Mill 1,0.161,175.69,33.45,0.1567,8.02,1235.14,12.78,
3,4Mill 1,0.177,139.82,36.78,0.2043,9.06,1227.70,13.40,
4,4Mill 2,0.385,96.17,44.77,0.3125,11.63,1204.26,15.38,
5,4Mill 2,0.335,58.14,38.95,0.3955,10.41,1194.53,14.34,
6,4Mill 2,0.280,26.42,32.56,0.5469,11.06,1150.69,13.11,
[END]
Advertisement

Style File Format

Htmlfile.dat file has my favorite HTML file and HTML table style. I’m sorry about Style
file is not in easy format but  It isn’t difficult so much.

HtmlFile.dat has 1 HTML body and several Table body. You can change all HTML code as
you like but leave strings in a ^text^ format unchanged!! A string within ^ bracket is
keyword used by CHtmlFile or CHtmlTable.

Keyword used at Htmlfile.dat

Keyword Comment
^BODY^ Used By CHtmlFile, All Table or Bitmap data will be inserted
at here
^TABLETITLE^ Table title defined at data table format or bitmap button
title will be inserted here
^HEIGHT^ Table Height
^WIDTH^ Table Width
^DATA^ Data
Cell

Format

^BOTTOM_SOLID^ CHtmlTable check cell boundary and deicde whether
to draw cell outline or not
^LEFT_SOLID^
^RIGHT_SOLID^
^TOP_SOLID^
^ADDRESS^ Button address will be inserted here

Anybody feel free contact with me and enhance this
code. If you enhance this code, don’t hesitate to report at codeguru. Good Luck 🙂

Downloads

Download demo project – 53 Kb
Download source – 7 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.