700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > java设置excel为只读_关于POI将excel加密(不能只读)

java设置excel为只读_关于POI将excel加密(不能只读)

时间:2019-07-20 09:18:43

相关推荐

java设置excel为只读_关于POI将excel加密(不能只读)

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)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。