0

我可以仅使用 Apache POI将旧的.doc文件转换为html 。

但是,对于 .docx,我必须使用该fr.opensagres.xdocreport包。代码非常简单:

    XWPFDocument document = new XWPFDocument(inputStream);
    OutputStream outputStream = new ByteArrayOutputStream();
    XHTMLOptions options = XHTMLOptions.create().indent(4).setImageManager(new Base64EmbedImgManager());
    XHTMLConverter.getInstance().convert(document, outputStream, options);
    return outputStream.toString();

但是,有两个问题

  • 嵌入的 excel 图表被忽略(使用 Apache POI 的.doc转换将它们转换为图像,就像它对任何其他普通图像所做的那样)
  • 具有自定义各种格式组合的文本未正确呈现,不必要地插入了几行换行符。(参见输入输出示例)

有人知道解决这个问题的方法吗?

谢谢你。

4

0 回答 0