1 Star 0 Fork 1

窦雪峰/unioffice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
Todd 提交于 2017-09-23 08:23 . schema: rename spreadsheetml to sml
// Copyright 2017 Baliance. All rights reserved.
package main
import (
"fmt"
"log"
"baliance.com/gooxml/color"
"baliance.com/gooxml/schema/soo/sml"
"baliance.com/gooxml/spreadsheet"
)
func main() {
ss := spreadsheet.New()
sheet := ss.AddSheet()
hdrStyle := ss.StyleSheet.AddCellStyle()
hdrStyle.SetHorizontalAlignment(sml.ST_HorizontalAlignmentCenter)
lightGray := ss.StyleSheet.Fills().AddFill()
lightGrayPattern := lightGray.SetPatternFill()
lightGrayPattern.SetFgColor(color.LightGray)
hdrStyle.SetFill(lightGray)
hdr := sheet.AddRow()
hdrCell := hdr.AddCell()
hdrCell.SetString("Products")
hdrCell.SetStyle(hdrStyle)
hdrCell = hdr.AddCell()
hdrCell.SetString("# Sold")
hdrCell.SetStyle(hdrStyle)
for i := 0; i < 10; i++ {
row := sheet.AddRow()
cell := row.AddCell()
cell.SetString(fmt.Sprintf("Product %d", i+1))
cell = row.AddCell()
cell.SetNumber(float64(i + 1))
}
totalRow := sheet.AddRow()
totalCell := totalRow.AddCell()
totalCell = totalRow.AddCell()
totalCell.SetFormulaRaw("SUM(B2:B11)")
ss.RecalculateFormulas()
if err := ss.Validate(); err != nil {
log.Fatalf("error validating: %s", err)
}
ss.SaveToFile("formula.xlsx")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/douxuefeng/unioffice.git
git@gitee.com:douxuefeng/unioffice.git
douxuefeng
unioffice
unioffice
v0.7.0

搜索帮助