使用 apache poi 读取 Excel 文件时出现异常 [英] exception while reading Excel file with apache poi

查看:48
本文介绍了使用 apache poi 读取 Excel 文件时出现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

读取 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆