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