My code:
package read_write;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.google.common.base.Function;
public class Readexcel {
public static void main(String[] args) throws IOException {
File src = new File("D:\\J\\clients_pw.xlsx");
FileInputStream fis = new FileInputStream (src);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sheet1= wb.getSheet("MAS_details");
String data1 = sheet1.getRow(1).getCell(0).getStringCellValue();
System.out.println(data1);
}
}
I am facing following error while trying to execute this
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipFile at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:298) at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:37) at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:307) at read_write.Readexcel.main(Readexcel.java:19)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.compress.archivers.zip.ZipFile at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
I am not sure if i have added all jars. i have added all apache poi jars and google collect
commons-compress-1.18.jar
, whichpoi-ooxml
needs in version4.0.0
, neither is mentioned in your linked component map nor is it shipped with thepoi-bin-4.0.0-20180907.zip
. – Axel Richter Sep 19 '18 at 14:58