Browse Source

Merge pull request #1968 from realhht/master

fix issue 1967
developing
Jiaju Zhuang 3 years ago committed by GitHub
parent
commit
3aa18351c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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