【问题标题】:Insert HTML Text Into OpenOffice Document (.odt) Files将 HTML 文本插入 OpenOffice 文档 (.odt) 文件
【发布时间】: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


【解决方案1】:

正如the other question 中已经回答的那样 - 您必须使用字符属性来获取粗体(或其他属性)文本

【讨论】:

  • 我已经为 Exporting MS Word 构建了长 HTML 我想找到解决方案,或者有什么方法可以直接在这些 .odt 文件中注入 HTML
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-25
  • 1970-01-01
  • 2019-08-22
相关资源
最近更新 更多