作者 tangxvhui

bug 修复

... ... @@ -412,7 +412,13 @@ func (c *AuditController) ChanceDataExcel() {
sourceData, excelHead := serveaudit.GetAuditListForExcel(param, companyId, uid)
xlsMaker := exceltool.NewExcelMaker()
xlsMaker.SetListHead(excelHead)
xlsMaker.MakeListExcelForBeego(sourceData)
err = xlsMaker.MakeListExcelForBeego(sourceData)
if err != nil {
log.Error("合成excel失败,err:%s", err)
msg = protocol.BadRequestParam("1")
c.ResposeJson(msg)
return
}
c.ResponseExcelByFile(c.Ctx, xlsMaker)
return
}
... ...
... ... @@ -107,7 +107,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user
publishStatusS := fmt.Sprint(soureData[i]["publish_status"])
publishStatus, _ := strconv.Atoi(publishStatusS)
soureData[i]["publish_status"] = models.ChancePublishStatusMap[publishStatus]
soureContentJson := fmt.Sprint(soureData[i]["soure_content"])
soureContentJson := fmt.Sprint(soureData[i]["source_content"])
var (
soureContentData []protocol.InputElement
soureContentText strings.Builder
... ... @@ -118,7 +118,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user
soureContentText.WriteString(soureContentData[ii].Label + ":" + soureContentData[ii].CurrentValue + ",")
}
}
soureData[i]["soure_content"] = soureContentText.String()
soureData[i]["source_content"] = soureContentText.String()
signString := signature.SignaString(fmt.Sprint(soureData[i]["id"]))
var frontHost string
if "prod" == myconfig.MConfig.ConfigName {
... ... @@ -141,7 +141,7 @@ func GetAuditListForExcel(param protocol.RequestAuditList, companyid int64, user
exceltool.ExcelHead{Key: "publish_status", Name: "公开状态"},
exceltool.ExcelHead{Key: "review_status", Name: "审核状态"},
exceltool.ExcelHead{Key: "status", Name: "关闭状态"},
exceltool.ExcelHead{Key: "soure_content", Name: "内容"},
exceltool.ExcelHead{Key: "source_content", Name: "内容"},
exceltool.ExcelHead{Key: "media", Name: "视频/图片/语音"},
exceltool.ExcelHead{Key: "discovery_score", Name: "得分"},
}
... ...
... ... @@ -91,7 +91,7 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) {
for key, val := range e.header {
headEn = append(headEn, val.Key)
headCn = append(headCn, val.Name)
alpha, err := excelize.ColumnNumberToName(key)
alpha, err := excelize.ColumnNumberToName(key + 1)
if err != nil {
return err
}
... ... @@ -102,8 +102,10 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) {
for index := range headCn {
//索引转列名,索引从0开始
cellAlpha := fmt.Sprintf("%s%d", alphaSlice[index], 1) // 单元格行坐标从1开始,如:a1,指第一行a列。
e.Xlsx.SetCellStr("Sheet1", cellAlpha, headCn[index])
err := e.Xlsx.SetCellStr("Sheet1", cellAlpha, headCn[index])
if err != nil {
fmt.Println(err)
}
}
//从excel第二行开始设置实际数据的值
for key1 := range sourData {
... ... @@ -112,7 +114,10 @@ func (e *ExcelMaker) MakeListExcelForBeego(sourData []orm.Params) (err error) {
if sourData[key1][headEn[i]] == nil {
sourData[key1][headEn[i]] = ""
}
e.Xlsx.SetCellStr("Sheet1", cellAlpha, fmt.Sprintf("%s", sourData[key1][headEn[i]]))
err := e.Xlsx.SetCellStr("Sheet1", cellAlpha, fmt.Sprintf("%s", sourData[key1][headEn[i]]))
if err != nil {
fmt.Println(err)
}
}
}
if len(e.fileName) == 0 {
... ...