[reportlab-users] First try with row and column spanning
Andy Robinson
reportlab-users@reportlab.com
Sun, 6 Apr 2003 01:13:36 +0100
I have started to add row and column spanning to
Platypus tables. Just got it to work but it's 01:00 now,
so this will have to do for docco until tomorrow.
You can now use a 'SPAN' command in the table style
definition to define spanned ranges, in a similar way to
the way you would color cells. I wrote the code such
that it follows all the old pathways if no span commands
are found, so hopefully this wil not impact existing apps
even while we debug/refine the spanning features.
Imagine a simple table with this data in the 9 cells:
[['A','B','C'],
['D','E','F'],
['G','H','I']]
Imagine that you want 'A' to span across the top row.
Your table style would then have to include this line:
(SPAN, (0,0), (2,0))
The 'A' would be the only thing drawn on the top row
(and if you centered the text in the table style it would
visibly centre across the row).
This should be useful immediately if you bear in mind the
following caveats:
(1) Data must still have the shape of the 'underlying grid'.
It does not matter if you replace 'B' and 'C' with None - in fact
that's a good idea - because Platypus will not even try to draw
those cell contents. But you still need the 3x3 matrix and it
would however be an error to have a data block like this:
[['A'],
['D','E','F'],
['G','H','I']]
(2) All the line and background drawing commands still
think in terms of the 'underlying' 3x3 grid. Thus if
you had a 3x3 table and made the first cell span
the whole of the top row, text in it would span
as it does in HTML. BUT if you did a GRID command
covering the whole table, your grid of lines would
'show through' in the comined top row. If you wanted
your table header yellow, you'd need a command in the
style to color the top row yellow, and not just the
top left cell.
This is also available in RML with an example in
test_008_tables.rml.
There is a lot more to do in addition to some
semantic puzzles to think through, but I encourage
people to play with this!
Thanks,
Andy Robinson