python-3.xpython-docxdocxtpl

Python library for create multiple tables of same table structure without changing style and next table should be on next page


in one of my application if user order more then one product we have to create same structure of table for each product dynamically and table structure, style provide user only , we just know filed/label are fix. so any one can guide how we can achieve in python

I'm try using docxtpl, python-docx python library

i already created single table but i'm facing issue for creating multiple table, push table to new page


Solution

  • Just use a loop and insert the break page each table except the last table?

    {% 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 %}