The recent parts of this series has shown you how to create excel exports from a view and also changing the layout of the reports with headers and logos. This post will show you how to filter the data in your excel reports both using keys and fulltext searches. Let’s get started.
To get some filtered export we add an combobox into our XPage and in this case to show both a Export with a key and search we have two buttons for the different export options.
The code behind the combobox is a standard lookup fro the value data
And storing the information within a viewScope variable ExportData
The setup behind the buttons is the same as we done in the previous posts but we add a scriptblock before doing the actual export
If we look at the simple formula for a key based export.
We clear the ExportSearch viewScope var I’ll explain this later and assign the ExportData var into the ExportKey var. The view we are working against is an ordinary view with a categorized first column.
What you need is assigning the key param with the viewScope.ExportKey. In this case I’ve also assigned the search param. But in an ordinary case you would probably assign only one of them. Depending on if you want to get all documents by category or by Fulltext search.
The code behind the search export button is this
We place a standard FT search formula inside the ExportSearch viewScope variable. Selecting all documents that the field Region has the value stored in the ExportData viewScope variable.
So exporting to excel with user customized data has never been easier.
Apache POI for XPages has more options up it sleave so this series will continue so stay tuned in.