2

golang生成excel

 2 years ago
source link: https://studygolang.com/articles/13517?fr=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

excelclaim

包装了excelize简化表格的生成。

  • 生成交通补贴
sheet := excel.NewSheet(xlsx, "加班交通费", 7, 28)
sheet.SetAllColsWidth(7, 14, 10, 11, 12, 8, 8)
sheet.SetRowNum(6)
excelStyle := excel.NewExcelStyle(11, 0, false);
sheet.Apply(excelStyle);

excelStyle2 := excel.NewExcelStyle(11, 0, true);

sheet.WriteRow("市内交通费报销明细").SetRowHeight(34).Apply(excelStyle2)
sheet.WriteRow("月份", "6", "姓名", "wwww", "部门", "", "研发部").Apply(excelStyle2)
sheet.WriteRow("序号", "日期", "出发地", "到达地", "公务事由", "金额", "备注").Apply(excelStyle2)
sheet.WriteRow("1", "2018.06.07", "公司", "宝安", "加班", "80.00", "").ApplyItem(1, excelStyle2)
sheet.WriteRow("2", "2018.06.07", "公司", "宝安", "加班", "80.00", "").ApplyItem(1, excelStyle2)
sheet.WriteRow("", "", "", "", "金额合计", "160.00")
544191-873ca3f8189306e0.jpg
交通费.jpg
  • 生成加班补贴
sheet := excel.NewSheet(xlsx, "加班餐费", 6, 22)
sheet.SetAllColsWidth(7, 14, 8, 11, 8, 12)

sheet.WriteRow("加班餐费明细")
sheet.WriteRow("月份", "2018年06月", "姓名", "wwww", "部门", "研发部")
sheet.WriteRow("序号", "日期", "事由", "中餐/晚餐", "金额", "备注")
sheet.WriteRow("1", "2018-06-01", "加班", "晚餐", "20", "21:05")
sheet.WriteRow("2", "2018-06-02", "加班", "晚餐", "20", "21:05")
sheet.WriteRow("3", "2018-06-01", "加班", "晚餐", "20", "21:05")
sheet.WriteRow("4", "2018-06-02", "加班", "晚餐", "20", "21:05")
sheet.WriteRow("", "", "", "", "金额合计", "80.00", "")
sheet.Apply(excel.NewExcelStyle(10, -1, false));
544191-8613e3089cb6d3c9.jpg
餐费.jpg

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK