【发布时间】:2015-01-05 10:27:53
【问题描述】:
我正在尝试在 Apache Open Office .odt 文件中插入 HTML 文本
我尝试使用Bold 声明如下所示,但它不起作用。
我有什么遗漏吗?
XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
XMultiServiceFactory oServMan = (XMultiServiceFactory)oStrap.getServiceManager();
XComponentLoader oDesk = (XComponentLoader)oServMan.createInstance("com.sun.star.frame.Desktop");
string url = @"private:factory/swriter";
PropertyValue[] propVals = new PropertyValue[0];
XComponent oDoc = oDesk.loadComponentFromURL(url, "_blank", 0, propVals);
string docText = "<b>This will</b> be my first paragraph.\n\r";
docText += "This will be my second paragraph.\n\r";
((XTextDocument)oDoc).getText().setString(docText);
string fileName = @"C:\test.odt";
fileName = "file:///" + fileName.Replace(@"\", "/");
((XStorable)oDoc).storeAsURL(fileName, propVals);
((XComponent)oDoc).dispose();
oDoc = null;
输出:
【问题讨论】:
-
它是否给出了某种错误?或将文本作为输出但不以粗体显示
-
@Codeek 检查更新...
标签: c# openoffice.org openoffice-writer openoffice-api