org.apache.poi.POIXMLException目前不支持严格的OOXML,请参阅bug#57699

我想用javaparsing一个Excel文件,所以我使用apache poi库,在这里你是maven的依赖:

<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.14</version> </dependency> 

这将包括一系列的依赖关系:

 poi-ooxml-3.14.jar poi-3.14.jar commons-codec-1.10.jar poi-ooxml-schemas-3.14.jar xmlbeans-2.6.0.jar stax-api-1.0.1.jar curvesapi-1.03.jar 

当我尝试使用以下代码读取Office 365 Excel文件(.xslx)时:

 import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ExcelConverter { public static void main(String[] args) throws Exception{ String excelFilePath = "C:/temp/Book1.xlsx"; File myFile = new File(excelFilePath); System.out.println("File exists: " + myFile.exists()); FileInputStream inputStream = new FileInputStream(myFile); Workbook workbook = new XSSFWorkbook(inputStream); } } 

我得到了以下控制台消息:

 File exists: true Exception in thread "main" org.apache.poi.POIXMLException: Strict OOXML isn't currently supported, please see bug #57699 at org.apache.poi.POIXMLDocumentPart.getPartFromOPCPackage(POIXMLDocumentPart.java:679) at org.apache.poi.POIXMLDocumentPart.<init>(POIXMLDocumentPart.java:122) at org.apache.poi.POIXMLDocumentPart.<init>(POIXMLDocumentPart.java:115) at org.apache.poi.POIXMLDocument.<init>(POIXMLDocument.java:61) at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:273) at org.myCompany.excel.ExcelConverter.main(ExcelConverter.java:25) 

你知道我能做些什么来解决这个问题吗? 提前致谢

目前看来,除了:

不要将电子表格保存为“严格的OOXML”格式。