简体   繁体   中英

Reading Excel File using POI jar file

I have written a program which reads input from csv file and its working fine. I read the inputstream of the csv file as follows.

BufferedReader br=new BufferedReader(new InputStreamReader(item.getInputStream()));

Now I am changing the program so as to read input from excel file. So I changed the code to this format and while compilation there are no errors.

POIFSFileSystem ps = new POIFSFileSystem(item.getInputStream());
HSSFWorkbook workbook = new HSSFWorkbook(ps);

But while submitting the JSP page, I get the following error. What must be the problem and where I have went wrong? Please advise.

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem
Readcsvv.doPost(Readcsvv.java:120)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Your POI jars are not in the classpath. Put them in the WEB-INF/lib folder.
Another less likely reason could be that your version of jars is different than those expected.

It looks like you've forgotten to include the POI library on the CLASSPATH (eg It's not referenced by your web app). You can include this lib under WEB-INF/lib (in your WAR archive or in the exploded directory format) or it can sit elsewhere in your app server/web server CLASSPATH

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM