我使用以下单元测试创建了文档
@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 10,用于家庭和业务(14.0.6112.5000版本)。同时,它适用于最新版本的Microsoft 10、Office、Office365和Liber。
有没有办法解决这个问题,以便打开任何版本的Office 10文档。谢谢
发布于 2016-01-28 03:03:56
可能您的问题是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
https://stackoverflow.com/questions/35039541
复制相似问题