将 C# 与 OpenOffice 结合使用的一般帮助:
http://www.oooforum.org/forum/viewtopic.phtml?p=151606 http://www.oooforum.org/forum/viewtopic.phtml?p=151606
http://opendocument4all.com/content/view/68/47/ http://opendocument4all.com/content/view/68/47/
使用 OO 3.0,您需要引用 cli_*.dll 库,安装 OO 时会将它们放入 GAC。
初始化 OO 连接的示例代码:
private static XMultiServiceFactory _multiServiceFactory;
private static XComponentLoader _componentLoader;
private static XFileIdentifierConverter _urlConverter;
private static void Initialize()
{
XComponentContext localContext = uno.util.Bootstrap.bootstrap();
_multiServiceFactory = (XMultiServiceFactory)localContext.getServiceManager();
_componentLoader = (XComponentLoader)_multiServiceFactory.createInstance("com.sun.star.frame.Desktop");
_urlConverter = (XFileIdentifierConverter)_multiServiceFactory.createInstance("com.sun.star.ucb.FileContentProvider");
}
加载文档:
string url = _urlConverter.getFileURLFromSystemPath(Path.GetPathRoot(path), path);
XComponent xComponent = _componentLoader.loadComponentFromURL(url, "_blank", 0, new PropertyValue[] { MakePropertyValue("Hidden", new uno.Any(true))});
XTextDocument doc = (XTextDocument)xComponent;
where
private static PropertyValue MakePropertyValue(string cName, Any uValue)
{
PropertyValue oPropertyValue = new PropertyValue();
if (!string.IsNullOrEmpty(cName))
oPropertyValue.Name = cName;
oPropertyValue.Value = uValue;
return oPropertyValue;
}
阅读更多有关我们可以做什么的信息 XTextDocumenthere http://api.openoffice.org/docs/common/ref/com/sun/star/text/XTextDocument.html.
也可以看看OpenOffice.org 开发人员指南 http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide.
UPDATE。
另一个有用的链接:
http://blog.nkadesign.com/2008/net-working-with-openoffice-3/ http://blog.nkadesign.com/2008/net-working-with-openoffice-3/
希望这可以帮助