Tuesday 20 August 2019

Multi Sheet Excel Output Using RTF Template with Custom Worksheet Name

<?spreadsheet-sheet-name: {concat(.//YEAR, ' ',.//STATE)}?>



By default, page breaks and section breaks specified in the RTF template create a new sheet in the output Excel workbook. You can control whether page breaks create a new sheet using the property xlsx-page-break-as-new-sheet

Set this property to "false" when you do not want page breaks in the RTF template to generate new sheets in the Excel workbook. 

A similar control does not exist for section breaks; that is, a section break in the template will always create a new sheet in the Excel workbook output.

For information on setting properties in an RTF template, see Section 4.13.3, "Setting Properties."

4.23.2 Specifying a Sheet Name

To specify a sheet name, use the following command in the template:
<?spreadsheet-sheet-name: xpath-expression?>
where xpath-expression is an XPath expression or a string constant.
For example, assume your template uses input data as follows:
 <?xml version="1.0" encoding="UTF-8" ?> 
   <ROWSET>
    <ROW>
      <CUSTOMER_NAME>Vgpsuwo Fjprpit</CUSTOMER_NAME> 
      <CUSTOMER_NUMBER>7795</CUSTOMER_NUMBER> 
      <YEAR>2005</YEAR> 
      <BRAND>MSPKID</BRAND> 
      <DIVISION>UWGLERXM</DIVISION> 
      <STATE>LD</STATE> 
      <INVOICE_DATE>2004-12-07T07:13:15.379-08:00</INVOICE_DATE> 
      <INVOICE_NO>806356</INVOICE_NO> 
      <INVOICE_AMOUNT>8181.704554734346</INVOICE_AMOUNT> 
    </ROW>
...
</ROWSET>
To generate a sheet name that shows the YEAR and STATE from the data (for example, "2005 ID") enter the following in a BI Publisher field in your template:
<?spreadsheet-sheet-name: {concat(.//YEAR, ' ',.//STATE)}?>
Ensure that your expression generates unique sheet names within the workbook.

No comments:

Post a Comment