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)
Click "Create a new attachment" after the initial bug submission
Created attachment 10729 [details] Here is the file that causes this error
Created attachment 10793 [details] A simple test java file that shows the error
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
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.
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?
Created attachment 11074 [details] possible workaround: jakarta-poi-1.10.0
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.
The same exception is being thrown when the Excel file has AutoFilter enabled.
Created attachment 11311 [details] sample excel file to generate this error: simple AutoFilter
You can simply generate it by creating an excel file with an autofilter dropdown box, see my attachment This worked with POI 1.11
*** Bug 39190 has been marked as a duplicate of this bug. ***
Original issue is due to encrypted workbook. HSSF does not currently support this (see FAQ). AutoFilter worksforme. Marking this WONTFIX Jason
(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
(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