Generating spreadsheets
There are two possibilities to generate spreadsheets in the Pytigon program.
- Generating .xlsx files
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.
Low level api:
def transformxlsx(streamin, streamout, transformlist)
parameters:
- steream_in - file with spreadsheet template in xlsx format.
- stream_out - output file in xlsx format.
- transform_list - list with rows in special format.
Row syntax in the list: tranform_list
For append row to worksheet use:
row = [ "wsname=>", rec[0], recp[2], ... , rec[n] ]
"wsname" - 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 "wsname" is empty. Row[1:] will be appended to table named "datatable"
if this table is defined in template file. Otherwise row[1:] will be appended to worksheet named "data".
For change single cell:
row = ["wsname//A1", value]
The "value" will be written to the cell with the address "A1" located on "wsname" worksheet.
For change single cell alternate syntax:
row = ["ws_name//A1:value",]
High level api:
def renderxlsx(templatename, transform_list)
parameters:
- template_name - name of template file in .xlsx format.
- transform_list - syntax discussed in the previous paragraph
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.