All you need to do in order to write data to a file is to:
- set up the template using reporting_setupTemplate routine
- set up the template's sheets using reporting_setupSheet routine
- add the data to the coresponding sheet using reporting_addData routine
- write the data added to a temporary file using reporting_writeWorkbook routine
- return the file created
- set up the template using reporting_setupTemplate routine
You can do this all by creating a file like the one below:
SER_funcs.incl
struct SheetProp{ string sheet; string[] heading; string[] data; string[] dataTypes; } function ser_writeDataInExcel(string reportFileName, boolean useRunnerLog, SheetProp[] sheetProps) { if(useRunnerLog) { runnerLog("Setting up report at " + formatDate(currentDate(), "HH:mm:ss"),100); } reporting_setupTemplate(reportFileName); for(SheetProp sheetProp in sheetProps){ reporting_setupSheet(sheetProp.sheet, sheetProp.heading, sheetProp.dataTypes); if(useRunnerLog) { runnerLog("Writing data at " + formatDate(currentDate(), "HH:mm:ss"),100); } reporting_addData(sheetProp.sheet, sheetProp.data); } if(useRunnerLog) { runnerLog("Preparing file at " + formatDate(currentDate(), "HH:mm:ss"),100); } string filename = reporting_writeWorkbook(); if(useRunnerLog) { runnerLog("Done at " + formatDate(currentDate(), "HH:mm:ss"),100); } return filename; }
It defines the structure of one sheet: with its name, its header, the data it contains and the data types of the columns.
The file above can be included into another SIL files by using this syntax:
include "SER_funcs.incl";