summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--calc.go11
-rw-r--r--calc_test.go1
2 files changed, 12 insertions, 0 deletions
diff --git a/calc.go b/calc.go
index ab205ce..c3b8bf9 100644
--- a/calc.go
+++ b/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
diff --git a/calc_test.go b/calc_test.go
index a804b58..3749702 100644
--- a/calc_test.go
+++ b/calc_test.go
@@ -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",