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. http://www.docx4java.org/forums/docx-java-f6/using-ctdocprotect-to-protect-a-word-file-t947.html?hilit=password&sid=2ced230863e1d4f59153790c09a7afe7&sid=2ced230863e1d4f59153790c09a7afe7#p3128) 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 http://schemas.microsoft.com/office/2006/encryption

* [MS-OFFCRYPTO] http://msdn.microsoft.com/en-us/library/cc313071.aspx

* http://offcrypto.codeplex.com/

* http://www.lyquidity.com/devblog/?p=35

By the way, POI can apparently read such a file:- http://poi.apache.org/encryption.html 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?

Regards,
hyl