介绍
Git: https://github.com/xuri/excelize
office site: https://xuri.me/excelize/zh-hans/
安装
$ go get github.com/xuri/excelize
$ go get github.com/xuri/excelize/v2
更新
go get -u github.com/xuri/excelize/v2
使用
package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile()
// Create a new sheet.
index := f.NewSheet("Sheet2")
// Set value of a cell.
f.SetCellValue("Sheet2", "A2", "Hello world.")
f.SetCellValue("Sheet1", "B2", 100)
// Set active sheet of the workbook.
f.SetActiveSheet(index)
// Save spreadsheet by the given path.
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
}
文档
- https://xuri.me/excelize/zh-hans/cell.html#SetCellStyle