I am currently working on a Proof Of Concept around Java CAPS and its capacity to handle, parse and transform Swift messages.
Customer do receive fund subscription orders from their partners and customers in many different formats : XML, CSV and … Excel files.
Excel files are always a bit tricky to handle when you’re not developping nor deploying on Windows servers (if you are using Windows, then check out our DCOM Binding Components as it might be an elegant way to handle DCOM compliant objects from OpenESB – or – our DCOM OTD for the folks using Java CAPS repository-based projects)
The solution I choose to handle these files is quite simple : I am using the OpenOffice API to programmatically open the XLS file with OO and save it as a CSV text file … just like you would do it by hand, using the OO GUI.
I attached a code sample to demonstrate this. This is a complete NetBeans project.
For this sample to compile and execute, you will need a couple of OO jar files in your classpath (see the code sample for the exact list of required jars, they are all shipping with OpenOffice) and you will need to start OpenOffice in background mode, listening to network invocations from your client program (the exact command is given in the code sample).
This was tested on Mac OS X, with Apple’s Java 6 and StarOffice 9 Beta. Enjoy !
The same technique can be applied to programmatically generates PDF files, without buying the expensive Distiller. This will be the subject of my next blog entry.
As usual, your comments and feebacks are welcome.
#1 by gallbladder attack symptoms on 20/12/2009 - 20:47
Using OpenOffice API to convert Excel files is brilliant!