简体   繁体   中英

Reading Excel by Apache POI and Java web application but showing error as “java.io.IOException: org/apache/commons/compress/archivers/zip/ZipFile”

In java web application i need to read the excel file's cell. i used apachi poi here. but it shows error as follows

java.io.IOException: org/apache/commons/compress/archivers/zip/ZipFile

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;


public class importservlet extends HttpServlet { 

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

    PrintWriter out=response.getWriter();        
    try{

      File file=new File("E:\\Book1.xlsx");
      Workbook wb = WorkbookFactory.create(file);
      Sheet sheet = wb.getSheetAt(0);
      out.println(sheet.getRow(1).getCell(1).getCellType());
      wb.close();
      }
    catch(Exception e){
        out.println(e);
     }

     }

     }

i used following jar files

  • poi-4.1.0

  • poi-ooxml-4.1.0

  • poi-ooxml-schemas-4.1.0

  • xmlbeans-3.1.0

  • commons-collections 4.4.3

You are probably missing commons-compress jar library

commons-compress

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