jaby 4 years ago committed by GitHub
parent 2c90b3f535
commit bafe087a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -628,16 +628,10 @@ func (f *File) evalInfixExp(sheet, cell string, tokens []efp.Token) (efp.Token,
} }
// current token is logical // current token is logical
if token.TType == efp.OperatorsInfix && token.TSubType == efp.TokenSubTypeLogical {
}
if token.TType == efp.TokenTypeOperand && token.TSubType == efp.TokenSubTypeLogical { if token.TType == efp.TokenTypeOperand && token.TSubType == efp.TokenSubTypeLogical {
argsStack.Peek().(*list.List).PushBack(newStringFormulaArg(token.TValue)) argsStack.Peek().(*list.List).PushBack(newStringFormulaArg(token.TValue))
} }
// current token is text
if token.TType == efp.TokenTypeOperand && token.TSubType == efp.TokenSubTypeText {
argsStack.Peek().(*list.List).PushBack(newStringFormulaArg(token.TValue))
}
if err = f.evalInfixExpFunc(sheet, cell, token, nextToken, opfStack, opdStack, opftStack, opfdStack, argsStack); err != nil { if err = f.evalInfixExpFunc(sheet, cell, token, nextToken, opfStack, opdStack, opftStack, opfdStack, argsStack); err != nil {
return efp.Token{}, err return efp.Token{}, err
} }
@ -1012,7 +1006,7 @@ func (f *File) parseToken(sheet string, token efp.Token, opdStack, optStack *Sta
optStack.Pop() optStack.Pop()
} }
// opd // opd
if token.TType == efp.TokenTypeOperand && token.TSubType == efp.TokenSubTypeNumber { if token.TType == efp.TokenTypeOperand && (token.TSubType == efp.TokenSubTypeNumber || token.TSubType == efp.TokenSubTypeText) {
opdStack.Push(token) opdStack.Push(token)
} }
return nil return nil

@ -34,18 +34,20 @@ func TestCalcCellValue(t *testing.T) {
{nil, nil, nil, "Feb", "South 2", 45500}, {nil, nil, nil, "Feb", "South 2", 45500},
} }
mathCalc := map[string]string{ mathCalc := map[string]string{
"=2^3": "8", "=2^3": "8",
"=1=1": "TRUE", "=1=1": "TRUE",
"=1=2": "FALSE", "=1=2": "FALSE",
"=1<2": "TRUE", "=1<2": "TRUE",
"=3<2": "FALSE", "=3<2": "FALSE",
"=2<=3": "TRUE", "=2<=3": "TRUE",
"=2<=1": "FALSE", "=2<=1": "FALSE",
"=2>1": "TRUE", "=2>1": "TRUE",
"=2>3": "FALSE", "=2>3": "FALSE",
"=2>=1": "TRUE", "=2>=1": "TRUE",
"=2>=3": "FALSE", "=2>=3": "FALSE",
"=1&2": "12", "=1&2": "12",
`="A"="A"`: "TRUE",
`="A"<>"A"`: "FALSE",
// Engineering Functions // Engineering Functions
// BESSELI // BESSELI
"=BESSELI(4.5,1)": "15.389222753735925", "=BESSELI(4.5,1)": "15.389222753735925",
@ -1084,6 +1086,10 @@ func TestCalcCellValue(t *testing.T) {
"=IF(1<>1)": "FALSE", "=IF(1<>1)": "FALSE",
"=IF(5<0, \"negative\", \"positive\")": "positive", "=IF(5<0, \"negative\", \"positive\")": "positive",
"=IF(-2<0, \"negative\", \"positive\")": "negative", "=IF(-2<0, \"negative\", \"positive\")": "negative",
`=IF(1=1, "equal", "notequal")`: "equal",
`=IF(1<>1, "equal", "notequal")`: "notequal",
`=IF("A"="A", "equal", "notequal")`: "equal",
`=IF("A"<>"A", "equal", "notequal")`: "notequal",
// Excel Lookup and Reference Functions // Excel Lookup and Reference Functions
// CHOOSE // CHOOSE
"=CHOOSE(4,\"red\",\"blue\",\"green\",\"brown\")": "brown", "=CHOOSE(4,\"red\",\"blue\",\"green\",\"brown\")": "brown",

Loading…
Cancel
Save