Moving on with Excel Export part 5 : XPages Export

In the previous parts (Part 1 Part 2 Part 3 Part 4) we covered plain export, styling your exports and doing selective exports. Today I want to show you how to create more advanced and flexible way to get your data using a java object that we use for the export.

We start by creating 2 java classes one for the export and one of the Export Data

screen247

Then in each class add implements Serializable and the private variable on the row below. This is so the java VM can swap the data out disk if needed.

screen245screen246

 

 

 

 

 

We will start by creating our data class, very simple. Check what type of data you want to export in each column, in my case I want to export

screen248

And then we use the generate setters/getters function in DDE by right clicking in the source window

screen249

And select all variables you want to autogenerate setter and getters for an click on OK

screen251

Time to create the getData function in the Export class the important thing here is that we return a a java object of the type List.

screen257

I also create the function as static because I will only run this function and return the data once. This is the code for the export class. The important thing to point out is

The I create the Exportdata object on each row and store it in the RowData variable

And when I have populated it I add it to the Data ArrayList Object the is returned from the function at the end.

In my Excel export component in All properties datarowexport and I select to create a wgpoi:ListObjectDataSource.screen194

And click on the buildValues property to add some source

screen258

And we add this simple code to get the data from the Java objects returned you can expand you getData class and sending in filter parameters from the XPage as we did in Part 4 of this series but in this case the filtering will be done in java.

screen259

But wait, you might say how do we populate the column data. That’s the great part of the implementation. You write the name of you variable in you data class and the getter will do the rest. so in this case it will call getName from your row class that is returned.

screen260

With this new way of exporting you can combine the data from different sources not only one as I’ve shown in the past parts of this series of posts and giving even better exports to you users.

Integrating a better export into your application will make your users happier

  1. Steven Podrouzek

    Very cool Fredrik! Thats impressive. Did not even think of that.

  2. thanks for the article 🙂

  3. Thanks Frank, really helpful.
    Is thera a pic/attachment missing in your explanation above?
    This is the section where i am looking for (??????):

    I also create the function as static because I will only run this function and return the data once. This is the code for the export class. The important thing to point out is
    ???????
    The I create the Exportdata object on each row and store it in the RowData variable

  4. Thanks Frederik, really helpful.
    Is thera a pic/attachment missing in your explanation above?
    This is the section where i am looking for (??????):

    I also create the function as static because I will only run this function and return the data once. This is the code for the export class. The important thing to point out is
    ???????
    The I create the Exportdata object on each row and store it in the RowData variable

  5. Thanks Frederik, really helpful.
    Is thera a pic/attachment missing in your explanation above?
    This is the section where i am looking for (??????):

    I also create the function as static because I will only run this function and return the data once. This is the code for the export class. The important thing to point out is
    ???????
    The I create the Exportdata object on each row and store it in the RowData variable

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>