forked from p30928647/excelize
This closes #1164, fix nested formula calculation result error
This commit is contained in:
parent
3971e8a48b
commit
129052ae7d
11
calc.go
11
calc.go
|
@ -809,6 +809,17 @@ func (f *File) evalInfixExp(sheet, cell string, tokens []efp.Token) (efp.Token,
|
|||
}
|
||||
}
|
||||
|
||||
if isEndParenthesesToken(token) && isBeginParenthesesToken(opftStack.Peek().(efp.Token)) {
|
||||
if arg := argsStack.Peek().(*list.List).Back(); arg != nil {
|
||||
opfdStack.Push(efp.Token{
|
||||
TType: efp.TokenTypeOperand,
|
||||
TSubType: efp.TokenSubTypeNumber,
|
||||
TValue: arg.Value.(formulaArg).Value(),
|
||||
})
|
||||
argsStack.Peek().(*list.List).Remove(arg)
|
||||
}
|
||||
}
|
||||
|
||||
// check current token is opft
|
||||
if err = f.parseToken(sheet, token, opfdStack, opftStack); err != nil {
|
||||
return efp.Token{}, err
|
||||
|
|
|
@ -725,6 +725,7 @@ func TestCalcCellValue(t *testing.T) {
|
|||
"=1+SUM(SUM(1,2*3),4)*-4/2+5+(4+2)*3": "2",
|
||||
"=1+SUM(SUM(1,2*3),4)*4/3+5+(4+2)*3": "38.666666666666664",
|
||||
"=SUM(1+ROW())": "2",
|
||||
"=SUM((SUM(2))+1)": "3",
|
||||
// SUMIF
|
||||
`=SUMIF(F1:F5, "")`: "0",
|
||||
`=SUMIF(A1:A5, "3")`: "3",
|
||||
|
|
Loading…
Reference in New Issue