0
poiを使用して、私のExcelファイルのすべてのセルを特定の色に設定します。しかし、私は空のセルのnullpointer例外を取得し続けます。これは私がこれまで持っているものです:excel 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);
}
空白のセルをどのように色付けすることができますか?