Read excel fie in java using poi

I am struggling to read an Excel file in a dynamic web project that I am developing. I could easily read it in a Java application by following the same steps.

What I've done?

I added them to build a path

  • XMLBeans-2.6.0.jar
  • poi-3.13-20150939
  • Examples
  • poi-excelant
  • poi-ooxml
  • poi-ooxml schemas
  • poi notepad

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

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's quite a long time, but that's the gist of it.

Question

I want to know how to solve this problem, and, as I said, it works in another Java-like file after following the same steps. I want to integrate it into a web application. I also tried calling a routine that imports a Java database from WebApp (which uses tomcat if that helps), still no luck.

+5
source share
1 answer

You need to add jar files not only to the build path. Obviously, you must have the same files in your military module in the WEB-INF / lib folder.

PS I think you do not need a drum with examples.

+4
source

Source: https://habr.com/ru/post/1238238/


All Articles