diff --git a/calc.go b/calc.go index 6c0a3b0..a7b5427 100644 --- a/calc.go +++ b/calc.go @@ -815,7 +815,7 @@ func (f *File) calcCellValue(ctx *calcContext, sheet, cell string) (result formu return } -func (f *File) CalcFormulaValue(ctx *calcContext, sheet, formula string) (result string, err error) { +func (f *File) calcFormulaValue(ctx *calcContext, sheet, formula string) (result string, err error) { var ( token formulaArg ) @@ -830,6 +830,17 @@ func (f *File) CalcFormulaValue(ctx *calcContext, sheet, formula string) (result result = token.Value() return } +func (f *File) CalcFormulaValue(sheet, formula string) (result string, err error) { + if result, err = f.calcFormulaValue(&calcContext{ + entry: fmt.Sprintf("%s!%s", sheet, formula), + maxCalcIterations: getOptions().MaxCalcIterations, + iterations: make(map[string]uint), + iterationsCache: make(map[string]formulaArg), + }, sheet, formula); err != nil { + return + } + return +} // getPriority calculate arithmetic operator priority. func getPriority(token efp.Token) (pri int) {