I am new to Apache POI, and I need to write to an excel file based on the contents of my DB. However, when there is an empty/null field in the DB, a Null Pointer Exception is thrown for that particular field. I've been reading about Missing Cell Policies, is this the best way to address this? I have omitted a lot of code for brevity, but the below is the key part. For example if actualAmountReturned is empty in the DB, a NPE is thrown.
List<CaseData> cases = (List<CaseData>) model.get("cases");
int rowCount = 1;
for (CaseData pieCase : cases) {
Row userRow = sheet.createRow(rowCount++);
userRow.createCell(0).setCellValue(pieCase.getCaseId());
userRow.createCell(1).setCellValue(pieCase.getAcknowledgementReceivedDate());
userRow.createCell(2).setCellValue(pieCase.getActualAmountReturned());
}
pieCase.getActualAmountReturned()
return? - Axel Richter