如何使用Apache POI检查excel单元格是否为空?
问题描述:
我正在使用Poi.jar从excel表中获取输入,并想知道如何检查单元格是否为空。
I am taking input from an excel sheet using Poi.jar and wanted to know how to check if a cell is empty or not.
现在我正在使用以下代码。
Right now I m using the below code.
cell = myRow.getCell(3);
if (cell != null) {
cell.setCellType(Cell.CELL_TYPE_STRING);
//System.out.print(cell.getStringCellValue() + "\t\t");
if (cell.getStringCellValue() != "")
depend[p] = Integer.parseInt(cell.getStringCellValue());
}
}
答
怎么样:
Cell c = row.getCell(3);
if (c == null || c.getCellType() == Cell.CELL_TYPE_BLANK) {
// This cell is empty
}