在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
package main import ( "fmt" "github.com/tealeg/xlsx" ) type Try struct { I string J string K string } func main() { var file *xlsx.File var sheet *xlsx.Sheet var row *xlsx.Row var err error file = xlsx.NewFile() sheet, err = file.AddSheet("Sheet1") if err != nil { fmt.Println(err.Error()) } //添加表 A := Try{ I: "第一列", J: "第二列", K: "第三列", } row = sheet.AddRow() row.WriteStruct(&A, 3) B := Try{ I: "1", J: "2", K: "3", } row = sheet.AddRow() row.WriteStruct(&B, 3) C := Try{ I: "11", J: "22", K: "33", } row = sheet.AddRow() row.WriteStruct(&C, 3) err = file.Save("MyXLSXFile.xlsx") if err != nil { fmt.Println(err.Error()) } }
|
请发表评论