[reportlab-users] Tons of table questions

Andy Robinson andy at reportlab.com
Thu Feb 26 11:46:25 EST 2009


2009/2/26 Dinu Gherman <gherman at darwin.in-berlin.de>:

> I think both conditions are very realistic in practice.

> But even without them I cannot see any non-linearity re-

> lated to the problem itself. So, maybe an implementation

> using generators might solve this?


The non-linearity is as follows. If you make a big table with,
say, 1000 rows x 10 cols, and space for 40 rows on each page,
and specify no widths to help us, then we have to size every
table cell - that's 10,000 objects. We then work out the optimal
column widths for the present page. We then say "OK, I can
only fit about 40 rows on this page", and we split it into a 40-
row table and a 960-row table.

Then, on the next page, we start again, this time sizing 9600
cells. But this page might have a different frame width, so we
just dumbly start again and recalculate all those table cell sizes.

I don't know the maths but the scaling is probably the same as
the song "ten green bottles, hanging on the wall" or the
"twelve days of Christmas".

AFAIR the LongTable optimisation works by just looking at
the first few rows to work out the column widths.

Smarter implementations are certainly possible but I would
urge people to just create a bunch of smaller tables in the
first place. If you are outputting thousands of rows, you
probably have some kind of grouping mechanism or want
headers and footers anyway, and it's easiest to style things
AND faster to render if you use a separate table for each visually
similar slab of content.

- Andy


More information about the reportlab-users mailing list