java开发,需要实现一个功能:将excel进行加密。然后碰到问题。
public static void main(String[] args) throws IOException, InvalidFormatException, GeneralSecurityException {
POIFSFileSystem fs = new POIFSFileSystem();
EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile);
Encryptor enc = info.getEncryptor();
enc.confirmPassword("12346");
OPCPackage opc = OPCPackage.open(new File("D:/file/1031/excel.xlsx"), PackageAccess.READ_WRITE);
OutputStream os = enc.getDataStream(fs);
opc.save(os);
opc.close();
FileOutputStream fos = new FileOutputStream("D:/file/1031/excel.xlsx");
fs.writeFilesystem(fos);
fos.close();
System.out.println("File created!!");
}
这个是我写的方法。
报错:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.poifs.crypt.EncryptionInfo.(Lorg/apache/poi/poifs/crypt/EncryptionMode;)V
at com.hengtiansoft.xinyunlian.apply.service.Test.main(Test.java:56)