Output as Excel (Swift)

Set up and configure output to Excel™ format from your reporting application. This option is useful if you want to perform custom calculations in an application such as Numbers.

Note: Excel reports, as output from Genero Report Writer, do not print at high quality. If you require high-fidelity printing, use one of the other output options, such as SVG.
To output your report as an Excel spreadsheet file, specify XLS or XLSX in the selectDevice() function.
let rcPtr = createRuntimeConfiguration(reportDesignFileName)
selectDevice (rcPtr, XLS)
let rcPtr = createRuntimeConfiguration(reportDesignFileName)
selectDevice (rcPtr, XLSX)
The report file will be written to the current working directory, unless you specify another location through the use of environment variables or by using the C API within your Swift application.
Tip: If you are experimenting with the provided Swift demo, ensure you change the file extension from the hard-coded "pdf" to the appropriate Excel extension type (.xls or .xlsx). On Mac® OS, NSWorkspace.shared().open() opens the document with the application defined by the system file association.

Excel report output

The output is in the specified Excel format, with the XLS format limited to 65,536 rows. In contrast, for the XLSX format the document is generated with constant memory consumption, so that very large documents can be produced without exhausting heap space.

Note: The XLSX format can only be opened with newer versions of Microsoft™ Excel (2007 or later). A backward compatibility pack can be downloaded from Microsoft; however, the XLSX format is then subject to the 65,536 limit of the earlier versions.

Any existing report, including ASCII, can be output to the spreadsheet.

The layout of the cells (size, font color, etc.) can be predictably controlled from the Report Designer. The goal is to put the report layout into the cells of the spreadsheet efficiently.

When items in the report design overlap, by default the placement but not the alignment is preserved in the spreadsheet. To make the necessary decisions, Genero Studio marks the column and row boundaries internally with tabs. If two consecutive tabs have no element that bounds on them, the column or row collapses. The implication of this is:

  • White space (empty columns, empty rows) is eliminated when possible.
  • Elements that overlap may be placed in the same column, but they maintain their relative placement (above/below).
  • Contiguous items are never placed in the same column, but maintain their relative placement and alignment.

The values in the cells are generated for the report, not the Excel formulas.

The following report elements are specially rendered in Excel:

  • Graphical elements such as bar codes are rendered as images.
  • Business graphs are rendered as tables.
  • For pivot tables, only the fact rows are shipped. The pivot table is therefore rendered as a flat table structure without being disrupted by group totals. You can then use the data to create an Excel pivot table with business charts and row-spanning formulas.

Device-specific configuration functions

Once you have specified XLS as the output, there are device-specific configuration functions available:
  • configureXLSDevice()
  • setXLSMergeCells()
Once you have specified XLSX as the output, there are device-specific configuration functions available:
  • configureXLSXDevice()
  • setXLSXMergeCells()

These functions should be included after calling the selectDevice() function but before calling the createContentHandler() function.

For the full list of available functions, refer to the Genero Report Writer C API documentation.