mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
修复多个sheet页时,doAfterAllAnalysed调用次数问题。
This commit is contained in:
parent
616d3af128
commit
7c0a8a4571
@ -6,6 +6,7 @@ import cn.hutool.core.lang.Assert;
|
|||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.log.StaticLog;
|
||||||
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||||
import cn.hutool.poi.exceptions.POIException;
|
import cn.hutool.poi.exceptions.POIException;
|
||||||
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
|
import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
|
||||||
@ -349,11 +350,8 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader<Excel03Sax
|
|||||||
* @param lastCell 行结束的标识Record
|
* @param lastCell 行结束的标识Record
|
||||||
*/
|
*/
|
||||||
private void processLastCell(LastCellOfRowDummyRecord lastCell) {
|
private void processLastCell(LastCellOfRowDummyRecord lastCell) {
|
||||||
// if(CollUtil.isNotBlank(this.rowCellList)) {
|
// 每行结束时, 调用handle() 方法
|
||||||
//整行内容全为空时,表示该行是空白行,不执行每行结束的handle.
|
this.rowHandler.handle(curRid, lastCell.getRow(), this.rowCellList);
|
||||||
// 每行结束时, 调用handle() 方法
|
|
||||||
this.rowHandler.handle(curRid, lastCell.getRow(), this.rowCellList);
|
|
||||||
// }
|
|
||||||
// 清空行Cache
|
// 清空行Cache
|
||||||
this.rowCellList = new ArrayList<>(this.rowCellList.size());
|
this.rowCellList = new ArrayList<>(this.rowCellList.size());
|
||||||
}
|
}
|
||||||
@ -362,7 +360,6 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader<Excel03Sax
|
|||||||
* 处理sheet结束后的操作
|
* 处理sheet结束后的操作
|
||||||
*/
|
*/
|
||||||
private void processLastCellSheet(){
|
private void processLastCellSheet(){
|
||||||
System.out.println("processLastCellSheet:rid="+rid+", curId="+curRid+",sheetName="+sheetName);
|
|
||||||
this.rowHandler.doAfterAllAnalysed();
|
this.rowHandler.doAfterAllAnalysed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,21 +73,18 @@ public class ExcelUtilTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readBySaxTest() {
|
public void doAfterAllAnalysedTest() {
|
||||||
String path = "readBySax.xls";
|
String path = "readBySax.xls";
|
||||||
AtomicInteger assertRowNum = new AtomicInteger(0);
|
|
||||||
try{
|
try{
|
||||||
ExcelUtil.readBySax(path, 0, new RowHandler() {
|
ExcelUtil.readBySax(path, -1, new RowHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(int sheetIndex, long rowIndex, List<Object> rowCells) {
|
public void handle(int sheetIndex, long rowIndex, List<Object> rowCells) {
|
||||||
System.out.println(StrUtil.format("sheetIndex={};rowIndex={},rowCells={}",sheetIndex,rowIndex,rowCells));
|
System.out.println(StrUtil.format("sheetIndex={};rowIndex={},rowCells={}",sheetIndex,rowIndex,rowCells));
|
||||||
assertRowNum.addAndGet(1);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
//Assert.assertEquals(3, assertRowNum.intValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user