From 405e79366db1ff629e5213c729b9540a1e5757d1 Mon Sep 17 00:00:00 2001 From: SometimesNaive Date: Thu, 3 Jun 2021 17:08:34 +0800 Subject: [PATCH] fix issue 1967 --- .../alibaba/excel/write/executor/ExcelWriteFillExecutor.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java b/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java index 5930a311..cab79750 100644 --- a/src/main/java/com/alibaba/excel/write/executor/ExcelWriteFillExecutor.java +++ b/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.Set; +import com.alibaba.excel.exception.ExcelCommonException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellType; @@ -368,6 +369,9 @@ public class ExcelWriteFillExecutor extends AbstractExcelWriteExecutor { return analysisCellList; } Sheet sheet = writeContext.writeSheetHolder().getCachedSheet(); + if (sheet.getLastRowNum() == 0) { + throw new ExcelCommonException(sheet.getSheetName() + " not exists in the excel to be written"); + } Map> firstRowCache = new HashMap>(8); for (int i = 0; i <= sheet.getLastRowNum(); i++) { Row row = sheet.getRow(i);