forked from p30928647/excelize
* 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:
parent
2c90b3f535
commit
bafe087a61
8
calc.go
8
calc.go
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue