Removing a row from an Excel sheet with Apache POI HSSF

前端 未结 7 1071
小鲜肉
小鲜肉 2020-11-29 05:38

I\'m using the Apache POi HSSF library to import info into my application. The problem is that the files have some extra/empty rows that need to be removed first before pars

7条回答
  •  攒了一身酷
    2020-11-29 06:28

    Something along the lines of

    int newrownum=0;
    for (int i=0; i<=sheet.getLastRowNum(); i++) {
      HSSFRow row=sheet.getRow(i);
      if (row) row.setRowNum(newrownum++);
    }
    

    should do the trick.

提交回复
热议问题