I am working on requirement where I need to read large xlsx file contains more than one million records. The apache POI is not memory efficient when reading large files .Hence I am using below API which adds
https://github.com/monitorjbl/excel-streaming-reader which is a wrapper around that streaming API while preserving the syntax of the standard POI API. Everything working fine except reading blank cells in the row. The above API throwing null pointer if cell is blank
for(int i=0; i<=expectedColumns-1; i++) {
Cell cell = row.getCell(i);
switch (cell.getCellType()) {
}
}
java.lang.NullPointerException
at test.XLSXToCSVConverterStreamer.xlsx(XLSXToCSVConverterStreamer.java:67)
at test.XLSXToCSVConverterStreamer.main(XLSXToCSVConverterStreamer.java:164)
if a cell in row is null it is throwing null pointer at Switch case i.e cell.getCelltype. I have modified code to read null cells as blank cells but its not supporting
for(int i=0; i<=expectedColumns-1; i++) {
//Cell cell = row.getCell(i);
Cell cell = row.getCell(i, Row.CREATE_NULL_AS_BLANK);
switch (cell.getCellType()) {
}
}
if I use Cell cell = row.getCell(i, Row.CREATE_NULL_AS_BLANK) to read empty cells as blank I am getting below issue. Kindly help me in resolving this
com.monitorjbl.xlsx.exceptions.NotSupportedException
at com.monitorjbl.xlsx.impl.StreamingRow.getCell(StreamingRow.java:108)
if (cell != null)
before your switch statement? – Gagravarr