java - 无法通过使用带有 Aspose 工作簿的 java 在 ADO(s3 存储桶)中提供密码来取消保护 xlsx、xls 文件
问题描述
我在使用 java 的 ADO 中没有收到任何错误或异常。我在 java 中使用过 Aspose 库。请在下面找到代码。它没有抛出任何错误或异常。我试过很多。我没有得到任何解决方案。这是我第一次在 ADO 环境下工作。
public void removePassword(){
log.info("****** Entered into removePassword()*** ");
try{
LoadOptions loadOptions = new LoadOptions(LoadFormat.XLSX);
loadOptions.setPassword("XXXX");
if ("true".equalsIgnoreCase(isAWS)) {
File file = awss3Service.loadFileFromS3(rsmAccessEntity.getIfluxawss3bucket(),"dev/sample/upload/22-01-2021/ABCP/" ,"Check_1.xlsx");
log.info("****** file length*** "+file.length());
com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(new FileInputStream(file),loadOptions);
workbook.save("Check_1.xlsx", FileFormatType.XLSX);
File file1 = new File("Check_1.xlsx");
log.info("****** file1 *** "+file1.length());
boolean isXlsxProtect = ProtectedFilesUtility.isXlsxProtected(new FileInputStream(file1));
log.info("****** isXlsxProtect *** "+isXlsxProtect);
awss3Service.uploadFile(new FileInputStream(file1),"dev/sample/upload/22-01-2021/ABCP/","Check_1.xlsx");
}
}catch(Exception e){
log.info("****** exception *** "+e);
}
}
解决方案
我尝试了上面的方法它不起作用,仍然文件有受保护的文件。我没有得到任何异常或错误。请找到我的一段代码..
public void removePassword(){
log.info("****** Entered into removePassword()*** ");
try{
LoadOptions loadOptions = new LoadOptions(LoadFormat.XLSX);
loadOptions.setPassword("XXXX");
if ("true".equalsIgnoreCase(isAWS)) {
File file = awss3Service.loadFileFromS3(rsmAccessEntity.getIfluxawss3bucket(),"dev/sample/upload/22-01-2021/ABCP/" ,"Check_1.xlsx");
log.info("****** file length*** "+file.length());
com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook(new FileInputStream(file),loadOptions);
workbook.getSettings().setPassword("XXXX");
workbook.save("Check_1.xlsx", FileFormatType.XLSX);
File file1 = new File("Check_1.xlsx");
log.info("****** file1 *** "+file1.length());
boolean isXlsxProtect = ProtectedFilesUtility.isXlsxProtected(new FileInputStream(file1));
log.info("****** isXlsxProtect *** "+isXlsxProtect);
awss3Service.uploadFile(new FileInputStream(file1),"dev/sample/upload/22-01-2021/ABCP/","Check_1.xlsx");
}
}catch(Exception e){
log.info("****** exception *** "+e);
}
}
推荐阅读
- docker - 如何在 80 端口运行 Odoo 的 Docker 镜像
- c# - 尝试将对象编码为在与玩家碰撞时在不同区域生成
- java - 计算一个句子中重复单词的总数
- gspread - gspread 可以创建/操作图表吗?
- python - 关于在 Apache Beam for python 中过滤返回值和预期返回类型的问题
- python - 识别列表中没有匹配词的句子
- floating-point - MIPS:浮点数
- sql - Microsoft SQL Server - 获取最新的价值记录
- php - 返回 Json_Encode 内容并以 HTML 显示
- python - Python OpenCV Lane Detector“无法解压不可迭代的numpy.uint8对象”错误