Got Table Sample Code?

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Got Table Sample Code?

Postby Patrick » Thu Mar 12, 2009 6:01 pm

Greetings,

Looking at previous posts, I guess there's no naitive table support per say. I'd love to see a very basic example of a table.

How do ya'll keep columns aligned in a table?

I'm looking at the method: "VPE.DefineHeader" so it'll print on subsequent pages, but how do you put, say column header #3, 10 cm from the left?

This is on XP, VPE4 - Pro, Visual Lansa 11.5

Thank you,
Pat
Patrick
 
Posts: 23
Joined: Thu Mar 12, 2009 5:44 pm

Postby 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.
Last edited by IDEAL Software Support on Fri Mar 13, 2009 6:04 pm, edited 1 time in total.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

You guys rock!

Postby Patrick » Fri Mar 13, 2009 2:39 pm

Thank you so much. Coming from (pardon my French) VL Reporter (yuck!), VPE is hands down, waaaaay better - MANY more properties, events and methods!

I did not find the sample table code - I'll look for it now.

Thnaks again,
Pat
Patrick
 
Posts: 23
Joined: Thu Mar 12, 2009 5:44 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 10 guests