Java的:解析使用POI / HWPF MS-word文档 [英] Java: parsing ms-word document using POI/HWPF
问题描述
我有一个MS-word文档(MS-Office 2003的非XML)。在这
文件存在与书签相关联的字符串。此外,
在Word文档中包含字的宏。我的目标是读
用java文件,替换与书签关联的字符串,
并保存文档回Word格式。
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.
我的第一种方法是使用Apache POI HWPF:
My first approach was using Apache POI HWPF:
HWPFDocument doc = new HWPFDocument(new FileInputStream("Test.doc"));
doc.write(new FileOutputStream("Test_generated.doc"));
使用此解决方案的问题是,所生成的文件不
包含原始文档的宏了(文件大小:32K;
生成的文档19K的文件大小)。
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).
现在是否有人,如果有可能保留所有的原始信息
使用POI / HWPF?
Does anybody now if it's possible to retain all the original info using POI/HWPF?
推荐答案
没有找到一个解决方案。客户必须支付的阅读Aspose许可证(昂贵),或使用宏避免。
never found a solution. The customer had to pay an Aspose-license (expensive) or refrain from using macros.
这篇关于Java的:解析使用POI / HWPF MS-word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!