Browse Source

fix issue 1967

developing
SometimesNaive 4 years ago
parent
commit
405e79366d
  1. 4
      src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java

4
src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java

@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.alibaba.excel.exception.ExcelCommonException;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellType;
@ -368,6 +369,9 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor {
return analysisCellList; return analysisCellList;
} }
Sheet sheet = writeContext.writeSheetHolder().getCachedSheet(); Sheet sheet = writeContext.writeSheetHolder().getCachedSheet();
if (sheet.getLastRowNum() == 0) {
throw new ExcelCommonException(sheet.getSheetName() + " not exists in the excel to be written");
}
Map<String, Set<Integer>> firstRowCache = new HashMap<String, Set<Integer>>(8); Map<String, Set<Integer>> firstRowCache = new HashMap<String, Set<Integer>>(8);
for (int i = 0; i <= sheet.getLastRowNum(); i++) { for (int i = 0; i <= sheet.getLastRowNum(); i++) {
Row row = sheet.getRow(i); Row row = sheet.getRow(i);

Loading…
Cancel
Save