|
|
|
|
@ -13,7 +13,7 @@ import (
|
|
|
|
|
|
|
|
|
|
func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*service.HighOptLossHistory) {
|
|
|
|
|
// Open the Excel file
|
|
|
|
|
f, err := excelize.OpenFile("/Users/leo/Documents/光衰通报/光衰/2025/光衰通报(3月28日).xlsx")
|
|
|
|
|
f, err := excelize.OpenFile("/Users/leo/Documents/光衰通报/光衰/2025/光衰通报(4月16日).xlsx")
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
return
|
|
|
|
|
@ -123,8 +123,9 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
|
|
|
|
|
NumFmt: 10, // 或使用自定义格式代码:"0.00%"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Cut and paste data from E4:E22 to C4:C22
|
|
|
|
|
for i := 4; i <= 22; i++ {
|
|
|
|
|
// Cut and paste data from E4:E23 to C4:C23
|
|
|
|
|
//TODO
|
|
|
|
|
for i := 4; i <= 23; i++ {
|
|
|
|
|
eCell := "E" + strconv.Itoa(i)
|
|
|
|
|
cCell := "C" + strconv.Itoa(i)
|
|
|
|
|
value, _ := f.GetCellValue("汇总", eCell)
|
|
|
|
|
@ -132,8 +133,9 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
|
|
|
|
|
f.SetCellValue("汇总", eCell, "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Populate E4:L22 with data from the map
|
|
|
|
|
for i := 4; i <= 22; i++ {
|
|
|
|
|
// Populate E4:L23 with data from the map
|
|
|
|
|
//TODO
|
|
|
|
|
for i := 4; i <= 23; i++ {
|
|
|
|
|
bCell := "B" + strconv.Itoa(i)
|
|
|
|
|
key, _ := f.GetCellValue("汇总", bCell)
|
|
|
|
|
if data, ok := m1[key]; ok {
|
|
|
|
|
@ -232,8 +234,9 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate D4:D22 as C-E
|
|
|
|
|
for i := 4; i <= 22; i++ {
|
|
|
|
|
// Calculate D4:D23 as C-E
|
|
|
|
|
//TODO
|
|
|
|
|
for i := 4; i <= 23; i++ {
|
|
|
|
|
cCell := "C" + strconv.Itoa(i)
|
|
|
|
|
eCell := "E" + strconv.Itoa(i)
|
|
|
|
|
dCell := "D" + strconv.Itoa(i)
|
|
|
|
|
@ -258,16 +261,19 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
|
|
|
|
|
f.SetCellStyle("汇总", dCell, dCell, styleGreen)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Sum columns C:H and place the results in row 23
|
|
|
|
|
// Sum columns C:H and place the results in row 24
|
|
|
|
|
for col := 'C'; col <= 'L'; col++ {
|
|
|
|
|
sumCell := string(col) + "23"
|
|
|
|
|
sumFormula := fmt.Sprintf("SUM(%s4:%s22)", string(col), string(col))
|
|
|
|
|
//TODO
|
|
|
|
|
sumCell := string(col) + "24"
|
|
|
|
|
//TODO
|
|
|
|
|
sumFormula := fmt.Sprintf("SUM(%s4:%s23)", string(col), string(col))
|
|
|
|
|
f.SetCellFormula("汇总", sumCell, sumFormula)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Recalculate the sum for each cell to ensure it appears without manual intervention
|
|
|
|
|
for col := 'C'; col <= 'L'; col++ {
|
|
|
|
|
sumCell := string(col) + "23"
|
|
|
|
|
//TODO
|
|
|
|
|
sumCell := string(col) + "24"
|
|
|
|
|
value, err := f.CalcCellValue("汇总", sumCell)
|
|
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
@ -275,8 +281,9 @@ func GenExcelFile(m1 map[string]*service.HighOptLossUnder, m2 map[string]*servic
|
|
|
|
|
f.SetCellValue("汇总", sumCell, cast.ToInt(value))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
done, _ := f.GetCellValue("汇总", "K23")
|
|
|
|
|
total, _ := f.GetCellValue("汇总", "L23")
|
|
|
|
|
//TODO 2行
|
|
|
|
|
done, _ := f.GetCellValue("汇总", "K24")
|
|
|
|
|
total, _ := f.GetCellValue("汇总", "L24")
|
|
|
|
|
f.SetCellValue("汇总", "M23", mathkit.FloatRound(cast.ToFloat64(done)/cast.ToFloat64(total), 4))
|
|
|
|
|
|
|
|
|
|
//设置表头
|
|
|
|
|
|