There are two possibilities to generate spreadsheets in the Pytigon program.
This method is dedicated to table-based sheets with a lot of data. It allows you to paste a table with data into the template sheet.
def transform_xlsx(stream_in, stream_out, transform_list)
parameters:
Row syntax in the list: tranform_list
For append row to worksheet use: row = [ "ws_name=>", rec[0], recp[2], ... , rec[n] ] "ws_name" - name of worksheet in template file. row[1:] will be appended to "ws_name" worksheet
For append row to default data table or default worksheet: row = ["=>", rec[0], recp[2], ... , rec[n] ] Syntax similar to the previous one. In this case "ws_name" is empty. Row[1:] will be appended to table named "data_table" if this table is defined in template file. Otherwise row[1:] will be appended to worksheet named "data".
For change single cell:
row = ["ws_name//A1", value]
The "value" will be written to the cell with the address "A1" located on "ws_name" worksheet.
For change single cell alternate syntax: row = ["ws_name//A1:value",]
def render_xlsx(template_name, transform_list)
parameters:
You can use .xlsx tamplates in pytigon generic views. If in your context there is an element ''doc_type" with the value 'xlsx', the Pytigon system will use the xlsx template instead of standard template.
The module enables the dynamic creation of documents in a
Process of documents creation begins with the creation of the template. It is also in odf format. Template is a normal static document supplemented with dynamic structures placed in comments to the selected cells. The syntax of these additional comments is consistent with django. There are additional syntax elements to control the place where dynamic structures are activated.
Additional syntax: First char in spreadsheet cell: * - result in text format : - result as number @ or $ - result as formula First char in note: ! - move expression to current cell element before cell and element after cell separated by char: '@' example: !{% for i in list %}@{%endfor%} !! - move expression to current row !!! - move expression to current sheet
Syntax compatibile with django:
{{var}}, {% block %} etc.
There are aliases: '_start_' is alias for '{{'
'_end_' is alias for '}}'