diff --git a/src/main/java/com/alibaba/excel/context/WriteContextImpl.java b/src/main/java/com/alibaba/excel/context/WriteContextImpl.java index f136ea0..6e691fd 100644 --- a/src/main/java/com/alibaba/excel/context/WriteContextImpl.java +++ b/src/main/java/com/alibaba/excel/context/WriteContextImpl.java @@ -429,7 +429,9 @@ public class WriteContextImpl implements WriteContext { OutputStream outputStream = encryptor.getDataStream(fileSystem); opcPackage.save(outputStream); } finally { - opcPackage.close(); + if (opcPackage != null) { + opcPackage.close(); + } } return fileSystem; }