package rearinstallothercostdata
import (
"io"
"sort"
"github.com/xuri/excelize/v2"
"utils"
"roimodel"
)
var datePoint int
// ShowExcelTable4直接显示表4
func ShowExcelTable4(response *roimodel.RearInstallOtherCostResonse) (buff io.Reader, err error) {
file := excelize.NewFile()
productSlice := []string{"ss", "ff", "gg"}
for _, sheetName := range productSlice {
index, _ := file.NewSheet(sheetName)
file.SetActiveSheet(index)
yearMonthIndex := writeTable4Date(file, response, sheetName) //将日期写入到表4并返回年月对应的位置索引
writeTable4Title(file, sheetName) //将表4标题写入到表4
writeTable4Rows(file, response, sheetName, yearMonthIndex) //将数据写入到表4
//从第3行第1列开始冻结
_ = file.SetPanes(sheetName, &excelize.Panes{
Freeze: true,
Split: false,
XSplit: 1,
YSplit: 3,
TopLeftCell: "B4",
})
}
//先删除默认的sheet1
err = file.DeleteSheet("Sheet1")
if err != nil {
return
}
buff, _ = file.WriteToBuffer()
return
}
// writeTable4Rows 将数据写入到表4
func writeTable4Rows(file *excelize.File, response *roimodel.RearInstallOtherCostResonse, sheetName string,
yearMonthIndex map[string]int) {
styleFmt4, _ :=
go将mysql表内容转换为excel特定的格式并以reader返回
于 2024-08-11 10:23:20 首次发布