代码拉取完成,页面将自动刷新
// Copyright 2017 Baliance. All rights reserved.
package main
import (
"fmt"
"baliance.com/gooxml/spreadsheet"
"baliance.com/gooxml/spreadsheet/formula"
)
func main() {
fmt.Println("Currently support", len(formula.SupportedFunctions()), "functions")
fmt.Println(formula.SupportedFunctions())
ss := spreadsheet.New()
sheet := ss.AddSheet()
sheet.Cell("A1").SetNumber(1.2)
sheet.Cell("A2").SetNumber(2.3)
sheet.Cell("A3").SetNumber(2.3)
formEv := formula.NewEvaluator()
// the formula context allows the formula evaluator to pull data from a
// sheet
a1Cell := sheet.FormulaContext().Cell("A1", formEv)
fmt.Println("A1 is", a1Cell.Value())
// So that when evaluating formulas, live workbook data is used. Formulas
// can be evaluated directly in the context of a sheet.
result := formEv.Eval(sheet.FormulaContext(), "SUM(A1:A3)")
fmt.Println("SUM(A1:A3) is", result.Value())
// Or, stored in a cell and the cell evaulated.
sheet.Cell("A4").SetFormulaRaw("SUM(A1:A3)+SUM(A1:A3)")
a4Value := formEv.Eval(sheet.FormulaContext(), "A4")
fmt.Println("A4 is", a4Value.Value())
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。