I'm making a dynamically generated report in python using Reportlab's Platypus.
I have multiple tables that are generated, most only have between 10 and 20 rows. Right now they are being automatically being split at the end of my page, but I would much rather have them stay together on the same page.
I have tried setting splitByRow to False upon Table instantiation, but that raises a "Not Implemented" error.
Also, I am not allowed make any changes to the reportLab python files, although I can see the code. Maybe I can subclass Table and disable split somehow?
What's the easiest way to disable flowable splitting?
I found the answer on my own. I import KeepTogether from reportlab.platypus.flowables and then when I add a table to the elements list, I use KeepTogether, like so:
from reportlab.platypus.flowables import KeepTogether
t = Table(tableData)
self.elements[name] = KeepTogether(t)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With