https://bz.apache.org/bugzilla/show_bug.cgi?id=69742
Bug ID: 69742 Summary: An error occurred when converting a word file to XWPFDocument, indicating java.io.IOException: Failed to read zip entry source. Product: POI Version: unspecified Hardware: PC Status: NEW Severity: normal Priority: P2 Component: HWPF Assignee: dev@poi.apache.org Reporter: 969675...@qq.com Target Milestone: --- Created attachment 40070 --> https://bz.apache.org/bugzilla/attachment.cgi?id=40070&action=edit This is the word file that I need to convert. 您好,我在将word文件转XWPFDocument时,出现了报错,报错信息为:java.io.IOException: Failed to read zip entry source。 我的开发环境如下: window 11 jdk 11.0.10 pom配置: <dependency> <groupId>fr.opensagres.xdocreport</groupId> <artifactId>org.apache.poi.xwpf.converter.xhtml</artifactId> <version>1.0.6</version> </dependency> 相关代码: try{ File wordFile = new File("D:\\website\\temp\\myWordFile.docx"); File htmlFile = new File("D:\\website\\temp\\myWordFile.html"); String imageName = baseWordFileImagePath + "notComPressImage" ; if (!wordFile.exists()) { return null ; } else { // 1) 加载word文档生成 XWPFDocument对象 InputStream in = new FileInputStream(wordFile); XWPFDocument document = new XWPFDocument(in); // 2) 解析 XHTML配置 (这里设置IURIResolver来设置图片存放的目录) File imageFolderFile = new File(imageName); XHTMLOptions options = XHTMLOptions.create().URIResolver(new FileURIResolver(imageFolderFile)); options.setExtractor(new FileImageExtractor(imageFolderFile)); options.setIgnoreStylesIfUnused(false); options.setFragment(false); // 3) 将 XWPFDocument转换成XHTML OutputStream out = new FileOutputStream(htmlFile); XHTMLConverter.getInstance().convert(document, out, options); } return htmlFile ; }catch (Exception e){ return null ; } 当代码运行到 XWPFDocument document = new XWPFDocument(in)时,会报java.io.IOException: Failed to read zip entry source的错误信息。 我的word 文件上传到了attachment中,请下载进行验证,谢谢。 如果你们找到了问题和解决方案,请及时通过969675...@qq.com的邮箱联系我,谢谢。 -- You are receiving this mail because: You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org