mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-04 04:37:59 +08:00
fix excel sax bug
This commit is contained in:
parent
aeb9c723c5
commit
b1b8a29a3c
@ -30,6 +30,7 @@
|
|||||||
### 🐞Bug修复
|
### 🐞Bug修复
|
||||||
* 【core 】 修复MapUtil.sort比较器不一致返回原map的问题(issue#I46AQJ@Gitee)
|
* 【core 】 修复MapUtil.sort比较器不一致返回原map的问题(issue#I46AQJ@Gitee)
|
||||||
* 【core 】 修复JSONSupport默认循环引用导致的问题(issue#1779@Github)
|
* 【core 】 修复JSONSupport默认循环引用导致的问题(issue#1779@Github)
|
||||||
|
* 【poi 】 修复ExcelUtil.readBySax资源没有释放问题(issue#1789@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ public class Excel03SaxReader implements HSSFListener, ExcelSaxReader<Excel03Sax
|
|||||||
// ------------------------------------------------------------------------------ Read start
|
// ------------------------------------------------------------------------------ Read start
|
||||||
@Override
|
@Override
|
||||||
public Excel03SaxReader read(File file, String idOrRidOrSheetName) throws POIException {
|
public Excel03SaxReader read(File file, String idOrRidOrSheetName) throws POIException {
|
||||||
try {
|
try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(file, true)) {
|
||||||
return read(new POIFSFileSystem(file), idOrRidOrSheetName);
|
return read(poifsFileSystem, idOrRidOrSheetName);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new POIException(e);
|
throw new POIException(e);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import cn.hutool.poi.exceptions.POIException;
|
|||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||||
|
import org.apache.poi.openxml4j.opc.PackageAccess;
|
||||||
import org.apache.poi.xssf.eventusermodel.XSSFReader;
|
import org.apache.poi.xssf.eventusermodel.XSSFReader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -55,9 +56,9 @@ public class Excel07SaxReader implements ExcelSaxReader<Excel07SaxReader> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Excel07SaxReader read(File file, String idOrRidOrSheetName) throws POIException {
|
public Excel07SaxReader read(File file, String idOrRidOrSheetName) throws POIException {
|
||||||
try {
|
try (OPCPackage open = OPCPackage.open(file, PackageAccess.READ);){
|
||||||
return read(OPCPackage.open(file), idOrRidOrSheetName);
|
return read(open, idOrRidOrSheetName);
|
||||||
} catch (InvalidFormatException e) {
|
} catch (InvalidFormatException | IOException e) {
|
||||||
throw new POIException(e);
|
throw new POIException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user