错误“安装 JCE Unlimited Strength Jurisdiction Policy files" [英] Error "install JCE Unlimited Strength Jurisdiction Policy files"
问题描述
我在 Java 中为 Excel 使用 Apache POI 库.我需要用密码打开 xlsx 文件.为什么我有这个错误:线程主"org.apache.poi.EncryptedDocumentException:出口限制到位 - 请安装 JCE Unlimited Strength Jurisdiction Policy files".我尝试安装这些文件.但这并没有解决问题.
I use Apache POI library for Excel in java. I need open xlsx file with password. Why I have this error: "Exception in thread "main" org.apache.poi.EncryptedDocumentException: Export Restrictions in place - please install JCE Unlimited Strength Jurisdiction Policy files". I tryed install this files. But this didn't solve the problem.
public static void ReadFromExcell(String file) throws IOException, GeneralSecurityException {
String excelFilePath = "ServerList.xlsx";
try {
NPOIFSFileSystem fileSystem = new NPOIFSFileSystem(new File(excelFilePath));
EncryptionInfo info = new EncryptionInfo(fileSystem);
Decryptor decryptor = Decryptor.getInstance(info);
if (!decryptor.verifyPassword("qwerty")) {
System.out.println("Unable to process: document is encrypted.");
return;
}
InputStream dataStream = decryptor.getDataStream(fileSystem);
Workbook workbook = new XSSFWorkbook(dataStream);
Sheet firstSheet = workbook.getSheetAt(0);
Iterator<Row> iterator = firstSheet.iterator();
while (iterator.hasNext()) {
Row nextRow = iterator.next();
Iterator<Cell> cellIterator = nextRow.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
System.out.print(cell.getStringCellValue() + "\t");
}
System.out.println();
}
workbook.close();
dataStream.close();
fileSystem.close();
} catch (GeneralSecurityException | IOException ex) {
ex.printStackTrace();
}
}
推荐答案
我找到了问题的解决方案.我只替换了文件夹jre"中的文件.还要替换文件夹jdk"中的文件.
I found a solution to the problem. I replaced the files only in the folder "jre". It is also necessary to replace the files in the folder "jdk".
这篇关于错误“安装 JCE Unlimited Strength Jurisdiction Policy files"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!