You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2007/06/01 16:17:37 UTC

DO NOT REPLY [Bug 42564] New: - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564

           Summary: org.apache.poi.hssf.record.RecordFormatException: Unable
                    to construct record instance
           Product: POI
           Version: 3.0
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: m.breier@prodata-systems.de


Hi there ...

recently I got the Exception printed below while reading an Excel file that has
been exported by MS Access to "Excel 97-2002 & 5.0/95 Workbook" format. 

DEBUG: type = 5; currentLength = 8; recordOffset = 8

org.apache.poi.hssf.record.RecordFormatException: Unable to construct record
instance
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:191)
	at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:115)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:205)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:153)
	... 50 more
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:274)
	at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:179)
	... 54 more
Caused by: java.lang.ArrayIndexOutOfBoundsException
	at
org.apache.poi.hssf.record.RecordInputStream.checkRecordPosition(RecordInputStream.java:132)
	at org.apache.poi.hssf.record.RecordInputStream.readInt(RecordInputStream.java:155)
	at org.apache.poi.hssf.record.BOFRecord.fillFields(BOFRecord.java:121)
	at org.apache.poi.hssf.record.Record.<init>(Record.java:56)
	at org.apache.poi.hssf.record.BOFRecord.<init>(BOFRecord.java:99)
	... 59 more

When the exported Excel file has been reopened and saved with Excel, everything
is ok. 

DEBUG: type = 5; currentLength = 16; recordOffset = 8; sid = 2057;
ContinueRecord.sid = 60
DEBUG: type = 16; currentLength = 16; recordOffset = 8; sid = 2057;
ContinueRecord.sid = 60


To get a clue why these exceptions occur I put some debug code into
BOFRecord.fillFields(RecordInputStream in) to produce the DEBUG output stated above:

...
protected void fillFields(RecordInputStream in)
{

    field_1_version  = in.readShort();
    field_2_type     = in.readShort();
    field_3_build    = in.readShort();
    field_4_year     = in.readShort();

    System.out.println("DEBUG: type = "+getType()+"; "+
    						  "currentLength = "+in.getLength()+"; "+
    						  "recordOffset = "+in.getRecordOffset()+"; "+
    						  "sid = "+in.getSid()+"; "+
    						  "ContinueRecord.sid = "+ContinueRecord.sid);

   	field_5_history  = in.readInt();
   	field_6_rversion = in.readInt();
}
...

Since I have not a clue what's up with this SID stuff, so what can I do to fix
this problem?

Regards
Marcus

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564





------- Additional Comments From benelux@email.plala.or.jp  2007-06-15 08:11 -------
Are there some 'named range' definitions?
If so, try removing the all name definitions and that workbook might be read. 
related bug maybe #41546. 

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564





------- Additional Comments From waiwong@ccnet-hk.com  2008-01-28 02:28 -------
Created an attachment (id=21435)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21435&action=view)
File with problem on opening

I am new to this list, but I have exactly the same problem.  I checked and
found Name Range in the file, but I have no way to prevent Access in generating
this.  Moreover, the Name Range is working fine if I open and save the file.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564


waiwong@ccnet-hk.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564


nick@torchbox.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME




------- Additional Comments From nick@torchbox.com  2008-02-10 13:54 -------
I've just tested svn trunk with the supplied problem file. I'm able to open the
file with HSSFWorkbook, serialise it to bytes, and open that again, all without
issue. (see src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java#test42564)

So, I believe this bug is fixed in 3.0.2, but it certainly appears to be fixed
in svn trunk. If you are still having problems, please re-open the bug, and
attach a file that doesn't work with svn trunk.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564


dave.webster@virginmedia.co.uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #21435|0                           |1
        is obsolete|                            |




------- Additional Comments From dave.webster@virginmedia.co.uk  2008-02-11 00:13 -------
Created an attachment (id=21503)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21503&action=view)
empty Excel spreadsheet which shows Exception when opening


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564


nick@torchbox.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |ASSIGNED




------- Additional Comments From nick@torchbox.com  2008-02-11 09:56 -------
OK, I can replicate the problem with the new file, and I've added a (disabled)
test to TestBugs

Microsoft are supposed to be releasing some new documentation on the file format
in a week or so, so I'll wait for that then see if it explains this new Grbit
with value 16

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564


dave.webster@virginmedia.co.uk changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |




------- Additional Comments From dave.webster@virginmedia.co.uk  2008-02-11 00:30 -------
Hello All, 

The problem:
I've just attached an 'empty' spreadsheet which throws an Exception when opening
(doesntwork.xls).

The stack trace is slightly different to the one originally posted here, but it
looks to be the same cause.

The Exception came from using versions: 3.0.2-FINAL-20080204 and the latest SVN
trunk build from Feb. 7th, 2008 (appologies, I am having SVN firewall probs.
here at work and can't get a later version at the moment).

Expected behaviour:
Well, that it opens and process correctly.

To replicate:
The test program I used to open the file was XLS2CSVmra.java found under:
/src/scratchpad/examples/src/org/apache/poi/hssf/eventusermodel/examples

I compiled and ran it under JDK 1.4.2.

Notes:
The Excel file was originally created by a client.  I removed : all data, all
named ranges, hidden worksheets, extra worksheets and macros, to leave the empty
spreadsheet attached.

Appologies if this bug has been resolved in a POI version post Feb. 7th; I won't
have subversion access to test the trunk until mid-week.

Many thanks as always! 

Dave

Stack trace:
[:/cygdrive/c/work/ExcelParser/42564/513] > javac XLS2CSVmra.java 
[:/cygdrive/c/work/ExcelParser/42564/514] > java -version
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)
[:/cygdrive/c/work/ExcelParser/42564/515] > java XLS2CSVmra ../doesntwork.xls 
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.eventusermodel.HSSFEventFactory.genericProcessEvents(HSSFEventFactory.java:172)
        at
org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processEvents(HSSFEventFactory.java:98)
        at
org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processWorkbookEvents(HSSFEventFactory.java:63)
        at XLS2CSVmra.process(XLS2CSVmra.java:111)
        at XLS2CSVmra.main(XLS2CSVmra.java:324)
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:274)
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:187)
        ... 5 more
Caused by: org.apache.poi.hssf.record.RecordFormatException: Unknown grbit '16'
        at
org.apache.poi.hssf.record.formula.ArrayPtg.readTokenValues(ArrayPtg.java:99)
        at
org.apache.poi.hssf.record.formula.Ptg.createParsedExpressionTokens(Ptg.java:110)
        at org.apache.poi.hssf.record.NameRecord.fillFields(NameRecord.java:778)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
        at org.apache.poi.hssf.record.NameRecord.<init>(NameRecord.java:139)
        ... 10 more
Exception in thread "main"  




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


DO NOT REPLY [Bug 42564] - org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42564


nick@torchbox.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO




------- Additional Comments From nick@torchbox.com  2008-01-09 05:43 -------
Could you please upload a problem file? That way we'll have something to test
against

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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