[reportlab-users] Need help with a table problem: style setting on very last line of a table split over pages
reportlab at boargules.com
Tue Jan 14 17:40:52 EST 2014
I'm sure the docs have an answer to this question but I haven't been
able to find it.
I have a report with several tables. Some tables have a total row at the
bottom, that I would like to be highlighted differently. Others don't.
For the table with a total row I specify the highlight colour like this:
TotaltableStyle = TableStyle([
('ROWBACKGROUNDS', (0,-1), (-1,-1),
('TEXTCOLOR', (0,-1), (-1,-1), black)
The parent here is of course the style for tables that don't have a
total row at the bottom. This works perfectly ... unless the table is
split over multiple pages. Then, I get this highlighting on the last row
on every page, when what I want to highlight is the last row on the last
An earlier version of this program solved the problem using two tables,
one for the detail, with a single-row table below it for the totals. But
that version specified the column widths explicitly, so the two tables
matched up. But now the tables are more crowded, and I don't have the
luxury of giving each column enough width to accommodate the longest
data item over all of the tables. So, I really need the detail table to
calculate its own column widths , and having two different tables means
that the column widths are computed independently and, of course, do not
So, either I need to copy the column widths from the detail table to the
total table; or I need to specify a style that applies only to the very
last line of the table. I haven't found a way to do either. I suspect
that indicates I'm looking for the answer to the wrong question.
In any case, I can't imagine I'm the only person who has ever wanted to
So, what is the proper way to apply a different style only to the very
last logical line of a table, even if it is split over multiple pages
and so has more than one physical last line?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the reportlab-users