Browse Source

Merge branch 'master' into add_mode

add_mode
DengBiao 1 year ago
parent
commit
808c5aa465
1 changed files with 12 additions and 7 deletions
  1. +12
    -7
      app/admin/svc/svc_data_statisstics.go

+ 12
- 7
app/admin/svc/svc_data_statisstics.go View File

@@ -659,25 +659,30 @@ func SelfSupportForSchoolDataStatisticsExport(req md.SelfSupportForSchoolDataSta
totalData[k2]["amount"] = sumAmount totalData[k2]["amount"] = sumAmount
} }


xlsx.NewSheet("Sheet1")
//xlsx.NewSheet("所有档口")
xlsx.SetSheetName("Sheet1", "所有档口")
titleList = []string{" 设 备 分 餐 数 据 统 计 表 "} titleList = []string{" 设 备 分 餐 数 据 统 计 表 "}
xlsx.SetSheetRow("Sheet1", "A1", &titleList)
xlsx.SetSheetRow("所有档口", "A1", &titleList)
titleList = []string{"名 称", "消费笔数", "消费金额"} titleList = []string{"名 称", "消费笔数", "消费金额"}
xlsx.SetSheetRow("Sheet1", "A2", &titleList)
xlsx.SetSheetRow("所有档口", "A2", &titleList)
style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`) style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`)
if err != nil { if err != nil {
logx.Error(err) logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error()) println("<<<<SelfSupportForSchoolDataStatisticsExport4>>>>>Error:::", err.Error())
panic(err) panic(err)
} }
xlsx.MergeCell("Sheet1", "A1", "C1") //合并单元格
xlsx.SetCellStyle("Sheet1", "A1", "C1", style)
xlsx.SetColWidth("Sheet1", "A", "C", 20)
xlsx.MergeCell("所有档口", "A1", "C1") //合并单元格
xlsx.SetCellStyle("所有档口", "A1", "C1", style)
xlsx.SetColWidth("所有档口", "A", "C", 20)
j := 3 //表头前两行用了,只能从第三行开始 j := 3 //表头前两行用了,只能从第三行开始
var totalNum, totalAmount float64
for key, val := range totalData { for key, val := range totalData {
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{key, val["num"], val["amount"]})
totalNum += val["num"]
totalAmount += val["amount"]
xlsx.SetSheetRow("所有档口", "A"+strconv.Itoa(j), &[]interface{}{key, val["num"], val["amount"]})
j++ j++
} }
xlsx.SetSheetRow("所有档口", "A"+strconv.Itoa(j), &[]interface{}{"合计", totalNum, totalAmount})


//xlsx.DeleteSheet("Sheet1") //TODO::只能放这里删除 //xlsx.DeleteSheet("Sheet1") //TODO::只能放这里删除
//将文件保存至服务器 //将文件保存至服务器


Loading…
Cancel
Save