Is there OLE Automation in Java?

Shahab picture Shahab · Jul 13, 2011 · Viewed 10.7k times · Source

Is it possible to use OLE Automation in Java? If not, why is it not possible in Java?

I'm looking to automate the exporting of excel spreadsheets in different format (ie, .csv etc...)

Thanks for the answers in advance :)

Answer

allquixotic picture allquixotic · Apr 22, 2013

Recently (March 2013), an independent contributor added support for generic COM Automation to JNA, which is the last man standing in terms of native platform API integration from Java. JNA is still very actively maintained, unlike Jawin/JACOB/etc.

See here for an example of how it is used. The pre-cooked bindings to the Office APIs are very simple so far, but looking at the code, it seems very easy to use the COM Automation APIs (IDispatch, Variant, etc) to do late binding to almost any COM interface.

I would like to see, however, a more complete binding of the Office COM APIs, since they are by far the most often used COM API in the world. Maybe there could also be an "MSExcel2007.java", "MSExcel2010.java", etc. to cover the different API versions. So it's very much a work in progress, but JNA is now as generally useful for COM Automation as JACOB/Jawin, with the bonus that it's extremely actively maintained (as of April 2013).