[reportlab-users] Fwd: Patch to support tables with oversize cells
Robin Becker
robin at reportlab.com
Sat May 14 03:49:11 EDT 2022
On 13/05/2022 13:12, Lennart Regebro wrote:
> Hi, sorry for the delay in this, I was on vacation.
>
> Splitting spanned cells turns out to be not easy at all. Well, the
> splitting was no problem, it's dealing with the styles.
>
> I believe I have found an edge case in Reportlab which I'm not sure if it's
> intended or not, and fixing it will require quite a major refactoring, so I
> would like your opinion on this. Basically, you can color a spanned cell
> only partially in current Reportlab, but supporting splitting such a cell
> leads to some weirdness.
>
> If you set the background color only on the starting cell for a spanned
> cell, then that whole cell will get that background color. But if you set a
> background color on only some out of the rows, only that part of the cell
> will get colored. If you then split that cell, then what parts of that
> split cell are colored can change,
>
> Fixing this would require calculating the colors or all cells before a
> split, and then, when the table is drawn, not doing any such
> "recalculation". But the first question is: Is this really supported? Is
> that how it is supposed to work? That you can set partial background colors
> on spanned cells?
>
> Attaching PDF that demonstrates this. I accidentally overwrote the code
> used to generate it, though. *facepalm*
>
> //Lennart
>
.........
Hi Lennart, hope you enjoyed the vacation. Looking at your output I believe you have in fact found a bug. I had little
to do with the original spanned columns/rows implementation, but I know it's a source of many bugs.
I don't believe the intent was ever to allow partial styling and I haven't seen this before. It seems to me that in a
span range we should consider the spanned cells to be absent. That would mean only the start cell of a span would
contain content and or styling. If I can work up your example I may see how to avoid the partial styling. If your
example actually shows a row span being split then we're almost there. Even without the partial styling fix I would
always say the the intent is that the styles should cover the cells and the partial case is a bug.
If we are able to avoid putting in content for the 'absent' spanned cells we should be able to ignore their styles.
--
Robin Becker
More information about the reportlab-users
mailing list