HTML Table Generator


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

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



	// Write Table Data

	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();
	delete pTable;

4. Write HTML File


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

Mill Edger Train // You can ignore title
3		// Table Type
9		// Table column number include fixed column
7		// Table Row include fixed row
1		// Fixed row
2		// Fixed column
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,

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


^BOTTOM_SOLID^ CHtmlTable check cell boundary and deicde whether to draw cell outline or not
^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 :-)


Download demo project - 53 Kb
Download source - 7 Kb


  • Code

    Posted by Legacy on 11/13/2002 08:00am

    Originally posted by: Arsi

    Very nicely done program, ^ ^

  • Showing .htm files to HTML?

    Posted by Legacy on 09/16/2002 07:00am

    Originally posted by: Tan

    Very useful and nice work.

    One question: Could you show a .html file directly in your demo? Similar to .igf file, not from formatted .txt files.

    Anybody has Any idea?

  • Nice to Meet you!

    Posted by Legacy on 10/15/2001 07:00am

    Originally posted by: Lee JongSeon


    한국분들이 올린것은 거의 보기 힘들었는데...
    많은 도움이 될것입니다.

  • HTML print cut off the contents

    Posted by Legacy on 08/16/2001 07:00am

    Originally posted by: Dinesh Chandra Maithani

    If I increase columns upto 20 or more in any of the tables, I am not able to print the full contents of the table, rather gets the cut off table

    Any solution ?

  • Good Korea!!!

    Posted by Legacy on 09/14/2000 07:00am

    Originally posted by: hyuri98

    Good! Good!

  • To make Html Table without text file

    Posted by Legacy on 12/21/1999 08:00am

    Originally posted by: Kim Pil Ho

    I've received 1 question about above title.

    This is the full comment about that question.

    title: regrading html table generator

    hi and first thanks for sharing.

    my problem is that the data is being duplicated one for the dat file and one for html file it self
    is there any way i can add a col and rows programaticly


    any way thanks in advance

    I've already provide the way you want.
    It looks like that I made fault at writing my article that can perplex the user.
    Reading text file in case of table is just additional way to help user who likes text result file.

    Try this sample code at HtmlMaker sample project.
    Just insert code in the member function

    void CHtmlMakerView::OnGenerate()

    After :
    m_HtmlFile.CreateHtmlFile(_T("result\\result.htm"), _T("Simulation Result"));

    Before :

    Source Code :
    pTable = new CHtmlTable();
    pTable->m_iTableType = HTML_TABLE_GRAY;
    pTable->m_iColumn = 2;
    pTable->m_iRow = 2;
    pTable->m_iFixedRow = 1;
    pTable->m_iFixedColumn = 1;
    pTable->m_iWidth = 100;
    pTable->m_sTitle = _T("Test of Direct Write Table");

    delete pTable;

    I'm sure you can modify above code as addrow() or addcol()

    Good luck :-)

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date