poi를 사용하여 내 엑셀 파일의 모든 셀을 특정 색으로 설정하고 싶습니다. 그러나 빈 셀에 대해 nullpointer 예외가 계속 발생합니다. 이것은 내가 지금까지 가지고있는 것입니다 :엑셀 poi : 빈 셀에 전경색 적용
HSSFWorkbook workBook = new HSSFWorkbook();
HSSFCellStyle whiteFG = workBook.createCellStyle();
whiteFG.setFillForegroundColor(HSSFColor.AQUA.index);
whiteFG.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
//each row has 20 columns
int numColumns = 20;
for (int colNum = 0 ; colNum < numColumns ; colNum++){
HSSFCell cell = row.getCell((short)colNum);
if (cell != null){
cell.setCellStyle(whiteFG);
}
else if ("".equals(cell.getStringCellValue())){
cell.setCellStyle(whiteFG);
}
else() {
cell.setCellStyle(whiteFG);
}
내가 어떻게 빈 셀을 채울 수 있습니까?