4

I'm trying to read a simple .xlsx in java

private void readExcelData(String excel) throws Exception {
    FileInputStream file = new FileInputStream(excel);
    XSSFWorkbook workbook = new XSSFWorkbook(file);
    XSSFSheet sheet = workbook.getSheetAt(0);
}

but i get Exception in thread "AWT-EventQueue-0" java.lang.IncompatibleClassChangeError: Found interface org.apache.poi.util.POILogger, but class was expected

I had to add xmlbeans-xmlpublic-2.3.0.jar or it gives me Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException Maybe it has something to do with that.

Does someone have a solution ?

1 Answer 1

2

You have a dependency issue, find out which jar is being used. Perhaps conflicting versions of poi jar, poi-4.1.0.jar is needed and you have poi-4.0.1.jar.

ClassLoader classloader = org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
URL res = classloader.getResource("org/apache/poi/util/POILogger.class");
String path = res.getPath();
System.out.println("POI came from " + path);

If you are using maven, run "mvn dependency:tree -Dverbose" to show included jars.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.