Home » excel » xpages – Exporting data to existing Excel file

xpages – Exporting data to existing Excel file

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a system with an Excel spreadsheet template file which is used for invoicing. I would like the user to be able to click a button on an Xpage, which will then open the spreadsheet and enter the latest invoicing data in Excel. I don’t mind if Excel is either the application on their machine or on the server, but my preference would be the application locally on their machine.

I’ve looked into Xagents, as I feel this is probably the answer. I know they can be used to create Excel but I have not been able to locate any mention of opening an Excel file, and entering data into specific cells.

Is this possible?

How to&Answers:

EDIT: you can use Apache POI for editing and creating Microsoft Office documents. This is a java project which gives you a handle to office documents and this can be used using java.
A good starting point can be the blog of Christian Guedemann from webgate:
http://guedebyte.wordpress.com/2012/09/17/documents-and-spreadsheets-with-xpages-building-the-kernel-part-ii/
(end of edit)

The only way I KNOW and tried to write data from Notes to Excel is exporting the data to an HTML page and setting the Content Type accordingly (e. g. as described here (there are a lot more resources available for taht):
http://www.dominoguru.com/pages/developer2010_xpagexlsexport.html

I am not sure if this is of help but it seems that this project can help you:
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=ZK%20Spreadsheet%20for%20XPages

As far as I can see this project can load Excel files from XPages – and then it should also be possible to edit the files.

Besides that the only solution I can think of is a Notes Agent that is called from the XPage. This agent can then run in background and do all the excel stuff. After running, the XPage can show a link to the Excel file. Actually this is the solution I would consider to implement – but maybe others step in with better answers here.

Answer:

You don’t want to introduce a dependency on Excel in your application — wouldn’t work with an iPad front-end. Rather have a look at the ZK Spreadsheet, it will fulfill your needs.

However if you have to have Excel, then you need a roundtrip solution: load the Excel from an URL (probably generated by an XAgent (?) and save it back. The saving back part is the tricky one. Normal HTTP doesn’t allow that. What you need there is a webDAV capable server. Watch out for a project on OpenNTF soon (just clearing IBM legal) that provides webDAV.

However the ZK Spreadsheet looks much better for your needs.

Answer:

I have a sample database at the following URL –> http://www.nnsu.com/nnsusite.nsf/%24%24OpenDominoDocument.xsp?documentId=B65507CB2DE15B3286257986005F061D&action=openDocument

Download the APCC.nsf. This will allow you to create/read a new EXCEL spreadsheet and then stream the resulting file to the requesting browser. There is not need to have EXCEL or office installed on the Server.

THe examples create a new workbook, but you can also store a “template” on the server or in a notes document and use it as a starting point and then save it to a document or stream it to the requesting browser.

With Apache POI you can read/write to a spreadsheet using data from the notes document the process is initiated from.