[reportlab-users] Fwd: Patch to support tables with oversize cells

Lennart Regebro lregebro at shoobx.com
Mon May 16 07:34:03 EDT 2022


I'm glad to hear I don't need to support this case. Yes, the span splitting
seems to work now, but the handling of styling isn't 100% yet.

I redid and attached the test I sent on Friday, if you want to look into
that behavior, but yes, I agree it might not really need fixing, I can't
imagine it's a common usecase.

//Lennart

On Sat, May 14, 2022 at 9:49 AM Robin Becker <robin at reportlab.com> wrote:

> 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
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20220516/0f3f0ae7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_table_bug.pdf
Type: application/pdf
Size: 2891 bytes
Desc: not available
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20220516/0f3f0ae7/attachment.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_table_bug.py
Type: text/x-python
Size: 3734 bytes
Desc: not available
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20220516/0f3f0ae7/attachment.py>


More information about the reportlab-users mailing list