views:

998

answers:

4

Is there a .NET API for OpenOffice?

EDIT: Is there a OpenOffice SDK for .NET?

A: 

Depends on your needs. Most of the OpenOffice document formats are XML readable, and creatable.

Jeff.Crossett
+2  A: 

Novel has a branch of OOo that adds mono capabilities, so you can use these builds for scripting via .Net inside OOo. The document formats for OOo (except for Base) is XML + resources in a zip container. If you need programmatic access beyond manual file manipulation, your best bet is to use the ActiveX control with COM Interop. If you want to use Base as a datasource in .Net, it is near impossible, as it's an embedded Java database structure without a mature .net port.

Tracker1
+1  A: 

This might help:

"AODL is the .net module of the ODF Toolkit. The library is completly written in pure C# and can be used to extend your .net based software to support the OpenDocument Format. To use AODL within your projects respectively software there is no need of a deep knowlegde of the OpenDocument Format itself. It would be helpfull to understand what's going behind the scenes and for writing your own extensions, but as mentioned before this isn't a fundamental requirement."

remotefacade
+1  A: 

If you have OpenOffice installed, then you can use the "OpenOffice SDK" (version 3.0.0 here) to control that instance from several programming environments, including .NET. You can use OpenOffice this way to accomplish a number of different things; one example is converting files from one file format to another. It's analogous to how you can control Microsoft Office via COM.

A set of CLI/.NET bindings come with the SDK, and are by default installed in

C:\Program Files\OpenOffice.org_3.0_SDK\sdk\cli

I've found Mark Alexander Bain's Creating an OpenOffice Calc Document with C# to be the most straightforward, hands-on, introductory article to controlling OpenOffice that way.

The CLI bindings are mostly a port/mapping of the non-.NET object model, so you'll want to get into things like the non-.NET-specific OpenOffice API Developer's Guide.

So far the main difference I've found between the CLI bindings and the other documentation is that with the CLI bindings you cast an object to a new interface using normal .NET cast syntax rather than with the UnoRuntime.queryInterface() method. For example, instead of

XComponentLoader xComponentLoader =
  (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, desktop);

just use

XComponentLoader xComponentLoader = (XComponentLoader)desktop;

There are also some pretty technical docs of how the OpenOffice/UNO stuff gets mapped onto .NET concepts in the CLI binding here: http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/ProUNO/CLI/CLI_Language_Binding

Chris