我如何(应该?)使用 Apache POI HWPFDocument?

发布于 2024-07-11 21:42:15 字数 203 浏览 6 评论 0原文

我正在考虑将 Apache POI 包含到我的应用程序中。 主要目标是输出 RTF 文档,但 DOC 也不错。 但是该文档对于编写 HWPFDocument 并不是很详细,而且我在网上找到的所有内容都没有任何帮助。

我可以读取 DOC 文件,工作没有任何问题。 但我真的不明白我怎么写文档。 也许有人可以给我一个简短的代码示例?

多谢!

I'm thinking about including the Apache POI into my application. Main goal is to output RTF document, but DOC would be nice, too. But the documentation is not very detailed about writing a HWPFDocument and everything I found on the web isn't helpful at all.

I can read DOC files, that's working without any problem. But I really can't see how I write a document. Maybe someone can give me a short code example?

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猫烠⑼条掵仅有一顆心 2024-07-18 21:42:15

如果您想做 RTF,这些是文本文件,所有版本的 Word 都支持它们。

你可以使用 itext 来做简单的事情
http://itextdocs.lowagie.com/tutorial/rtf/index.php

ro

你可以用困难的方式导出它们

//-- 另存为 example.doc -------------

{
\rtf1
\ansi
\ansicpg1252
\deff0
\deflang1033
  {\fonttbl
    {\f0
     \fswiss
     \fcharset0 Arial;
    }
  }
  {
  \*
  \generator Msftedit 5.41.21.2500;
  }
  \viewkind4
  \uc1
  \pard
  \f0
  \fs20 

  Hello World

  \par
}

If you want to do RTF, These are text files and they are support in all versions of Word.

you can use itext for simple stuff
http://itextdocs.lowagie.com/tutorial/rtf/index.php

ro

you can export them the hard way

//-- save as example.doc -------------

{
\rtf1
\ansi
\ansicpg1252
\deff0
\deflang1033
  {\fonttbl
    {\f0
     \fswiss
     \fcharset0 Arial;
    }
  }
  {
  \*
  \generator Msftedit 5.41.21.2500;
  }
  \viewkind4
  \uc1
  \pard
  \f0
  \fs20 

  Hello World

  \par
}
橘和柠 2024-07-18 21:42:15

嗯,

距离上次使用 POI 已经有很长一段时间了。 我读到 HWPFDocument 现在是孤立的(在 apache POI 网站上阅读)。 我建议使用 Microsoft 发布的 WordML 规范。

http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats

我以前用过这种方法。 最简单的方法是创建一个 WordML 模板并使用 XPATH 替换值

Well,

It has been a long time since the last time I used POI. I read that the HWPFDocument is now orphaned (read on apache POI website). I would recommend using the WordML specification released by Microsoft instead.

http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats

I have used this method before. The easiest way is to create a WordML template and just replace the values using XPATH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文