使用某些版本的 Office 10 打开由 docx4j 保存的文件时出错

Error while openning of saved by docx4j files with some version of Office 10

我使用以下单元测试创​​建了文档

@Test
public void testConvert() throws Docx4JException 
{

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
wordMLPackage.getMainDocumentPart().addParagraphOfText("hello");            
// Now save it 
wordMLPackage.save(new java.io.File("/home/user/DocX/sample.docx") );
}

但是我在使用某些版本的 Microsoft Office 10 for home and business(版本 14.0.6112.5000)打开此文件时出现错误(文件已损坏)。同时它与最新版本的 Microsoft Office 10、Open Office、Office365 和 Liber Office 兼容。

有什么方法可以解决此问题,以便能够使用任何版本的 Office 10 打开文档。 谢谢

可能你的问题是 docx4j.properties 属性: docx4j.AppVersion

docx4j.AppVersion=3.3
# of the form XX.YYYY where X and Y repre**strong text**sent numerical values
# WARNING: -SNAPSHOT will cause Word 2010 x64 to treat the docx as corrupt!

确保值为 3.2 或 3.3,而不是说 3.2.1

或设置docx4j.App.write=false