by IDEAL Software Support » Fri Mar 13, 2009 12:34 pm
Sample code to create tables is provided with the installation of VPE. The installation includes source codes for C++, C#, Visual Basic 6, Visual Basic .NET and Delphi. For all languages listed above, the source code contains a demo for creating tables (including computing totals and subtotals).
Basically a table is created as follows:
- Compute the height of a table-row at a given font size, use the method RenderWrite() for this task. If all rows have the same height, you can do this once in your initialization code, which increases performance. If each row is different in height, call RenderWrite() for each new row for the highest cell.
- Write functions to create Table/Group Headers and Footers. Write functions to compute their heights (using RenderWrite()).
- Cells are inserted into a document with the method Write(left, top, right, top + rendered_height, "your text goes here"). As you can see, this answers your question how to insert a cell 10cm to the left: call Write(10, 5, 17, 10 + rendered_height, "my text"). In this example the text is placed 10cm to the left and 5cm to the top. Its width is 7cm (17 - 10) and the height has been pre-computed using RenderWrite() - see the manuals on how to use RenderWrite().
- Before inserting a header, check your current y-coordinate: if the current y-coordinate plus the height for the next row plus the height for the table footer is greater than the bottom page margin (property nBottomMargin), you must insert the table footer and issue a PageBreak() command. Otherwise you can insert the next row.
That's it.