16 thoughts on “Read & write excel sheet data in Java using Apache POI

  1. I tried exactly the same code and also have downloaded JARs from the link provided. On running i get error as below
    Exception in thread "main" java.io.IOException: org/apache/commons/compress/archivers/zip/ZipFile

    at org.apache.poi.ss.usermodel.WorkbookFactory.createWorkbook(WorkbookFactory.java:353)

    at org.apache.poi.ss.usermodel.WorkbookFactory.createXSSFWorkbook(WorkbookFactory.java:316)

    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:234)

    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:200)

    at readingData.ReadDatafromExcel.main(ReadDatafromExcel.java:23)

    Caused by: java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile

    at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:307)

    at org.apache.poi.xssf.usermodel.XSSFWorkbookFactory.createWorkbook(XSSFWorkbookFactory.java:134)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:498)

    at org.apache.poi.ss.usermodel.WorkbookFactory.createWorkbook(WorkbookFactory.java:341)

    … 4 more

    Caused by: java.lang.ClassNotFoundException: org.apache.commons.compress.archivers.zip.ZipFile

    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)

    … 11 more
    I am getting this on line:
    "wb = WorkbookFactory.create(file)"
    Any ideas if something has changed or if the newer java version might not be compatible with something.
    I am using jre 8 update 231 and the downloaded jars are also updated. poi updated to 4.1.1 and xml beans have updated to

  2. your tutorial doesn't makes sense to me as I have 20 rows and 20 columns to deal with.
    Take cell count too and apply 2 For loop.

  3. Hi, Thanks for the helpful content you have shared. I continued to research this topic and I found on the net JSpreadsheet. It’s Java API for Microsoft Excel from Independentsoft company. There are a number of use cases on the site and the API itself is well documented.

Leave a Reply

Your email address will not be published. Required fields are marked *