方法一:
public static boolean isEmptyRow(Row row) {
if (row == null || row.toString().isEmpty()) {
return true;
} else {
Iterator<Cell> it = row.iterator();
boolean isEmpty = true;
while (it.hasNext()) {
Cell cell = it.next();
if (cell.getCellType() != Cell.CELL_TYPE_BLANK) {
isEmpty = false;
break;
}
}
return isEmpty;
}
}
方法二:
public static boolean isEmptyRow(Row row) {
if (row == null || row.toString().isEmpty()) {
return true;
} else {
boolean isEmpty = true;
// 从第一个不为空的列开始 到 最后一个 不为空的列(有格式就算一列 )
for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) {
Cell cell = row.getCell(c);
if (cell != null && cell.getCellType() != CellType.BLANK){
isEmpty = false;
break;
}
}
return isEmpty;
}
}