C# 将HTML文本插入OpenOffice文档(.odt)文件

C# 将HTML文本插入OpenOffice文档(.odt)文件,c#,openoffice.org,openoffice-writer,openoffice-api,C#,Openoffice.org,Openoffice Writer,Openoffice Api,我正在尝试在ApacheOpenOffice.odt文件中插入HTML文本 我尝试使用如下所示的粗体语句,但它不起作用 是不是我遗漏了什么 XComponentContext oStrap = uno.util.Bootstrap.bootstrap(); XMultiServiceFactory oServMan = (XMultiServiceFactory)oStrap.getServiceManager(); XComponentLoader oDesk = (XC

我正在尝试在ApacheOpenOffice
.odt
文件中插入HTML文本

我尝试使用如下所示的
粗体
语句,但它不起作用

是不是我遗漏了什么

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;
XComponentContext oStrap=uno.util.Bootstrap.Bootstrap();
XMultiServiceFactory oServMan=(XMultiServiceFactory)oStrap.getServiceManager();
XComponentLoader oDesk=(XComponentLoader)oServMan.createInstance(“com.sun.star.frame.Desktop”);
字符串url=@“private:factory/swriter”;
PropertyValue[]propVals=新的PropertyValue[0];
XComponent oDoc=oDesk.loadComponentFromURL(url,“_blank”,0,propVals);
string docText=“这将是我的第一段。\n\r”;
docText+=“这将是我的第二段。\n\r”;
((XTextDocument)oDoc.getText().setString(docText);
字符串文件名=@“C:\test.odt”;
fileName=“file://“+fileName.Replace(@“\”,“/”);
((XStorable)oDoc.storeAsURL(文件名,propVals);
((XComponent)oDoc.dispose();
oDoc=null;
输出:


如中所述-您必须使用字符属性来获取粗体(或其他属性化)文本

是否出现某种错误?或者将文本作为输出,但不以bold@Codeek检查更新…我已经为导出MS Word构建了长HTML,我想找到解决方案,或者是否有任何方法可以直接在这些
.odt
文件中插入HTML