Bug 46796

Summary: I can not read excel password protected workbook files
Product: POI Reporter: David Jimenez Vasquez <inge_jimenezvasquez>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Excel files reading using POI

Description David Jimenez Vasquez 2009-03-03 13:01:01 UTC
I just need to read an excel password protected workbook file.
This excel file is password protected because no one can modify the structure of it. I just need to read the contents of the specified sheet, i understand that is not posible edit this excel file, but a person should be able to read the contents of one or some sheets of this workbook.
When we tried to open a excel file that is password protected (workbook and sheet) it throws a java.lang.reflect.InvocationTargetException, but when we tried to open a excel file that is password protected (only sheet) it reads succesfully.
I think that if we were to try to open an excel file that is password protected (workbook and sheet) it should read the contents succesfully, but only for reading the contents, not write it, i mean, without modifying the estructure of the workbook.
Comment 1 David Fisher 2009-03-03 13:12:52 UTC
When Excel tries to open your "Workbook" and "Sheet" protected file do you have to supply the password in order to view the contents?
Comment 2 David Jimenez Vasquez 2009-03-03 13:41:41 UTC
No, i don't have to supply any password.
I can view the contents without supplying the password.
This is the situation, i have a JAVA program that uses the library Apache POI HSSF to read and write excel files, when the program tries to read a password protected file (only sheet), it reads succesfully, but when the program tries to read a password protected file (workbook and sheet), it throws a java.lang.reflect.InvocationTargetException.
Comment 3 David Fisher 2009-03-03 13:53:49 UTC
What version of POI are you using? If not the latest 3.5beta5 would you mind seeing if that makes a difference.

Is it possible for you to attach a sample file that shows the trouble but does not contain any proprietary information?
Comment 4 David Jimenez Vasquez 2009-03-03 14:23:34 UTC
Created attachment 23326 [details]
Excel files reading using POI
Comment 5 David Jimenez Vasquez 2009-03-03 14:24:41 UTC
I am using the Apache POI 2.5.1
Comment 6 David Jimenez Vasquez 2009-03-03 15:02:36 UTC
I am going to try with Apache POI 3.2-FINAL and 3.5-beta5 to view the results.

Thanks in advance.
Comment 7 Josh Micich 2009-03-03 15:31:17 UTC
(In reply to comment #6)
> I am going to try with Apache POI 3.2-FINAL and 3.5-beta5 to view the results.
> 
> Thanks in advance.

The latest POI version is not going to work either.  This issue was first noticed in bug 27548 . The resolution at that point was to throw an explicit error when POI encountered an encrypted workbook.  No progress has been made beyond this.

It may take a lot of work to get POI to support encrypted workbooks
Comment 8 David Jimenez Vasquez 2009-03-05 20:21:44 UTC
As Josh Micich said, the latest POI version didn't work either. 
Despite of knowing it wouldn't work, i tried it anyway to view the results.
I tried with the POI 3.2-FINAL and 3.5-beta5, both threw the same exception, org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance.

I just have a reflexive question, no offense, but... Won't Apache POI have this feature? Will Apache POI always throw an exception whenever a JAVA program try to read the contents of a password protected workbook file?
Comment 9 Nick Burch 2009-03-16 10:05:16 UTC
(In reply to comment #8)
> I just have a reflexive question, no offense, but... Won't Apache POI have this
> feature?

The bulk of the office encryption stuff isn't standard, and isn't documented, so support it very unlikely to be forthcoming, unless someone volunteers to do a massive amount of reverse engineering
Comment 10 Maxim Valyanskiy 2009-08-06 03:18:07 UTC
https://issues.apache.org/bugzilla/show_bug.cgi?id=47652