Imhven 2 years ago
commit df3c50bf20

@ -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]

@ -1,4 +1,4 @@
module github.com/xuri/excelize/v2 module git.qcode.fun/imhven/excelize-formula/v2
go 1.16 go 1.16

Loading…
Cancel
Save