使用apache poi读取Excel文件时出现exception
问题阅读Excel 2007文件.xlsx文件扩展名,而我正在尝试阅读apache poi:
InputStream file = new FileInputStream(C:\\test.xlsx); ---> XSSFWorkbook workbook = new XSSFWorkbook(file);
这行在Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
给我一个exceptionException in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
请问,这个错误可能是什么原因造成的?
您需要在类路径中包含名为xmlbeans-xxxjar
的jar文件,该文件位于文件夹“your_location_of_poi \ poi-xx \ ooxml-lib \”下。
注意: xx
是您正在使用的poi版本, xxx
是上述文件夹下该jar文件的版本号
你下载额外的jar文件。 你可以下载:
你错过了POI附带的额外jar文件。 将它们包含在类路径中。
您的类路径中没有XMLBeans。
我下载了xmlbeans.jar并添加到Library作为External Jar。 它解决了我的问题。