https://issues.apache.org/bugzilla/show_bug.cgi?id=44536

           Summary: Error reading a 'read only 'recommended' XLS file
           Product: POI
           Version: 3.0
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


This is for version 3.0.2 FINAL.

If you open an XLS file and save with the 'read only recommended' option set,
POI fails to read the file:

Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException:
Unable to construct record instance
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:199)
        at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:117)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:207)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:259)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:240)
        at rde.tests.poi.XLTest.main(XLTest.java:30)
Caused by: 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:513)
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:187)
        ... 5 more
Caused by: java.lang.IllegalArgumentException: Illegal length
        at
org.apache.poi.hssf.record.RecordInputStream.readCompressedUnicode(RecordInputStream.java:270)
        at
org.apache.poi.hssf.record.FileSharingRecord.fillFields(FileSharingRecord.java:62)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
        at
org.apache.poi.hssf.record.FileSharingRecord.<init>(FileSharingRecord.java:48)
        ... 10 more

The code to parse the FILESHARING record does not seem to take account of
changes from BIFF5 to BIFF8.  Here is an extract from the openoffice xls file
format document:

0 2 1 = Recommend read-only state while loading the file
2 2 Hash value calculated from the read-only password (➜4.18.4)
4 var. User name of the file creator
BIFF2-BIFF5: Byte string, 8-bit string length (➜2.5.2)
BIFF8: Unicode string, 16-bit string length (➜2.5.3)
170

A trivial XLS file is attached


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to