如何用Java编辑word文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2494709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can you edit a word document with Java
提问by user302267
How can you edit a word document with Java?
如何用Java编辑word文档?
回答by Bryan Denny
Take a look at http://poi.apache.org/
回答by Uri
I'm not familiar with anything standard. It also depends on the version of Word, since various versions use different file formats.
我不熟悉任何标准。它还取决于 Word 的版本,因为不同的版本使用不同的文件格式。
The POI projectfrom Apache is supposed to provide ways to do this:
Apache的POI 项目应该提供执行此操作的方法:
回答by Hannes de Jager
You can use COM to do that also. Use a Java COM interop library like JACOB (JAVA COM BRIDGE): http://sourceforge.net/projects/jacob-project/
您也可以使用 COM 来做到这一点。使用 Java COM 互操作库,如 JACOB(JAVA COM BRIDGE):http: //sourceforge.net/projects/jacob-project/
Here is a tutorial using Jacob to talk to MS Word: http://www.land-of-kain.de/docs/jacob/
这是使用 Jacob 与 MS Word 交谈的教程:http: //www.land-of-kain.de/docs/jacob/
The other library that looks promising and that will solve the cross-platform problem is J-Interop: http://www.j-interop.org/.
另一个看起来很有前途并且可以解决跨平台问题的库是 J-Interop:http: //www.j-interop.org/。
回答by BlairHippo
In the past, I've solved problems like this using OpenOffice.org's Java API. It's not exactly lightweight, but the licensing terms are generous and it has the backing of a development community with a vested interest in making sure it can parse whatever weirdness Microsoft inflicts on the Word file format. Might be worth a look.
过去,我使用OpenOffice.org的 Java API解决了这样的问题。它并不完全是轻量级的,但许可条款是慷慨的,并且得到了开发社区的支持,开发社区的既得利益确保它可以解析微软对 Word 文件格式造成的任何奇怪的问题。可能值得一看。
回答by Paul Jowett
You could try Docmosis, which allows you to populate or produce word docs from Java. It's based on BlairHippo's suggestion of using the OpenOffice API but without needing to learn the api. JODReportsis similar.
您可以尝试Docmosis,它允许您从 Java 填充或生成 word 文档。它基于 BlairHippo 的使用 OpenOffice API 的建议,但无需学习该 API。 JODReports是类似的。