mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
添加StopReadException,定义sax读取时用户可手动终止(issue#3820@Github)
This commit is contained in:
@@ -8,6 +8,7 @@ import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.poi.excel.cell.FormulaCellValue;
|
||||
import cn.hutool.poi.excel.sax.Excel03SaxReader;
|
||||
import cn.hutool.poi.excel.sax.StopReadException;
|
||||
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||
import cn.hutool.poi.exceptions.POIException;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
@@ -33,6 +34,24 @@ public class ExcelSaxReadTest {
|
||||
ExcelUtil.readBySax("aaa.xlsx", 0, createRowHandler());
|
||||
}
|
||||
|
||||
@Test
|
||||
void readEndByExceptionTest(){
|
||||
ExcelUtil.readBySax("aaa.xlsx", 0, (sheetIndex, rowIndex, rowList) -> {
|
||||
if (rowIndex == 1) {
|
||||
throw new StopReadException();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void readEndByException03Test(){
|
||||
ExcelUtil.readBySax("aaa.xls", 0, (sheetIndex, rowIndex, rowList) -> {
|
||||
if (rowIndex == 1) {
|
||||
throw new StopReadException();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excel07ByNameTest() {
|
||||
// 工具化快速读取
|
||||
|
Reference in New Issue
Block a user