|
|
@ -815,6 +815,27 @@ func (f *File) calcCellValue(ctx *calcContext, sheet, cell string) (result formu
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (f *File) CalcFormulaValue(sheet, formula string) (result string, err error) {
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
|
|
|
token efp.Token
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
ps := efp.ExcelParser()
|
|
|
|
|
|
|
|
tokens := ps.Parse(formula)
|
|
|
|
|
|
|
|
if tokens == nil {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if token, err = f.evalInfixExp(sheet, "", tokens); err != nil {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
result = token.TValue
|
|
|
|
|
|
|
|
isNum, precision := isNumeric(result)
|
|
|
|
|
|
|
|
if isNum && precision > 15 {
|
|
|
|
|
|
|
|
num, _ := roundPrecision(result)
|
|
|
|
|
|
|
|
result = strings.ToUpper(num)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// getPriority calculate arithmetic operator priority.
|
|
|
|
// getPriority calculate arithmetic operator priority.
|
|
|
|
func getPriority(token efp.Token) (pri int) {
|
|
|
|
func getPriority(token efp.Token) (pri int) {
|
|
|
|
pri = tokenPriority[token.TValue]
|
|
|
|
pri = tokenPriority[token.TValue]
|
|
|
|