使用C#与OpenOffice的一般帮助:
http://www.oooforum.org/forum/viewtopic.phtml?p=151606 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;
其中
private static PropertyValue MakePropertyValue(string cName, Any uValue)
{
PropertyValue oPropertyValue = new PropertyValue();
if (!string.IsNullOrEmpty(cName))
oPropertyValue.Name = cName;
oPropertyValue.Value = uValue;
return oPropertyValue;
}
了解更多关于你可以做什么,我们XTextDocument here。请参阅OpenOffice.org Developer's guide。
UPDATE。 一个更加有用的链接:
http://blog.nkadesign.com/2008/net-working-with-openoffice-3/
希望这有助于
感谢您的回答,但什么是使用后“在哪里”的代码?有关C#/ OpenOffice的文档非常少:/ – 2009-07-23 06:20:32