来自 Java 的邮件合并

发布于 2024-08-24 00:53:46 字数 236 浏览 5 评论 0原文

有谁有从 Java 对 Word 文档进行邮件合并的经验吗?我需要支持 doc 和 docx 格式。

我听说过 Apache POI 和 docx4j。然而,通过阅读周围的内容,我确信 POI 中“支持”这个词有多好。据我所知,docx4j 仅支持 docx 格式。

任何人都可以建议上述之一(并纠正我的支持知识)或另一个合适的图书馆。如果有必要,我愿意使用一个库作为 doc,另一个库作为 docx。

谢谢。

Does anyone have any experience with doing mail merge from Java on a word document? I need to support both doc and docx formats.

I have heard of Apache POI and docx4j. However, from reading around I'm sure how good the word support is in POI. docx4j only supports docx format as far as I can see.

Can any suggest either one of the above (and correct my knowledge on support) or another appropriate library. If necessary I would be willing to use one lib for doc and another for docx.

Thanks.

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

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

发布评论

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

评论(5

海拔太高太耀眼 2024-08-31 00:53:47

使用 MS Word 文档非常困难。 DOC 格式非常复杂,DOCX 理论上更简单,但它相当新,并且没有成熟的、功能丰富的 Java 库来使用它和 DOC。

Joel 中描述了与使用 MS Office 文档相关的大多数问题的最简单解决方案斯波尔斯基文章。我希望您可以在您的应用程序中使用此方法。

Working with MS Word documents is very hard. DOC format is very complicated, DOCX is in theory simpler, but it is rather new and there is no mature, feature rich Java library to work with it and DOC as well.

The easiest solutions to most problems connected with working with MS Office documents is describe in the Joel Spolsky article. I hope you can use this method in your application.

失眠症患者 2024-08-31 00:53:47

Docx4j 有一个 MailMerger 类。它有效,但它在此过程中删除了很多格式。

Docx4j has a MailMerger class. It works, but it strips out a lot of formatting in the process.

提笔书几行 2024-08-31 00:53:47

查看 OpenOffice 以[手动]查看它是否可以生成您需要的文件类型。只需加载一些文档,并保存一些文档和 docx 版本。如果结果通过这些简单的手动测试,则 DocmosisJODReports 可以通过 Java 自动执行此操作。

Have a look at OpenOffice to see [manually] whether it can produce the types of files you need. Just load up some docs, and save some docs and docx versions. If the results pass these simple manual tests, then Docmosis or JODReports can automate this from Java.

沉睡月亮 2024-08-31 00:53:47

如果您愿意接受非自由解决方案,Aspose 提供了看起来非常复杂的 用于邮件合并的 Java API 等。

If you're open to non-free solutions, Aspose provides what appears to be a very sophisticated Java API for mail merging, among other things.

熟人话多 2024-08-31 00:53:47

我需要类似的东西,并构建了一个简单的项目,允许对 Word 文档和 Excel/CSV 文件中的数据进行邮件合并。

您可以在 https://github.com/centic9/poi-mail-merge,也许它已经提供了您需要的东西,否则希望很容易添加更多功能。

I needed something similar and have built a simple project which allows to do a mail-merge of a word document and data from an Excel/CSV file.

You can find it at https://github.com/centic9/poi-mail-merge, maybe it already provides what you need here, otherwise it is hopefully easy to add more features.

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