exception while reading Excel file with apache poi

2019-02-25 01:56发布

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);

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?

5条回答
地球回转人心会变
2楼-- · 2019-02-25 02:15

You don't have XMLBeans in your classpath.

查看更多
Fickle 薄情
3楼-- · 2019-02-25 02:32

I downloaded xmlbeans.jar and added to Library as External Jar. It resolved my issue.

查看更多
Bombasti
4楼-- · 2019-02-25 02:37

You're missing the extra jar files that come with POI. Include them in your classpath.

查看更多
Evening l夕情丶
6楼-- · 2019-02-25 02:42

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.

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

查看更多
登录 后发表回答