如何使用Apache POI检查excel单元格是否为空? [英] How to check if an excel cell is empty using Apache POI?
本文介绍了如何使用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
}
这篇关于如何使用Apache POI检查excel单元格是否为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文