修改导出文件乱码
This commit is contained in:
parent
29309cd960
commit
8e1241846e
@ -183,10 +183,10 @@ func ExportRegister(c *gin.Context) {
|
||||
temp = append(temp, v.UpdatedAt)
|
||||
data = append(data, &temp)
|
||||
}
|
||||
_, _ = utils.ToExcelByType(columns, data, "slice", filePath)
|
||||
// if err != nil {
|
||||
// response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
|
||||
// }
|
||||
_, err = utils.ToExcelByType(columns, data, "slice", filePath)
|
||||
if err != nil {
|
||||
response.ResponseQuickMsg(c, msg.Fail, err.Error(), nil)
|
||||
}
|
||||
//处理图片
|
||||
// err = logic.DealExcelImg(filePath)
|
||||
// if err != nil {
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -79,6 +80,12 @@ func ToExcelByType(titleList []string, dataList []interface{}, dataType string,
|
||||
var buffer bytes.Buffer
|
||||
_ = file.Write(&buffer)
|
||||
if filePath != "" {
|
||||
dir := filepath.Dir(filePath)
|
||||
if err = CreateDirPath(dir); err != nil {
|
||||
// 新增错误日志记录
|
||||
logger.Errorf("目录创建失败: %v", err)
|
||||
return
|
||||
}
|
||||
if err = file.Save(filePath); err != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user