mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-03 20:27:58 +08:00
fix readBySax stream bug
This commit is contained in:
parent
9867333f68
commit
8d1ab0173a
@ -14,6 +14,7 @@
|
|||||||
### Bug修复
|
### Bug修复
|
||||||
* 【cron 】 修复CronTimer可能死循环的问题(issue#1224@Github)
|
* 【cron 】 修复CronTimer可能死循环的问题(issue#1224@Github)
|
||||||
* 【core 】 修复Calculator.conversion单个数字越界问题(issue#1222@Github)
|
* 【core 】 修复Calculator.conversion单个数字越界问题(issue#1222@Github)
|
||||||
|
* 【poi 】 修复ExcelUtil.getSaxReader使用非MarkSupport流报错问题(issue#1225@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package cn.hutool.poi.excel;
|
|||||||
|
|
||||||
import cn.hutool.core.exceptions.DependencyException;
|
import cn.hutool.core.exceptions.DependencyException;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.ReUtil;
|
import cn.hutool.core.util.ReUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
@ -84,6 +85,7 @@ public class ExcelUtil {
|
|||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public static void readBySax(InputStream in, int rid, RowHandler rowHandler) {
|
public static void readBySax(InputStream in, int rid, RowHandler rowHandler) {
|
||||||
|
in = IoUtil.toMarkSupportStream(in);
|
||||||
final ExcelSaxReader<?> reader = ExcelSaxUtil.createSaxReader(ExcelFileUtil.isXlsx(in), rowHandler);
|
final ExcelSaxReader<?> reader = ExcelSaxUtil.createSaxReader(ExcelFileUtil.isXlsx(in), rowHandler);
|
||||||
reader.read(in, rid);
|
reader.read(in, rid);
|
||||||
}
|
}
|
||||||
@ -97,6 +99,7 @@ public class ExcelUtil {
|
|||||||
* @since 5.4.4
|
* @since 5.4.4
|
||||||
*/
|
*/
|
||||||
public static void readBySax(InputStream in, String idOrRid, RowHandler rowHandler) {
|
public static void readBySax(InputStream in, String idOrRid, RowHandler rowHandler) {
|
||||||
|
in = IoUtil.toMarkSupportStream(in);
|
||||||
final ExcelSaxReader<?> reader = ExcelSaxUtil.createSaxReader(ExcelFileUtil.isXlsx(in), rowHandler);
|
final ExcelSaxReader<?> reader = ExcelSaxUtil.createSaxReader(ExcelFileUtil.isXlsx(in), rowHandler);
|
||||||
reader.read(in, idOrRid);
|
reader.read(in, idOrRid);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package cn.hutool.poi.excel.test;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.hutool.core.lang.Console;
|
import cn.hutool.core.lang.Console;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.poi.excel.ExcelUtil;
|
import cn.hutool.poi.excel.ExcelUtil;
|
||||||
@ -31,6 +32,12 @@ public class ExcelSaxReadTest {
|
|||||||
ExcelUtil.readBySax("aaa.xlsx", 0, createRowHandler());
|
ExcelUtil.readBySax("aaa.xlsx", 0, createRowHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void excel07FromStreamTest() {
|
||||||
|
// issue#1225 非markSupport的流读取会错误
|
||||||
|
ExcelUtil.readBySax(IoUtil.toStream(FileUtil.file("aaa.xlsx")), 0, createRowHandler());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void excel03Test() {
|
public void excel03Test() {
|
||||||
Excel03SaxReader reader = new Excel03SaxReader(createRowHandler());
|
Excel03SaxReader reader = new Excel03SaxReader(createRowHandler());
|
||||||
|
Loading…
Reference in New Issue
Block a user