!919 修复“sax方式读取excel2003版本,会调用两次doAfterAllAnalysed方法”问题。

Merge pull request !919 from hellozrh/v5-dev
This commit is contained in:
Looly
2023-02-09 11:37:01 +00:00
committed by Gitee
6 changed files with 94 additions and 1 deletions

View File

@@ -1,9 +1,12 @@
package cn.hutool.poi.excel.sax;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.log.StaticLog;
import cn.hutool.poi.excel.sax.handler.RowHandler;
import cn.hutool.poi.exceptions.POIException;
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
@@ -216,7 +219,10 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader<Excel03Sax
if(this.rid < 0 && null != this.sheetName){
throw new POIException("Sheet [{}] not exist!", this.sheetName);
}
processLastCellSheet();
if(this.curRid != -1 && isProcessCurrentSheet()) {
//只有在当前指定的sheet中才触发结束事件且curId=-1时也不处理避免重复调用
processLastCellSheet();
}
} else if (isProcessCurrentSheet()) {
if (record instanceof MissingCellDummyRecord) {
// 空值的操作