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.
我正在努力阅读我正在开发的动态Web项目中的excel文件。我可以通过遵循相同的步骤在Java应用程序中轻松阅读它。
What I did?
我做了什么?
I added these to build path
我添加了这些来构建路径
- xmlbeans-2.6.0.jar
- XMLBeans的-2.6.0.jar
- poi-3.13-20150939
- POI-3.13-20150939
- poi-examples
- POI-例子
- poi-excelant
- POI-excelant
- poi-ooxml
- POI-OOXML
- poi-ooxml-schemas
- POI-OOXML-模式
- poi-scratchpad
- 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();
The Error
错误
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
It is pretty long but this is the gist of it
它很长,但这是它的要点
The Question
问题
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.
我想知道如何解决这个问题,正如我所提到的,它遵循相同的步骤后在另一个类似的java文件中工作。我想将它集成到网络应用程序中。我也试过调用从WebApp导入Java数据库的例程(如果有帮助就使用tomcat)仍然没有运气。
Thanks
谢谢
1 个解决方案
#1
4
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.
您不仅需要在构建路径中添加jar文件。显然,你需要在WEB-INF / lib文件夹中的war模块中拥有相同的文件。
P.S. I think you don't need poi-examples jar.
附:我想你不需要poi-examples jar。
#1
4
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.
您不仅需要在构建路径中添加jar文件。显然,你需要在WEB-INF / lib文件夹中的war模块中拥有相同的文件。
P.S. I think you don't need poi-examples jar.
附:我想你不需要poi-examples jar。