Zip can be decompressed normally with password, and excel can be opened normally.
I want to double-click zip do not need a password, double-click excel in zip need a password, enter the password after the excel directly open. But now excel is not open after entering the password.
to be
I want to double-click zip do not need a password, double-click excel in zip need a password, enter the password after the excel directly open.
public static File compressWithPassword(InputStream inputStream, String fileNameInZip,
String password) throws IOException {
ZipParameters parameters = new ZipParameters();
parameters.setEncryptFiles(true);
parameters.setEncryptionMethod(EncryptionMethod.ZIP_STANDARD);
parameters.setFileNameInZip(fileNameInZip + XLSX_EXTENSION);
parameters.setCompressionMethod(CompressionMethod.DEFLATE);
parameters.setCompressionLevel(CompressionLevel.NORMAL);
parameters.setIncludeRootFolder(true);
File tmpZipedFile = new File(tempDir, fileNameInZip + ".zip");
if (tmpZipedFile.exists()) {
if (!tmpZipedFile.delete()) {
tmpZipedFile.deleteOnExit();
}
}
try (ZipFile zipFile = new ZipFile(tmpZipedFile)) {
zipFile.setPassword(password.toCharArray());
zipFile.addStream(inputStream, parameters);
}
return tmpZipedFile;
}
as is
Zip can be decompressed normally with password, and excel can be opened normally.
I want to double-click zip do not need a password, double-click excel in zip need a password, enter the password after the excel directly open. But now excel is not open after entering the password.
to be
I want to double-click zip do not need a password, double-click excel in zip need a password, enter the password after the excel directly open.