使用 apache poi 读取 Excel 文件时出现异常 [英] exception while reading Excel file with apache poi
问题描述
读取 Excel 2007 文件 .xlsx 文件扩展名时出现问题,而我正在尝试使用 apache poi 读取:
Problem reading Excel 2007 file .xlsx file extention, while I am trying to read with 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
请问这个错误的原因是什么?
This line giving me an exception Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject
please, what can be cause of this error?
推荐答案
您需要在文件夹your_location_of_poi\poi-xx\ooxml-lib"下包含一个名为 xmlbeans-xxxjar
的 jar 文件\" 在您的类路径中.
you need to include a jar file named xmlbeans-x.x.x.jar
that comes under folder "your_location_of_poi\poi-x.x\ooxml-lib\" in your classpath.
注意:x.x
是你使用的 poi 版本,x.x.x
是上面提到的文件夹下那个 jar 文件的版本号
Note: x.x
is the version of poi that you are using and x.x.x
is the version number of that jar file under the above mentioned folder
这篇关于使用 apache poi 读取 Excel 文件时出现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!