|
|
|
@ -483,6 +483,19 @@ public class WriteContextImpl implements WriteContext {
|
|
|
|
|
POIFSFileSystem fileSystem = new POIFSFileSystem(); |
|
|
|
|
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 = encryptor.getDataStream(fileSystem); |
|
|
|
|
opcPackage.save(outputStream); |
|
|
|
|
} finally { |
|
|
|
|
if (opcPackage != null) { |
|
|
|
|
opcPackage.close(); |
|
|
|
|
} |
|
|
|
|
if (outputStream != null) { |
|
|
|
|
outputStream.close(); |
|
|
|
|
} |
|
|
|
|
try (OPCPackage opcPackage = OPCPackage.open(file, PackageAccess.READ_WRITE); |
|
|
|
|
OutputStream outputStream = encryptor.getDataStream(fileSystem)) { |
|
|
|
|
opcPackage.save(outputStream); |
|
|
|
|