Bug 27548 - getting InvocationTargetException while reading Password Protected Excel File
Summary: getting InvocationTargetException while reading Password Protected Excel File
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.0-FINAL
Hardware: All All
: P1 major with 12 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 39190 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-09 19:39 UTC by Lance Wentz
Modified: 2009-03-03 15:56 UTC (History)
2 users (show)



Attachments
Here is the file that causes this error (140.50 KB, application/octet-stream)
2004-03-09 19:44 UTC, Lance Wentz
Details
A simple test java file that shows the error (1.80 KB, text/plain)
2004-03-15 19:35 UTC, Lance Wentz
Details
possible workaround: jakarta-poi-1.10.0 (170 bytes, text/plain)
2004-03-31 15:22 UTC, Bodo Hirtsiefer
Details
sample excel file to generate this error: simple AutoFilter (16.00 KB, application/octet-stream)
2004-04-22 15:08 UTC, Tony Nys
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lance Wentz 2004-03-09 19:39:56 UTC
This bug happens on 1.5.1, 2.0 Final and version is 2.5 Final.

I don't see anyway to attach the excel file that fails.
I can e-mail the file, just give me the e-mail address.

stack trace:
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
        at org.apache.poi.hssf.record.RecordFactory.createRecord
(RecordFactory.java:224)
        at org.apache.poi.hssf.record.RecordFactory.createRecords
(RecordFactory.java:160)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:165)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:132)
...
Caused by: java.lang.IllegalArgumentException: Illegal length
        at org.apache.poi.util.StringUtil.getFromUnicodeHigh(StringUtil.java:76)
        at org.apache.poi.hssf.record.FontRecord.fillFields(FontRecord.java:135)
        at org.apache.poi.hssf.record.Record.fillFields(Record.java:90)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
        at org.apache.poi.hssf.record.FontRecord.<init>(FontRecord.java:88)
...
org.apache.poi.hssf.record.RecordFormatException: Unable to construct record 
instance, the following exception occured: null
        at org.apache.poi.hssf.record.RecordFactory.createRecord
(RecordFactory.java:237)
        at org.apache.poi.hssf.record.RecordFactory.createRecords
(RecordFactory.java:160)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:165)
        at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>
(HSSFWorkbook.java:132)
Comment 1 Danny Mui 2004-03-09 19:44:01 UTC
Click "Create a new attachment" after the initial bug submission
Comment 2 Lance Wentz 2004-03-09 19:44:38 UTC
Created attachment 10729 [details]
Here is the file that causes this error
Comment 3 Lance Wentz 2004-03-15 19:35:44 UTC
Created attachment 10793 [details]
A simple test java file that shows the error
Comment 4 Lance Wentz 2004-03-15 19:38:09 UTC
I attached a simple java file that ilistrates the error.

execute it something like this:
java -cp poi-2.5-final-20040302.jar;. xlstest 2004TimeSheet.xls
Comment 5 Michael Zalewski 2004-03-16 03:08:29 UTC
I believe this happens because the workbook is encrypted. If you run through 
BiffViewer, you can see that the WRITEPROTECT record is present, and the first 
records after WRITEPROTECT contain very strange data. The first record after 
the WRITEPROTECT that contains a String is the FONT record, but the font name 
cannot be read because the name and length are encrypted. POI does not support 
encryption and cannot read a workbook which is password protected.

Try removing the protection and see if the program works.
Comment 6 Lance Wentz 2004-03-16 17:32:04 UTC
We are using POI to read the text of an Excel file.  Then we use lucene for 
indexing, and searching our our website.

For business needs some files could be write protected.

Is there a better way to get the text our of the excell files.  Or is it 
posible to give a better exception such as FileProtectedException?
Comment 7 Bodo Hirtsiefer 2004-03-31 15:22:23 UTC
Created attachment 11074 [details]
possible workaround: jakarta-poi-1.10.0
Comment 8 Lance Wentz 2004-04-09 00:25:50 UTC
I've tracked this down a little bit more.

If I password protect a sheet, it works fine, I can read all the data.
But If I password protect the workbook, it fails.

It seems to me if you have code to read a paswword protected sheet, reading a 
password protected woorkbook shouldn't be much different.
Comment 9 Timo Neumann 2004-04-13 16:28:11 UTC
The same exception is being thrown when the Excel file has AutoFilter enabled.
Comment 10 Tony Nys 2004-04-22 15:08:45 UTC
Created attachment 11311 [details]
sample excel file to generate this error: simple AutoFilter
Comment 11 Tony Nys 2004-04-22 15:09:47 UTC
You can simply generate it by creating an excel file
with an autofilter dropdown box, see my attachment

This worked with POI 1.11
Comment 12 Jason Height 2006-08-27 11:55:12 UTC
*** Bug 39190 has been marked as a duplicate of this bug. ***
Comment 13 Jason Height 2006-08-27 12:00:36 UTC
Original issue is due to encrypted workbook. HSSF does not currently support
this (see FAQ).

AutoFilter worksforme.

Marking this WONTFIX

Jason
Comment 14 Josh Micich 2009-03-03 15:27:37 UTC
(In reply to comment #13)
> Original issue is due to encrypted workbook. HSSF does not currently support
> this (see FAQ).
POI was fixed to throw an explicit exception in svn r437370
Comment 15 Josh Micich 2009-03-03 15:56:48 UTC
(In reply to comment #14)
> POI was fixed to throw an explicit exception in svn r43737

Sorry about the typo (missing last digit).  The change is here: svn r437370