[英]Password Protect XSSFWorkBook Apache POI
I need to password protect XSSFWorkBook.我需要密码保护 XSSFWorkBook。 For HSSF, I am able to do it easily but the same implementation is not working for XSSFWorkBook.对于 HSSF,我可以轻松完成,但相同的实现不适用于 XSSFWorkBook。
I am using Apache POI 3.6 and 3.9 both.我同时使用 Apache POI 3.6 和 3.9。 I mean I tried using both 3.6 and 3.9.我的意思是我尝试使用 3.6 和 3.9。
I guess I need to use POIFSFileSystem but can anyone guide me for the same.我想我需要使用 POIFSFileSystem 但任何人都可以指导我。
Password Protect is supported by latest version of poi.最新版本的 poi 支持密码保护。
Please see http://poi.apache.org/encryption.html请参阅http://poi.apache.org/encryption.html
Have tried the suggested method and it is working fine.已经尝试了建议的方法,它工作正常。
Base on Apache POI - Encryption support doc.基于Apache POI - 加密支持文档。
It is depend on file system, that mean MS-Office 2003
or MS-Office 2007
, etc..它取决于文件系统,即MS-Office 2003
或MS-Office 2007
等。
The following program work in MS-Office 2007
.以下程序在MS-Office 2007
。 Please, check the documentation请检查文档
POIFSFileSystem filesystem = --> get your filesystem
EncryptionInfo encInfo = new EncryptionInfo(filesystem);
Decryptor decryptor = new Decryptor(encInfo);
decryptor.verifyPassword("your-password");
XSSFWorkbook wb = new XSSFWorkbook(decryptor.getDataStream(filesystem))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.