private void testExcel(String fileName) {
ClassLoader classLoader = getClass().getClassLoader();
File file = new File(classLoader.getResource(fileName).getFile());
Workbook workbook = StreamingReader.builder()
.rowCacheSize(100) // number of rows to keep in memory (defaults to 10)
.bufferSize(4096) // buffer size to use when reading InputStream to file (defaults to 1024)
.open(file);
}
Error Logs:
java.lang.NoClassDefFoundError: org/apache/poi/POIXMLTypeLoader
at org.openxmlformats.schemas.spreadsheetml.x2006.main.SstDocument$Factory.parse(Unknown Source)
at org.apache.poi.xssf.model.SharedStringsTable.readFrom(SharedStringsTable.java:119)
at org.apache.poi.xssf.model.SharedStringsTable.<init>(SharedStringsTable.java:106)
at org.apache.poi.xssf.eventusermodel.XSSFReader.getSharedStringsTable(XSSFReader.java:82)
at com.monitorjbl.xlsx.impl.StreamingWorkbookReader.init(StreamingWorkbookReader.java:117)
at com.monitorjbl.xlsx.StreamingReader$Builder.open(StreamingReader.java:278)
This looks like a classpath problem to me. If I had to guess, you've got some conflicting versions of POI in there. The current version of the library needs POI 3.13.
I use the latest version.
My code:
Error Logs: