This closes #858 (#859)

* fixes https://github.com/360EntSecGroup-Skylar/excelize/issues/858

* fixes https://github.com/360EntSecGroup-Skylar/excelize/issues/858

Co-authored-by: dvelderp <peter.de.velder@gmail.com>
This commit is contained in:
jaby 2021-06-08 13:02:34 +02:00 committed by GitHub
parent 2c90b3f535
commit bafe087a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 19 deletions

View File

@ -628,16 +628,10 @@ func (f *File) evalInfixExp(sheet, cell string, tokens []efp.Token) (efp.Token,
}
// current token is logical
if token.TType == efp.OperatorsInfix && token.TSubType == efp.TokenSubTypeLogical {
}
if token.TType == efp.TokenTypeOperand && token.TSubType == efp.TokenSubTypeLogical {
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 {
return efp.Token{}, err
}
@ -1012,7 +1006,7 @@ func (f *File) parseToken(sheet string, token efp.Token, opdStack, optStack *Sta
optStack.Pop()
}
// 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)
}
return nil

View File

@ -46,6 +46,8 @@ func TestCalcCellValue(t *testing.T) {
"=2>=1": "TRUE",
"=2>=3": "FALSE",
"=1&2": "12",
`="A"="A"`: "TRUE",
`="A"<>"A"`: "FALSE",
// Engineering Functions
// BESSELI
"=BESSELI(4.5,1)": "15.389222753735925",
@ -1084,6 +1086,10 @@ func TestCalcCellValue(t *testing.T) {
"=IF(1<>1)": "FALSE",
"=IF(5<0, \"negative\", \"positive\")": "positive",
"=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
// CHOOSE
"=CHOOSE(4,\"red\",\"blue\",\"green\",\"brown\")": "brown",