sheet.getRow(rowIndex);为null_POI导出excel

第一次使用POI,出现这个问题,看到有其他猿也遇到过,不知道怎么处理,所以记录一下~

sheet.getRow(rowIndex);通过sheet获取指定行,rowIndex代表第几行

用rowIndex行,需要判断该row是否为null,为null就是该row不存在,需要创建该行才能使用。

Row row = sheet.getRow(rowIndex);
if (row == null) {
  row = sheet.createRow(rowIndex);
}


猜你喜欢

转载自www.cnblogs.com/sunchunmei/p/12085135.html