[reportlab-users] long tables

Henning von Bargen reportlab-users@reportlab.com
Mon, 14 Apr 2003 09:17:47 +0200


Hi,

what is the status of long tables (>= 20 pages long)?

I remember that someone said it would be better to use
several small tables instead of one long table,
since performance degrades for long tables 
( as I understand, because the time that size calculation
takes is of order O(n^2) where n=number of rows ).
This is not a good workaround, because usually you usually
don't know where to split into small tables in advance.

I looked in the sources for the table class 
in an earlier release of reportlab
and found that splitting tables worked like this:
1. Calculate the height and width for the whole table.
2. If the table fits on the page, we're done, render it.
3. If the table does not fit, split into two tables R0 (fits on current
page)
    and R1 (the rest), where calc() will be called for R1 when the next
    page is going to be rendered.

Calculating the size of R1 is causing the performance degradation.

I think this could be improved to O(n), if one could give the available
height 
in wrap() as an additional argument to calc().

Then the calc() function could just stop as soon as the computed height
for the first m rows is greater than availHeight.
It could then return the height computed so far
and maybe set a flag stating that even more rows follow.
With this solution, the size calculation would occur only once for each row.

Just an idea. Has anyone tried it? Could it cause trouble?

Henning