I am using Apache POI to read Excel. I add poi-ooxml to read Excel from resource.
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-full</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
And here is my code:
try (InputStream inputStream = this.getClass().getResourceAsStream("/test.xlsx")) {
workbook = new XSSFWorkbook(inputStream);
} catch (IOException e) {
}
It throws exception with
Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument
I tried to add poi-ooxml-lite but it throws a similar exception about missing DocumentFactory. Please help me correct if I got anything wrong.