[reportlab-users] Placing narrow table so that it wraps across the page

Robin Becker robin at reportlab.com
Thu Apr 21 05:13:49 EDT 2011


On 20/04/2011 16:55, William Hudspeth, Ph.D. wrote:

> I have a very narrow table with only two columns, but lots of rows. I

> would like to break the table itself into multiple 'blocks' (perhaps 3

> blocks required) across the page, kind of like newspaper columns, but

> with the column headers repeated at the top of each 'block'. The entire

> table must also be capable of being split across multiple pages if it is

> too long for one page.

>

>

> header1 header2 header1 header2 header1 header2

> val1 val2 val1 val2 val1 val2

> val1 val2 val1 val2 val1 val2

> val1 val2 val1 val2 val1 val2

> val1 val2 val1 val2 val1 val2

> .... .... ...

>

> How would one go about accomplishing such a structure?

>

> Thanks,

>

> Bill

........

this is actually quite hard. We don't support columnWise splitting of tables,
but this can be considered as ordinary row wise splitting.

Conceptually you will need to have a repeat row count that contains the header
row(s). Then conceptually you need to do the following in a flowable

1) when the table is about to be drawn a) decide whether there's enough room on
the current [age to make it sensible. If not issue a page throw and defer.

2) switch the PageTemplate to a three column layout.

3) issue the table in the three frame layout.

4) switch back to two column or full width layout.

I believe this could all be done in the platypus doctemplate framework by using
existing flowables eg Table and DocIf which can be used to program the framework
inside the story.

I don't have an example to hand, but if you prod me over the next week (when we
have a bunch of holidays) I will try and set one up.
--
Robin Becker


More information about the reportlab-users mailing list