gpt4 book ai didi

java.lang.ClassNotFoundException : org. apache.poi.poifs.crypt.agile.AgileEncryptionInfoBuilder

转载 作者:行者123 更新时间:2023-11-30 11:11:51 25 4
gpt4 key购买 nike

我正在使用 Apache Poi.3.10-FINAL jar 生成 Excel 工作表。我尝试使用下面的代码进行密码保护。我收到这样的错误。

Exception in thread "main" org.apache.poi.EncryptedDocumentException: java.lang.ClassNotFoundException: org.apache.poi.poifs.crypt.agile.AgileEncryptionInfoBuilder
at org.apache.poi.poifs.crypt.EncryptionInfo.<init>(EncryptionInfo.java:135)
at org.apache.poi.poifs.crypt.EncryptionInfo.<init>(EncryptionInfo.java:91)
at org.apache.poi.poifs.crypt.EncryptionInfo.<init>(EncryptionInfo.java:80)
at com.tcs.ServiceCatalog.Common.main(Common.java:63)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.poifs.crypt.agile.AgileEncryptionInfoBuilder
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.poi.poifs.crypt.EncryptionInfo.getBuilder(EncryptionInfo.java:150)
at org.apache.poi.poifs.crypt.EncryptionInfo.<init>(EncryptionInfo.java:133)
... 3 more

代码:取自 link.

POIFSFileSystem fs = new POIFSFileSystem();
EncryptionInfo info = new EncryptionInfo(fs, EncryptionMode.agile);

Encryptor enc = info.getEncryptor();
enc.confirmPassword("s3cr3t");

OPCPackage opc = OPCPackage.open(new File("c:/test/excel.xlsx"), PackageAccess.READ_WRITE);
OutputStream os = enc.getDataStream(fs);
opc.save(os);
opc.close();

FileOutputStream fos = new FileOutputStream("c:/test/excel.xlsx");
fs.writeFilesystem(fos);
fos.close();

我尝试搜索缺少的类 org.apache.poi.poifs.crypt.agile.AgileEncryptionInfoBuilder 但找不到。

感谢任何帮助。提前致谢。

最佳答案

您还需要 poi-ooxml-3.10.FINAL。下载并将其添加到您的类路径中。

关于java.lang.ClassNotFoundException : org. apache.poi.poifs.crypt.agile.AgileEncryptionInfoBuilder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27183699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com