protected List<List<XSSFCell>> read2DTable(XSSFSheet sheet) {
LOGGER.debug("read2DTable START");
List<XSSFCell> headerCells = readTableHeader(sheet);
List<List<XSSFCell>> allRows = IntStream.range(sheet.getFirstRowNum(), sheet.getLastRowNum()+1)
.mapToObj(i -> sheet.getRow(i))
.map(row -> headerCells.stream()
.map(col -> row.getCell(col.getColumnIndex()))
.collect(Collectors.toList()))
.filter(c -> StringUtils.isNotEmpty(c.toString()))
.collect(Collectors.toList());
LOGGER.info("rows read: {}, columns read: {}", allRows, headerCells.size());
LOGGER.info("read2DTable END");
return allRows;
}
This is the error:
Caused by: java.lang.NullPointerException
at com.netcracker.solutions.gtdc.cim.importdata.processing.excel.ExcelProcessor.lambda$null$9(ExcelProcessor.java:162)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at com.netcracker.solutions.gtdc.cim.importdata.processing.excel.ExcelProcessor.lambda$read2DTable$10(ExcelProcessor.java:162)
that happens in here :
.map(col -> row.getCell(col.getColumnIndex()))
.collect(Collectors.toList()))
.filter(c ->StringUtils.isNotEmpty(c.toString()))
.collect(Collectors.toList());