分享
golang导出Excel表格
zhzhlong · · 4527 次点击 · · 开始浏览这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。
设置样式:
package main import ( "github.com/tealeg/xlsx" "fmt" ) func main() { var file *xlsx.File var sheet *xlsx.Sheet var row *xlsx.Row var cell *xlsx.Cell var err error style := xlsx.NewStyle() fill := *xlsx.NewFill("solid", "00FF0000", "FF000000") font := *xlsx.NewFont(20, "Verdana") border := *xlsx.NewBorder("thin", "thin", "thin", "thin") style.Fill = fill style.Font = font style.Border = border style.ApplyFill = true style.ApplyFont = true style.ApplyBorder = true file = xlsx.NewFile() sheet,_ = file.AddSheet("SheetName") row = sheet.AddRow() cell = row.AddCell() cell.Value = "100000" cell.SetStyle(style) cell = row.AddCell() cell.Value = "test" err = file.Save("test.xlsx") if err != nil { fmt.Printf(err.Error()) } }
发送到浏览器: https://blog.csdn.net/niechaoya/article/details/46470715
想法: 先把数据组织成一个二维数组 [ [ua ua ua ub ub ub uc uc uc ] [] [] ] 用swith
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信4527 次点击
上一篇:go 编释流程
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
设置样式:
package main import ( "github.com/tealeg/xlsx" "fmt" ) func main() { var file *xlsx.File var sheet *xlsx.Sheet var row *xlsx.Row var cell *xlsx.Cell var err error style := xlsx.NewStyle() fill := *xlsx.NewFill("solid", "00FF0000", "FF000000") font := *xlsx.NewFont(20, "Verdana") border := *xlsx.NewBorder("thin", "thin", "thin", "thin") style.Fill = fill style.Font = font style.Border = border style.ApplyFill = true style.ApplyFont = true style.ApplyBorder = true file = xlsx.NewFile() sheet,_ = file.AddSheet("SheetName") row = sheet.AddRow() cell = row.AddCell() cell.Value = "100000" cell.SetStyle(style) cell = row.AddCell() cell.Value = "test" err = file.Save("test.xlsx") if err != nil { fmt.Printf(err.Error()) } }
发送到浏览器: https://blog.csdn.net/niechaoya/article/details/46470715
想法: 先把数据组织成一个二维数组 [ [ua ua ua ub ub ub uc uc uc ] [] [] ] 用swith