1、优化历史汇总(按小时)excel导出接口;
This commit is contained in:
parent
16ad7a9b6c
commit
1b2dbab38d
|
@ -1727,7 +1727,6 @@ func ExportHourSummaryToExcel(data []MgHourSummary, sumData TotalHourSummary, db
|
||||||
|
|
||||||
// 填充数据
|
// 填充数据
|
||||||
for i, record := range data {
|
for i, record := range data {
|
||||||
nExcelStartRow += 1
|
|
||||||
row := i + 2
|
row := i + 2
|
||||||
productName := productMap[record.ProductID] // 获取产品名称
|
productName := productMap[record.ProductID] // 获取产品名称
|
||||||
file.SetCellValue(sheet, "A"+strconv.Itoa(row), record.Hour)
|
file.SetCellValue(sheet, "A"+strconv.Itoa(row), record.Hour)
|
||||||
|
@ -1744,9 +1743,7 @@ func ExportHourSummaryToExcel(data []MgHourSummary, sumData TotalHourSummary, db
|
||||||
file.SetCellValue(sheet, "L"+strconv.Itoa(row), record.TotalNewUserUnsubRate)
|
file.SetCellValue(sheet, "L"+strconv.Itoa(row), record.TotalNewUserUnsubRate)
|
||||||
}
|
}
|
||||||
|
|
||||||
endRow := fmt.Sprintf("L%d", len(data)+1)
|
nExcelStartRow += len(data)
|
||||||
// 应用样式到整个表格
|
|
||||||
_ = file.SetCellStyle(sheet, "A1", endRow, style)
|
|
||||||
|
|
||||||
totalData := "订单数:" + strconv.FormatInt(int64(len(data)), 10)
|
totalData := "订单数:" + strconv.FormatInt(int64(len(data)), 10)
|
||||||
end := []interface{}{totalData, "", "",
|
end := []interface{}{totalData, "", "",
|
||||||
|
@ -1761,13 +1758,17 @@ func ExportHourSummaryToExcel(data []MgHourSummary, sumData TotalHourSummary, db
|
||||||
sumData.TotalNewUserUnsubRate,
|
sumData.TotalNewUserUnsubRate,
|
||||||
}
|
}
|
||||||
for i, _ := range end {
|
for i, _ := range end {
|
||||||
cell, _ := excelize.CoordinatesToCellName(1+i, nExcelStartRow+2)
|
cell, _ := excelize.CoordinatesToCellName(1+i, nExcelStartRow+1)
|
||||||
err := file.SetCellValue(sheet, cell, end[i])
|
err := file.SetCellValue(sheet, cell, end[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("file set value err:", err)
|
logger.Errorf("file set value err:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endRow := fmt.Sprintf("L%d", nExcelStartRow+1)
|
||||||
|
// 应用样式到整个表格
|
||||||
|
_ = file.SetCellStyle(sheet, "A1", endRow, style)
|
||||||
|
|
||||||
// 从配置文件读取保存路径和URL前缀
|
// 从配置文件读取保存路径和URL前缀
|
||||||
fileName := time.Now().Format("20060102150405") + "_历史汇总(按小时).xlsx"
|
fileName := time.Now().Format("20060102150405") + "_历史汇总(按小时).xlsx"
|
||||||
url := MiGuExportUrl + fileName
|
url := MiGuExportUrl + fileName
|
||||||
|
|
Loading…
Reference in New Issue
Block a user