poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 50209] Evaluation of SUBTOTAL function seems to be incorrect
Date Mon, 25 Jul 2011 16:19:00 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=50209

Yegor Kozlov <yegor@dinom.ru> changed:

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

--- Comment #5 from Yegor Kozlov <yegor@dinom.ru> 2011-07-25 16:19:00 UTC ---

(In reply to comment #4)
> Created attachment 27118 [details]
> patch

Fixed in r1150673

The fix is based on the proposed patch, but I chose a bit different strategy.
Instead of pulling DoubleList and iteration logic from
MultiOperandNumericFunction and thus duplicating code, it is better to inject
this logic right into MultiOperandNumericFunction.collectValues.
I think I found an elegant way how to do that.

P.S. You patch assumes that the last ptg in nested cells is FuncVarPtg:


+    public int getFunctionIndex( EvaluationCell srcCell ){

+        Ptg[] ptgs = _workbook.getFormulaTokens(srcCell);

+        int index = -1;

+        if( ptgs.length > 0  &&  ptgs[ptgs.length-1] instanceof FuncVarPtg){

+            FuncVarPtg fVar = (FuncVarPtg)ptgs[ptgs.length-1];

+            index = fVar.getFunctionIndex();

+        }

+        return index;

+    }



It is not always so. Consider two use cases:

SUBTOTAL(9, A1:A2)      ptgs: [9, A1:A2, SUBTOTAL]
SUBTOTAL(9, A1:A2) + 1  ptgs: [9, A1:A2, SUBTOTAL, 1, '+']

Your implementation ignores the second case which is wrong. The correct logic
is to iterate over all ptgs and check if there is a FuncVarPtg for the SUBTOTAL
function.

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


Mime
View raw message