Python 库,用于在不更改样式的情况下创建相同表结构的多个表,并且下一个表应该在下一页上

问题描述 投票:0回答:1

在我的一个应用程序中,如果用户订购了多个产品,我们必须为每个产品动态创建相同的表结构,并且表结构、样式仅提供给用户,我们只知道归档/标签是固定的。所以任何人都可以指导我们如何在 python 中实现

我尝试使用 docxtpl、python-docx python 库

我已经创建了单个表,但我面临创建多个表的问题,将表推送到新页面

python-3.x python-docx docxtpl
1个回答
0
投票

只需使用循环并插入中断页除了最后一个表之外的每个表?

{% for product in products %}

{# your table and code for the table here #}

{# Break page after each table except the last table #}
{% if not loop.last %}
{{ '\f' }}
{% endif %}

{% endfor %}
© www.soinside.com 2019 - 2024. All rights reserved.