01. Configure Excel Export


How to export to excel with POI4XPAGES
1. Download POI4Xpages
2. Install the Extension on your Server and Designer Client

1. Prepare your Excel file.



There are several things highlighted on the screenshot.
· <<user>> and <<date> are placeholders. They will be replaced with calculated values
· Contacts is the name of the spreadsheet
Save the Excel template and insert it as a File Resource into the application



2. Open the XPage on which the export should be performed.

Add the ‘Poi Workbook’ control to the XPage


Select the POI Workbook control and switch to the properties panel to configure the export.



The downloadFileName specifies the name of the file which will be created.
Add a templateSource. The templateSource defines which excel file is going to be used for the export. You can choose between “resourcetemplate” (a resource file) or “attachmenttemplate” (an attachment in a document from a defined database).

In this example we use ‘resourcetemplate’


· databaseName: The database where the resource file is saved, empty means the current database
· filename: The name of the resource file
As a next step we define the spreadsheet. The spreadsheet represents a sheet in a workbook:

· name: The name of the spreadsheet on the workbook
· create: if yes is selected, the spreadsheet will be created if it doesn’t exist. Otherwise the spreadsheet definition will be ignored.
Remember the <<user>> and <<date>> values on the sheet. We will now set the values for these fields by defining some 'cellValues'.


With the definition of the cellBookmarks all the <<user>> and <<date>> tags on the spreadsheet (not within the whole workbook) will be replaced with the specified values during the export.

Be aware that you have to write ‘user’ instead of ‘<<user>>’ for the cellBookmark name.



The configuration is now done. Let us export the excel file by button. The button needs an “onClick()” eventhandler like this:

Choose “Generate Workbook” and select the ID of workbook definition.