On Wed, 18 Nov 2015, Ni Lei wrote:
I tried to read Excel files which are protected with password, but got the EncryptedDocumentException.

That's a sign that you need to have the password and to do the decryption!

Case 1: when reading .xlsx file:

Caused by: org.apache.poi.EncryptedDocumentException: The supplied spreadsheet 
seems to be an Encrypted .xlsx file. It must be decrypted before use by XSSF, 
it cannot be used by HSSF
   at 
org.apache.poi.hssf.usermodel.HSSFWorkbook.getWorkbookDirEntryName(HSSFWorkbook.java:252)
 ~[poi-3.11.jar:3.11]

This is entirely expected - you can't ask HSSFWorkbook (for reading XLS) files to process a password protected XLSX files for you! You need to decrypt it first, then give to XSSFWorkbook

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


You can also supply the password when opening a workbook with WorkbookFactory too


The poi version is 3.11, and the password is set in MS Excel 2013, Windows 7.

Upgrade!

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to