Java: parsing ms-word document using POI/HWPF

笑着哭i 提交于 2019-12-23 17:05:26

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/1108886/java-parsing-ms-word-document-using-poi-hwpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!