christopher-ramirez / secretary

Take the power of Jinja2 templates to OpenOffice and LibreOffice.
Other
190 stars 48 forks source link

Dynamic columns in tables #28

Closed mpyrev closed 8 years ago

mpyrev commented 8 years ago

Is it possible to create tables with not predefined number of columns? For example, I need to generate report with table and columns are dates selected by user before.

christopher-ramirez commented 8 years ago

Hi!

TL;DR I'm afraid I'm not sure if this can be done with Secretary. Maybe a table with just a single row and using a repeatable cell can do the trick. Please check Control Flow section, specifically cel, before::cell and after::cell modifiers.

An Open Document file is composed of a series of XML files. Secretary generally does not try to play with the attributes in the XML nodes. Instead it relays by internally moving inserted jinja2 fields as if they were manually authored in a HTML template. In many cases, ODT handles columns and rows through XML elements attributes, much like colspan in HTML defines how many columns a cell should takes. That's why Secretary is very limited in what it can do with dynamic cells or columns.

With this limitations, Secretary offers a way to make dynamic columns possible to a certain degree. But most of the time it doesn't provide the expected results because of the issues mentioned above. See Control Flow section, specifically cel, before::cell and after::cell modifiers.