go execl 包

初探 golang execl 包,安装,使用,demo…

介绍

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

发表评论

邮箱地址不会被公开。 必填项已用*标注