Hi All
Only a few hours and I will travel with Roman, Peter and Andre to the IBMConnect2013. The last years “LotusSphere 2012” (the old name of the IBMConnect) was a game changer in my life. I meet great people like Niklas Heidloff, Philippe Riand, Martin Donnelly, Dan O’Conner and many more.
But these guys have inspired me to build myWebGate and POI 4 XPages.
We have greate news about both projects, but this post ist about POI 4 XPages. We have made some progresses on the project that we would like to share in the version 1.1.0:
- The POI 4 XPages supports now the version 3.9 of the brilliant Apache POI Project, which is the newest release
- We fixed some typos and a bug in the creation of Workbooks. If you try to export data to a sheet wich doesn’t exist on the exceltemplate and you choose “create” = “false”, the export fails. This was not the idea behind the “create”=”false” option. Now the export definition with this settings will be ignored, if the sheet doesn’t exist. (Marco Baumann has reported this issue at the gitHub.com)
- We implemented the POI – ListObjectDataSource which is designed to export the java.util.List<?> object in version 1.0.1 but we did make a mistake in the value definition. This values have to be assigned with a SSJS function, but our binding was against a value property. We fixed this with a new “MethodBinding” assignment (like the createObject function from the ObjectDataSource in the ExtLib) called “buildValues”. This means that “values” is deprecated and only for backwards compatibilty available
- With version 1.1.0 we introduce a brand new feature in the workbook and document controll. A binding which we called postGenerationProcess. This feature is really powerful, let me explain why.
postGenerationProcess – all power of apache poi in your hand:
POI 4 XPages build your Workbook or Document with the “generate….” function. But when the action is started, you don’t have access to the Workbook or Document object. “postGenerationProcess” change this. In the postGenerationProcess your SSJS / Java Code will be executed, right before the Workbook or Document is transmitted from the server to the client.
The follwowing code in the postGenerationProcess prints the name of the first sheet on a workbook to the server console:
print( workbook.getSheetAt(0).getSheetName() );
While we are calling the postGenerationProcess, the POI 4 XPages Code assign the current workbook to the variable workbook, or the current document to the variable xwpfdocument. This variable are representation of the the following apache poi classes:
workbook: org.apache.poi.ss.usermodell.Workbook -> javadoc
xwpfdocument: org.apache.poi.xwpf.usermodell.XWPFDocument -> javadoc
Imagine what you can do now, afert a document or a workbook is created!
Have Fun
Christian
Download POI4XPages here
Mark Leusink
February 12, 2013 at 11:25 pm
Hi Christian,
I’m using the (excellent) POI4XPages now in one of my projects. For one of the exports I’m now trying to use the ListObjectDataSource, but I can’t get it to work.
I’m currently using the buildValues property to add an EL for a bean method that returns an (array) list object containing simple custom classes (just some private strings). I made sure that there is a get method for every column name I added in the class, but when I try to open the XPage I get an error 500.
Do you have an example on how to use that datasource?
Thanks,
Mark
guedebyte
February 13, 2013 at 7:54 pm
Hello Mark
Thanks for using POI4Xpages.
Could you please tell me which version you have on your designer client, and which version on the server. The error-log.xml after a http quit, lo http and a reproduction of the error would also be interesting.
Tomorrow will I share a short example of how to use this datasource.
Best regards
Christian
Mark Leusink
February 16, 2013 at 10:08 am
Hi Christian,
Using the new example you shared I was able to create an export using the ListObjectDataSource. Works great!
Here are a couple of observations while working with it:
– I could not use EL in the buildValues property: “#{javascript:users.getAllUsers()}” did work, “#{users.allUsers}” didn’t.
– The stepSize attribute of the wgpoi:data2rowExport is required: it only exports the first row if not present.
– if I have 2 exports on 1 XPage (triggered by 2 buttons), after downloading the first, I cannot download the second.
guedebyte
February 16, 2013 at 10:32 am
Hello Mark
Thanks for your feedback:
– EL Problem -> I’ve opened a Issue https://github.com/OpenNTF/POI4Xpages/issues/11 – We will have a look at this. I Think this could not be solved, because wie us a “methodeBinding”
– stepSize -> I’ve also opened a Issue https://github.com/OpenNTF/POI4Xpages/issues/12 – My plan is to solve this with Version 1.1.5 which brings also PDF Capability for docx – generation
– 2 Exports -> We know this issue see -> https://github.com/OpenNTF/POI4Xpages/issues/6 – I personally belive, that this is a “client side” issue and the XSP object is not responsive anymore. But any ideas are welcome 🙂 Btw. have you tried a “context.reloadPage”.
Best regards and wish you success with poi4xpages
Mark Leusink
February 16, 2013 at 9:25 pm
This is the last time I’ll bother you 😉
I’ve found a workaround for multiple exports on 1 page (issue 6): I’ve added the export definitions to a separate XPage and added the wgpoi:generateWorkbook simple actions to the beforeRenderResponse. To trigger the export I just open that ‘export’ XPage in a new window/ tab: the browser offers the file and closes that new window/tab again.
I was able to add multiple wgpoi:generateWorkbook simple actions and determined which one gets executed by setting the loaded attribute based on a URL parameter.
yasmine
April 30, 2014 at 3:16 pm
Hi,
I’m a beginner in xpages and I faced a problem, I should use POI 4 XPages in a project for generating excel files so I installed POI on server and on my machine when I run a local project it works very well and no problem with it but when i run a project hosted on the server and when I click On download button I get http error 500
Please if anyone has an idea about this error let me know the solution
Best Regards,
guedebyte
May 1, 2014 at 10:11 am
Hello Yasmine
I’ve writteion some question and advice on your discussion entry on OpenNTF.org.
http://www.openntf.org/main.nsf/project.xsp?r=project/POI%204%20XPages/discussions/D71930E9029785CF86257CCA0049EA14
Best regards and have fun with POI 4 XPages
Christian