阅读使用POI在Java中的Excel呸 [英] Read excel fie in java using poi
问题描述
我奋力来读取Excel文件中的动态Web项目我发展。我可以很容易地按照相同的步骤阅读它在Java应用程序。
I am struggling to read excel file in a dynamic web project I am developing. I could easily read it in a java application by following the same steps.
我干了什么?
我添加了这些构建路径
- 的XMLBeans-2.6.0.jar
- POI-3.13-20150939
- POI-例子
- POI-excelant
- POI-OOXML
- POI-OOXML-架构
- POI暂存器
code:
FileInputStream input_document = new FileInputStream(new File("file_location"));
XSSFWorkbook my_xls_workbook = new XSSFWorkbook(input_document);
XSSFSheet my_worksheet = my_xls_workbook.getSheetAt(0);
XSSFCell cell=null;
for(int i=0;i<463;i++){
cell = my_worksheet.getRow(i).getCell(0);
words[i]=cell.getStringCellValue();
System.out.println(words[i]);
}
my_xls_workbook.close();
的错误
SEVERE: StandardWrapper.Throwable
java.lang.NoClassDefFoundError: org/apache/poi/xssf/usermodel/XSSFWorkbook
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet vhealth.GetMed
java.lang.ClassNotFoundException: org.apache.poi.xssf.usermodel.XSSFWorkbook
这是pretty长,但这是它的精神
It is pretty long but this is the gist of it
问题
我想知道如何解决这个和我提到它按照相同的步骤后,工作在另一个类似的Java文件。我想它在Web应用程序集成。我也打过电话从Web应用程序中导入数据库在Java程序(它使用Tomcat是否有帮助)仍然没有运气。
I want to know how to solve this and as I mentioned it works in another similar java file after following the same steps. I want to integrate it in the web app. I've also tried calling the routine which imports the database in Java from the WebApp(which uses tomcat if that helps) still no luck.
感谢
推荐答案
您不仅需要在构建路径中添加jar文件。你需要显然有在WEB-INF / lib文件夹你的战争模块相同的文件。
You need to add jar files not only in the build path. You need obviously to have the same files in your war module in the WEB-INF/lib folder.
P.S。我认为你不需要POI-例子罐子。
P.S. I think you don't need poi-examples jar.
这篇关于阅读使用POI在Java中的Excel呸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!