Show TOC

Function documentationReports: Exporting Query Results Using a Workbook Template Locate this document in the navigation structure

 

The file attachment container object allows you to import spreadsheet workbook files to be used as a pool of templates for exporting query results from report and list pages to a spreadsheet application. A workbook template may contain macros and embedded objects. It may also have various format options preset.

Features

You can select a suitable workbook template during report definition or query definition. This selection can be made for custom query definitions and for both custom and standard reports. You can select the same workbook template for multiple query definitions and for multiple reports. For a report, this template would be used when exporting the results of all the queries in the report to a spreadsheet application. For a query definition, this would be used when exporting the results of the single query in a list page or from a single query in a report.

If no workbook template has been selected for a report or for the query in a list page that is being exported, the value of an optional, enterprise-scoped system property is used to provide the path name to the workbook template. The name of the property is export.workbook_template.path.default in the userinterface section. This serves as a default for all exported query results in the enterprise. The path name in the property is expected to be the same as the path name of a file attachment container. If neither a workbook template object reference nor a property value has been provided, the export to a spreadsheet application is done without a template.

A report can have multiple queries. When a report is exported to a spreadsheet application, each query result set is written to a separate sheet in the workbook. If a workbook template has been specified, the sheets in the template are used sequentially for each query result set. If there are more query result sets than sheets in the template, a new sheet is created for each additional result set.

Reuse of Cell Styles from a Workbook Template

All formatting specifications in a spreadsheet application workbook template are not retained during export. The workbook formatting specifications (styles) that are set at a global level (for the whole workbook) are recognized and used in all exported worksheets. However, formatting that is specified at the column, row, or merged cell level is lost. Formatting at the column level is recognized for cells that have values set in them.

Rules are in place that can reuse the styles from certain cells for all the cells in a header row or all the cells in a column. They are as follows:

  • If a cell anywhere in the workbook has a value set into it, even a space (blank), that cell's style will be reused for that cell in the exported worksheet. The style might come from a column or row format specification, but the cell must have a value. If there is no value, the cell's style is not recognized.

  • If a cell with a value is found in the header row, the style of that cell is used for all header row cells (without values) to the right of that cell. This accommodates the situation where the number of columns is not known (such as for a workbook template that is used as the default for all queries and reports, or for a query with repeating columns).

  • If any cell with a value is found in the first row of data (one row beneath the header row), the style of that cell is used for all cells (without values) in that column, from that row on.

The following technique can be used for setting styles for a given query or report:

  1. Clear the whole worksheet of all cell values. (Select all and delete.)

  2. Set the style for each column. (Select a column and format it.)

  3. Enter a value in each cell in the first data row.

  4. Set the style for the header row. (Select the header row cells and format the selection.)

  5. Enter a value in the first cell of the header row.

Note that when a query has repeated columns, there is currently no way to format the original set of columns and then copy that formatting to the repeated columns.