How to determine empty row?

后端 未结 9 1894
情书的邮戳
情书的邮戳 2020-12-23 10:18

How I can determine empty rows in .xls documents using Apache POI?

9条回答
  •  星月不相逢
    2020-12-23 10:32

    You have to iterate through all cells in the row and check if they are all empty. I don't know any other solution...

     short c;
     for (c = lastRow.getFirstCellNum(); c <= lastRow.getLastCellNum(); c++) {
         cell = lastRow.getCell(c);
         if (cell != null && lastRow.getCell(c).getCellType() != HSSFCell.CELL_TYPE_BLANK) {
              nonBlankRowFound = true;
         }
     }
    

    The code is from here

提交回复
热议问题