Java:使用 POI/HWPF 解析 ms-word 文档

发布于 2024-07-26 20:04:39 字数 451 浏览 1 评论 0原文

我有一个 ms-word 文档(MS-Office 2003;非 xml)。 在此范围内 文档中有一个与书签关联的字符串。 此外, word文档包含word宏。 我的目标是阅读 使用 java 编写文档,替换与书签关联的字符串, 并将文档保存回word格式。

我的第一种方法是使用 Apache POI HWPF:

HWPFDocument doc = new HWPFDocument(new FileInputStream("Test.doc"));
doc.write(new FileOutputStream("Test_generated.doc"));

此解决方案的问题是生成的文件不 不再包含宏(原始文档的文件大小:32k; 生成文档的文件大小19k)。

现在有人可以保留所有原始信息吗 使用 POI/HWPF?

I have a ms-word document (MS-Office 2003; non-xml). Within this
document there is a string associated with a bookmark. Furthermore,
the word document contains word-macros. My goal is to read the
document with java, replace the string associated with the bookmark,
and save the document back to word format.

My first approach was using Apache POI HWPF:

HWPFDocument doc = new HWPFDocument(new FileInputStream("Test.doc"));
doc.write(new FileOutputStream("Test_generated.doc"));

The problem with this solution is that the generated file does not
contain the macro anymore (File size of the original document: 32k;
file size of the generated document 19k).

Does anybody now if it's possible to retain all the original info
using POI/HWPF?

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

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

发布评论

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

评论(1

混吃等死 2024-08-02 20:04:39

从未找到解决方案。 客户必须支付 Aspose 许可证(昂贵)或避免使用宏。

never found a solution. The customer had to pay an Aspose-license (expensive) or refrain from using macros.

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