Question

I need to password protect XSSFWorkBook. For HSSF, I am able to do it easily but the same implementation is not working for XSSFWorkBook.

I am using Apache POI 3.6 and 3.9 both. I mean I tried using both 3.6 and 3.9.

I guess I need to use POIFSFileSystem but can anyone guide me for the same.

No correct solution

OTHER TIPS

Password Protect is supported by latest version of poi.

Please see http://poi.apache.org/encryption.html

Have tried the suggested method and it is working fine.

Base on Apache POI - Encryption support doc.

It is depend on file system, that mean MS-Office 2003 or MS-Office 2007, etc..

The following program work in 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))

Using Apache POI we can read the password protected files, but their is no option to create the password protected files.

So try some other commercial library like Aspose.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top