Page 1 of 1

password protection

PostPosted: Sat Jun 22, 2013 3:45 pm
by hyl
I am a beginner of docx4j and I need to protect a generated excel file(xlsx). I have read the article about password protection for docx (i.e. but I still have no idea on it. So, I'd appreciate some guidance.

Re: password protection

PostPosted: Sun Jun 23, 2013 10:46 am
by jason
There are various options for setting permissions in Excel (referred attached screenshot from 2010), including password protection of a single sheet or entire workbook.

If you choose "Encrypt with Password", you'll get an xlsx file which is not a normal zip file, but rather, an OLE compound file.

It'll include an EncryptionInfo stream, with root element encryption in namespace




By the way, POI can apparently read such a file:- but I don't know whether it can write one. In any case that code could be a useful place to start.

Re: password protection

PostPosted: Mon Jun 24, 2013 7:40 pm
by hyl
Hi Jason,

Thanks for your reply and your information.

I have already tried POI to encrypt excel files, but it seems only able to encrypt xls files instead of xlsx one.
Is there any feature in xlsx4j for implementing the password encryption/decryption of xlsx likes docx?