Moving on with Excel Export part 4 : XPages Export

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.

screen237

 

 

 

 

 

 

The code behind the combobox is a standard lookup fro the value data

screen235

 

 

 

 

 

And storing the information within a viewScope variable ExportData

screen233

 

 

 

 

 

 

 

 

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

screen231

 

 

 

 

 

 

 

If we look at the simple formula for a key based export.

screen232

 

 

 

 

 

 

 

 

 

 

 

 

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.

screen236

 

 

 

 

 

 

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.

screen238

 

 

 

 

 

 

The code behind the search export button is this

screen230We 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.

  1. Steven Podrouzek

    !!! That’s why you the guru and I’m the student. Thank you Fredrik.

    • Fredrik Norling Fredrik Norling

      Great that you like my series. I have more posts in this series soon. If there is something you like me to cover in future posts, let me know.

  2. shilpa mittal

    Hi Fredrik,

    I am beginner for xpages and looking for export to excel functionality. I am not finding “Moving on with Excel Export part 1 : XPages Export”.
    Please guide me through

    Thanks in advance

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>