From c2b8d2333c28ccb68631d7b29a7f94cfd31dbd02 Mon Sep 17 00:00:00 2001 From: Hccake Date: Fri, 11 Jun 2021 00:47:44 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20fix=20=E5=BD=93=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E5=AF=BC=E5=87=BA=E6=97=B6=EF=BC=8C=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=E8=BE=93=E5=87=BA=E6=B5=81=E6=9C=AA=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E6=96=87=E4=BB=B6=E6=8D=9F=E5=9D=8F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/alibaba/excel/context/WriteContextImpl.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/alibaba/excel/context/WriteContextImpl.java b/src/main/java/com/alibaba/excel/context/WriteContextImpl.java index c1f89f02..5b4efb18 100644 --- a/src/main/java/com/alibaba/excel/context/WriteContextImpl.java +++ b/src/main/java/com/alibaba/excel/context/WriteContextImpl.java @@ -488,14 +488,18 @@ public class WriteContextImpl implements WriteContext { Encryptor encryptor = new EncryptionInfo(EncryptionMode.standard).getEncryptor(); encryptor.confirmPassword(writeWorkbookHolder.getPassword()); OPCPackage opcPackage = null; + OutputStream outputStream = null; try { opcPackage = OPCPackage.open(file, PackageAccess.READ_WRITE); - OutputStream outputStream = encryptor.getDataStream(fileSystem); + outputStream = encryptor.getDataStream(fileSystem); opcPackage.save(outputStream); } finally { if (opcPackage != null) { opcPackage.close(); } + if (outputStream != null) { + outputStream.close(); + } } return fileSystem; }