地址:https://github.com/tealeg/xlsx
具体各类操作可以直接看里边给出的示例或直接查看代码,用法还是很简单的。这里给出个简单的测试示例:
package main import ( "fmt" "github.com/tealeg/xlsx" ) func test1() { var file *xlsx.File var sheet *xlsx.Sheet var row *xlsx.Row var cell *xlsx.Cell var err error file = xlsx.NewFile() sheet = file.AddSheet("Sheet1") row = sheet.AddRow() cell = row.AddCell() cell.Value = "000101" cell = row.AddCell() cell.Value = "中文" err = file.Save("MyXLSXFile.xlsx") if err != nil { fmt.Printf(err.Error()) } } func test2() { var file *xlsx.File var sheet *xlsx.Sheet var row *xlsx.Row var cell *xlsx.Cell var err error file,_ = xlsx.OpenFile("MyXLSXFile.xlsx") sheet = file.Sheet["Sheet1"] row = sheet.AddRow() cell = row.AddCell() cell.Value = "000101" cell = row.AddCell() cell.Value = "中文1" err = file.Save("MyXLSXFile1.xlsx") if err != nil { fmt.Printf(err.Error()) } } func main() { test1() test2() }