private static int getRightRows(Sheet sheet) {
int rsCols = sheet.getColumns(); // 列数
int rsRows = sheet.getRows(); // 行数
int nullCellNum;
int afterRows = rsRows;
for (int i = 2; i < rsRows; i++) { // 统计行中为空的单元格数
nullCellNum = 0;
for (int j = 0; j < rsCols; j++) {
String val = sheet.getCell(j, i).getContents();//获取单元格内容
val = StringUtils.trimToEmpty(val);
if (StringUtils.isBlank(val))//判断单元格是否为空计算空单元格的数量
nullCellNum++;
}
if (nullCellNum >= rsCols) { // 如果nullCellNum大于或等于总的列数
afterRows--; // 行数减一
}
}
return afterRows;
}