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 2008/05/11 12:37:50 UTC

DO NOT REPLY [Bug 44967] New: Exception when reading SharedFormulaRecord

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

           Summary: Exception when reading SharedFormulaRecord
           Product: POI
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: yegor@dinom.ru


I was going to research bug #44010 and found that POI can't anymore read the
problem 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:208)
        at
org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:126)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:245)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:168)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:297)
        at
org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:278)
        at org.apache.poi.hssf.scratchpad.ReWrite.main(ReWrite.java:42)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
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:494)
        at
org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:196)
        ... 11 more
Caused by: java.lang.IllegalArgumentException: Unexpected operand type code '?'
(65533)
        at
org.apache.poi.hssf.record.formula.function.FunctionMetadataReader.parseOperandTypeCode(FunctionMetadataReader.java:162)
        at
org.apache.poi.hssf.record.formula.function.FunctionMetadataReader.parseOperandTypeCodes(FunctionMetadataReader.java:138)
        at
org.apache.poi.hssf.record.formula.function.FunctionMetadataReader.processLine(FunctionMetadataReader.java:103)
        at
org.apache.poi.hssf.record.formula.function.FunctionMetadataReader.createRegistry(FunctionMetadataReader.java:82)
        at
org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry.getInstance(FunctionMetadataRegistry.java:41)
        at
org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry.getFunctionByIndex(FunctionMetadataRegistry.java:57)
        at org.apache.poi.hssf.record.formula.FuncPtg.<init>(FuncPtg.java:42)
        at org.apache.poi.hssf.record.formula.Ptg.createPtg(Ptg.java:250)
        at
org.apache.poi.hssf.record.SharedFormulaRecord.getParsedExpressionTokens(SharedFormulaRecord.java:168)
        at
org.apache.poi.hssf.record.SharedFormulaRecord.fillFields(SharedFormulaRecord.java:160)
        at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
        at
org.apache.poi.hssf.record.SharedFormulaRecord.<init>(SharedFormulaRecord.java:56)


There are 3 SharedFormula records and all of them fail. I extracted the record
data and attached a failing unit test.

Josh, can you look into it? It might be related to your recent changes. 


Yegor


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44967] Exception when reading SharedFormulaRecord

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44967





--- Comment #2 from Yegor Kozlov <ye...@dinom.ru>  2008-05-11 03:39:26 PST ---
Created an attachment (id=21943)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21943)
sample xls to reproduce the problem


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44967] Problem with unicode characters in functionMetatada.txt

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44967


Josh Micich <jo...@gildedtree.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
            Summary|Exception when reading      |Problem with unicode
                   |SharedFormulaRecord         |characters in
                   |                            |functionMetatada.txt




--- Comment #3 from Josh Micich <jo...@gildedtree.com>  2008-05-11 11:45:48 PST ---
These problems started with the second fix to bug 44675 (svn r652994), when
FunctionMetadataReader began to read more of the columns from
functionMetadata.txt.

Originally, that file had non-ascii characters in it (ndash and ellipsis) which
I thought I had handled correctly.  Nick found a bug almost identical to this
(on linux), and applied a fix (svn r653831).  However, the fix didn't work for
me (on win32).  At this point, I thought the best solution was to totally
eliminate all non-ascii characters from functionMetadata.txt, and that's what I
did in svn r653892.

I can see from your stack trace that you have the latest
FunctionMetadataReader.  However, I don't understand why character 0xFFFD is
being read from functionMetadata.txt.  From what I can tell, there are only
ascii characters in functionMetadata.txt as of r653892.  I just ran the
following code in my workspace:

InputStream is =
FunctionMetadataRegistry.class.getResourceAsStream("functionMetadata.txt");
while (true) {
        int ic = is.read();
        if(ic ==-1) {
                break;
        }
        if(ic<'!' || ic > 'z') {
                switch (ic) {
                        case '\n': case '\r': case '\t': case ' ':
                                continue;
                }
                System.out.println("Unexpected char (" + ic + "):" + (char)ic);
        }
}
is.close();

In my workspace there are no unexpected chars.  Maybe you could run try the
same to help diagnose the problem.


BTW - This bug is not specific to shared formulas.  Reading any xls that
involves a formula will hit FunctionMetadataRegistry.getInstance().  Almost 100
junits were broken by this bug. The most direct test case to hit this bug is in
TestFunctionMetadataRegistry.


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44967] Problem with unicode characters in functionMetatada.txt

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44967


Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|                            |FIXED




--- Comment #4 from Yegor Kozlov <ye...@dinom.ru>  2008-05-12 01:53:33 PST ---
I found what's wrong.
Somehow my IDE (IntelliJ Idea 4.0) didn't update the resources after
compilation. As a result, an old version of functionMetadata.txt was used and
generated errors.

Sorry for the trouble. 

Yegor


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 44967] Exception when reading SharedFormulaRecord

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=44967





--- Comment #1 from Yegor Kozlov <ye...@dinom.ru>  2008-05-11 03:38:52 PST ---
Created an attachment (id=21942)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=21942)
failing test


-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org