You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ni Lei <ni...@worksap.co.jp> on 2015/11/18 08:20:09 UTC

Will poi library support reading encrypted excel file?

Hi,

I tried to read Excel files which are protected with password, but got the EncryptedDocumentException.

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]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:308) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:288) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:223) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:381) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:363) ~[poi-3.11.jar:3.11]
    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:84) ~[poi-ooxml-3.11.jar:3.11]

Case 2: when reading .xls file:

Caused by: org.apache.poi.EncryptedDocumentException: HSSF does not currently support CryptoAPI encryption
    at org.apache.poi.hssf.record.FilePassRecord$Rc4KeyData.read(FilePassRecord.java:65) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.record.FilePassRecord.<init>(FilePassRecord.java:193) ~[poi-3.11.jar:3.11]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_20]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_20]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_20]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:408) ~[na:1.8.0_20]
    at org.apache.poi.hssf.record.RecordFactory$ReflectionConstructorRecordCreator.create(RecordFactory.java:87) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.record.RecordFactory.createSingleRecord(RecordFactory.java:338) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.record.RecordFactoryInputStream$StreamEncryptionInfo.<init>(RecordFactoryInputStream.java:74) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.record.RecordFactoryInputStream.<init>(RecordFactoryInputStream.java:207) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:477) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:325) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:288) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:223) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:381) ~[poi-3.11.jar:3.11]
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:363) ~[poi-3.11.jar:3.11]
    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:84) ~[poi-ooxml-3.11.jar:3.11]

>From the exception message and the webpage (http://poi.apache.org/encryption.html), poi doesn't support RC4 CryptoAPI encryption.

Do you have any plans to support it? Or do you have any ideas on how to read such excel files?

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

Lei

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Will poi library support reading encrypted excel file?

Posted by kiwiwings <ki...@apache.org>.
Nick Burch-2 wrote
>> The poi version is 3.11, and the password is set in MS Excel 2013, 
>> Windows 7.
> 
> Upgrade!

If you upgrade, use 3.13-beta1 or higher because of #58133 [1]

Andi

[1] https://bz.apache.org/bugzilla/show_bug.cgi?id=58133



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Will-poi-library-support-reading-encrypted-excel-file-tp5720988p5720991.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Will poi library support reading encrypted excel file?

Posted by Nick Burch <ap...@gagravarr.org>.
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: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org