use*_*170 7 python split reportlab platypus
我正在使用 Reportlab 的 Platypus 在 python 中制作动态生成的报告。
我生成了多个表,大多数只有 10 到 20 行。现在,它们会在我的页面末尾自动拆分,但我更希望它们在同一页面上保持在一起。
我曾尝试在表实例化时将 splitByRow 设置为 False,但这会引发“未实现”错误。
此外,我不允许对 reportLab python 文件进行任何更改,尽管我可以看到代码。也许我可以子类化 Table 并以某种方式禁用拆分?
禁用可流动拆分的最简单方法是什么?
我自己找到了答案。我从 reportlab.platypus.flowables 导入 KeepTogether,然后当我将表格添加到元素列表时,我使用 KeepTogether,如下所示:
from reportlab.platypus.flowables import KeepTogether
t = Table(tableData)
self.elements[name] = KeepTogether(t)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2123 次 |
| 最近记录: |