|
@@ -2,12 +2,12 @@ package util
|
|
|
|
|
|
//数据导出excel
|
|
|
import (
|
|
|
- "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
+ qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"io"
|
|
|
+ "jy/src/jfw/modules/subscribepay/src/config"
|
|
|
"os"
|
|
|
- qutil "app.yhyue.com/moapp/jybase/common"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
@@ -32,14 +32,14 @@ var (
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-//获取
|
|
|
+// 获取
|
|
|
func GetExcelFilePath(orderCode string) string {
|
|
|
now := time.Now()
|
|
|
filename := fmt.Sprintf("%s.xlsx", fmt.Sprintf("%s_%s_%s", now.Format("20060102150405"), orderCode, qutil.GetLetterRandom(5)))
|
|
|
return fmt.Sprintf("/dataexport/%s/%s/%s", now.Format("2006"), now.Format("01"), filename)
|
|
|
}
|
|
|
|
|
|
-//获取excel导出数据长度
|
|
|
+// 获取excel导出数据长度
|
|
|
func GetDataExportFileDataLen(path string) (int, error) {
|
|
|
xFile, err := xlsx.OpenFile(path)
|
|
|
if err != nil {
|
|
@@ -55,7 +55,7 @@ func GetDataExportFileDataLen(path string) (int, error) {
|
|
|
return sheet1.Rows[len(sheet1.Rows)-1].Cells[0].Int()
|
|
|
}
|
|
|
|
|
|
-//生成数据导出excel
|
|
|
+// 生成数据导出excel
|
|
|
func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, filePath string) error {
|
|
|
if list == nil || len(*list) == 0 {
|
|
|
return errors.New("未查询到数据")
|
|
@@ -147,6 +147,8 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
|
|
|
if v.Filed == "title" || v.Filed == "url" {
|
|
|
cell.SetFormula(fmt.Sprintf("=HYPERLINK(\"%s\",\"%s\")", data["url_jump"], data[v.Filed]))
|
|
|
+ } else if v.Filed == "href" {
|
|
|
+ cell.SetFormula(fmt.Sprintf("=HYPERLINK(\"%s\",\"%s\")", data["href"], data[v.Filed]))
|
|
|
} else {
|
|
|
cell.SetValue(data[v.Filed])
|
|
|
}
|
|
@@ -162,8 +164,8 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
return file.Save(filePath)
|
|
|
}
|
|
|
|
|
|
-//校验文件夹是否存在;
|
|
|
-//若不存在则创建;
|
|
|
+// 校验文件夹是否存在;
|
|
|
+// 若不存在则创建;
|
|
|
func FolderCheck(path string) error {
|
|
|
pathCheck := path[:strings.LastIndex(path, "/")]
|
|
|
//校验文件夹是否存在
|
|
@@ -175,7 +177,7 @@ func FolderCheck(path string) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-//移动文件至指定目录
|
|
|
+// 移动文件至指定目录
|
|
|
func MoveFile(src, dst string) (int64, error) {
|
|
|
srcFile, err := os.Open(src)
|
|
|
if err != nil {
|