From 42062d5fb7217bc39f41e362f66a6328c41d0252 Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Sat, 23 Sep 2023 17:55:05 +0800 Subject: [PATCH] update --- app/admin/svc/svc_data_statisstics.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/admin/svc/svc_data_statisstics.go b/app/admin/svc/svc_data_statisstics.go index 80cfd0b..bdacc5e 100644 --- a/app/admin/svc/svc_data_statisstics.go +++ b/app/admin/svc/svc_data_statisstics.go @@ -840,6 +840,9 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD for k1, v1 := range list { tmpFileName := k1 + "班级明细_" + utils.Int64ToStr(now.UnixMilli()) + ".xlsx" tmpDownloadPath := "./static/export/central_kitchen_for_school/" + tmpFileName + startDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.StartDate, time.Local) + endDate, _ := time.ParseInLocation("2006-01-02 15:04:05", req.EndDate, time.Local) + for k2, v2 := range v1 { if k2 == "" { //若年级为空,则为教师餐 @@ -847,10 +850,22 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD } for k3, v3 := range v2 { - titleList = []string{"姓名", "早餐", "午餐", "晚餐"} xlsx.NewSheet(k3) + titleList = []string{startDate.Format("2006-01-02") + "~~" + endDate.Format("2006-01-02") + " (" + k1 + ", " + k3 + ") 班级明细"} xlsx.SetSheetRow(k3, "A1", &titleList) - j := 2 //表头被第一行用了,只能从第二行开始 + titleList = []string{"姓名", "早餐", "午餐", "晚餐"} + xlsx.SetSheetRow(k3, "A2", &titleList) + xlsx.MergeCell(k3, "A1", "D1") //合并单元格 + style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`) + if err != nil { + logx.Error(err) + println("<<<>>>>Error:::", err.Error()) + panic(err) + } + xlsx.SetCellStyle(k3, "A1", "D1", style) + + xlsx.SetColWidth(k3, "A", "D", 20) + j := 3 //表头前两行用了,只能从第三行开始 for k4, v4 := range v3 { xlsx.SetSheetRow(k3, "A"+strconv.Itoa(j), &[]interface{}{ k4, v4["breakfast"], v4["lunch"], v4["dinner"]})