From f855ddfc46cfa5c977340e645a5d0b9f1e4b871d Mon Sep 17 00:00:00 2001 From: xs Date: Tue, 10 Aug 2021 14:38:51 +0000 Subject: [PATCH 1/5] feat: add CalcFormulaValue method --- calc.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/calc.go b/calc.go index 18605db..ea5e473 100644 --- a/calc.go +++ b/calc.go @@ -475,6 +475,27 @@ func (f *File) CalcCellValue(sheet, cell string) (result string, err error) { 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. func getPriority(token efp.Token) (pri int) { pri = tokenPriority[token.TValue] From d752546afcf2a91ede56a694ad9323c3fcf7e38b Mon Sep 17 00:00:00 2001 From: xs Date: Tue, 10 Aug 2021 14:40:54 +0000 Subject: [PATCH 2/5] feat: update module name --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 41f53a2..76c4ea4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/xuri/excelize/v2 +module git.qcode.fun/com/excelize-formula/v2 go 1.15 From 6073b0b064134faab7fe4ae97bbe77f76591bf84 Mon Sep 17 00:00:00 2001 From: xs Date: Wed, 11 Aug 2021 01:11:07 +0000 Subject: [PATCH 3/5] feat: update module name --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 76c4ea4..9a833ef 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module git.qcode.fun/com/excelize-formula/v2 +module gitea.qcode.fun/com/excelize-formula/v2 go 1.15 From bf8f5129673c5adf58ca474a8646fed02a111cd2 Mon Sep 17 00:00:00 2001 From: xs Date: Wed, 11 Aug 2021 02:11:25 +0000 Subject: [PATCH 4/5] update module name --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 9a833ef..db45c7e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gitea.qcode.fun/com/excelize-formula/v2 +module gitea.qcode.fun/imhven/excelize-formula/v2 go 1.15 From f7e208ec53f74e2d616a21310b7e685417ff081c Mon Sep 17 00:00:00 2001 From: xs Date: Wed, 11 Aug 2021 05:44:40 +0000 Subject: [PATCH 5/5] feat: update module name --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index db45c7e..eb1c923 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gitea.qcode.fun/imhven/excelize-formula/v2 +module git.qcode.fun/imhven/excelize-formula/v2 go 1.15