I am using the Apache POI Library to get the data from EXCEL Sheet. I have attached the EXCEL Sheet which has the yellow part highlighted. I am trying to extract the all the data from EXCEL Sheet but I am not getting the data from the highlighted part. It gives the null pointer exception when trying to access these cells.
SAMPLE Document : Document
SAMPLE Code.
FileInputStream inputStream = new FileInputStream(file);
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet firstSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = firstSheet.iterator();
while (iterator.hasNext()) {
Row nextRow = iterator.next();
Iterator<Cell> cellIterator = nextRow.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
System.out.print(cell.getStringCellValue());
System.out.print(",");
}
System.out.println();
}
workbook.close();
inputStream.close();
When you run the above program you will get some fields are not extracted from the excel sheet(Highlighted Part). When you explicitly try to access those cells you will get the null pointer exception.