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


Josh Micich <[EMAIL PROTECTED]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Formula written incorrectly |Token Class Transformation
                   |produces #VALUE error       |incorrect when function
                   |                            |expects 'reference' but arg
                   |                            |is 'value'




--- Comment #2 from Josh Micich <[EMAIL PROTECTED]>  2008-05-22 10:25:02 PST ---
Initial investigation shows that Excel encodes (when it re-parses) the formula
different to POI.  At first I thought the problem might have been the missing
tAttrVolatile token, but that seems to make no difference.  The critical
problem is the difference in the operand class of two of the function tokens.  
Excel augments to them to 'array'.  I am speculating that the rule being
followed here is that when the function parameter is 'reference' and the actual
argument is 'value' that it should get changed to 'array'.  However, I can't
see that explicity mentioned in the ooo document.  

// The formula parse tokens 
AttrPtg [volatile ]  (POI does not encode this token)
IntPtg [1]
AreaPtg [A:A]
AreaPtg [A:A]
FuncVarPtg [MIN nArgs=1]
StringPtg [:]
ConcatPtg
AreaPtg [A:A]
FuncVarPtg [MAX nArgs=1]
ConcatPtg
FuncVarPtg [INDIRECT nArgs=1]
FuncVarPtg [ROW nArgs=1]   >>> ptgClass = V should be A
AreaPtg [B:B]
FuncVarPtg [SUMIF nArgs=3] >>> ptgClass = V should be A
IntPtg [0]
FuncVarPtg [IRR nArgs=2]  
class AddPtg

// Function metadata
#Columns: (index, name, minParams, maxParams, returnClass, paramClasses)
148     INDIRECT        1       2       R       V V
8       ROW     0       1       V       R
345     SUMIF   2       3       V       R V R
62      IRR     1       2       V       R 


In this current example  SUMIF()'s return class is 'value' but IRR() expects
'reference' for the first parameter.  I guess this somehow necessitates the
transformation of the SUMIF() token to 'array'.  From there, perhaps 'forced
array' state causes SUMIF()'s second arg to be transformed to 'array' too.

A simpler example "COLUMNS(PI())" also gets encoded by Excel with
transformation to 'array' operand class.  Excel tolerates POI's incorrect
encoding in this case, so the mistake is not as clearly visible.

The fix for this is going to be in FormulaParser.setParameterRVA().


-- 
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