|
|
|
@ -815,24 +815,19 @@ func (f *File) calcCellValue(ctx *calcContext, sheet, cell string) (result formu
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (f *File) CalcFormulaValue(sheet, formula string) (result string, err error) {
|
|
|
|
|
func (f *File) CalcFormulaValue(ctx *calcContext, sheet, formula string) (result string, err error) {
|
|
|
|
|
var (
|
|
|
|
|
token efp.Token
|
|
|
|
|
token formulaArg
|
|
|
|
|
)
|
|
|
|
|
ps := efp.ExcelParser()
|
|
|
|
|
tokens := ps.Parse(formula)
|
|
|
|
|
if tokens == nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if token, err = f.evalInfixExp(sheet, "", tokens); err != nil {
|
|
|
|
|
if token, err = f.evalInfixExp(ctx, sheet, "", tokens); err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
result = token.TValue
|
|
|
|
|
isNum, precision := isNumeric(result)
|
|
|
|
|
if isNum && precision > 15 {
|
|
|
|
|
num, _ := roundPrecision(result)
|
|
|
|
|
result = strings.ToUpper(num)
|
|
|
|
|
}
|
|
|
|
|
result = token.Value()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|