|
@@ -6,12 +6,13 @@ import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
- "github.com/tealeg/xlsx/v3"
|
|
|
"io"
|
|
|
"jy/src/jfw/modules/subscribepay/src/config"
|
|
|
"os"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ "github.com/tealeg/xlsx"
|
|
|
)
|
|
|
|
|
|
var (
|
|
@@ -56,18 +57,13 @@ func GetDataExportFileDataLen(path string) (int, error) {
|
|
|
if !ok {
|
|
|
return -1, fmt.Errorf("not find sheet1")
|
|
|
}
|
|
|
-
|
|
|
- if sheet1.MaxRow == 0 {
|
|
|
+ if len(sheet1.Rows) == 0 {
|
|
|
return -1, fmt.Errorf("sheet1 hasn't Rows data ")
|
|
|
}
|
|
|
//避免最后一行为合并单元格数据
|
|
|
- for l := sheet1.MaxRow - 1; l > 0; l-- {
|
|
|
- v, err := sheet1.Row(l)
|
|
|
- if err != nil {
|
|
|
- continue
|
|
|
- }
|
|
|
- if v.GetCell(0).Value != "" {
|
|
|
- return qutil.IntAll(v.GetCell(0).Value), nil
|
|
|
+ for l := len(sheet1.Rows) - 1; l > 0; l-- {
|
|
|
+ if sheet1.Rows[l].Cells[0].Value != "" {
|
|
|
+ return sheet1.Rows[l].Cells[0].Int()
|
|
|
}
|
|
|
}
|
|
|
return -1, fmt.Errorf("sheet1 get error")
|
|
@@ -102,7 +98,7 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
Border: defaultExcelBorder,
|
|
|
}
|
|
|
cell.SetStyle(style)
|
|
|
- sheet.Col(index).SetWidth(excel.Width)
|
|
|
+ sheet.Col(index).Width = excel.Width
|
|
|
}
|
|
|
} else {
|
|
|
excelHead = config.ExConf.Senior_Fields
|
|
@@ -147,11 +143,8 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
if excel.VMerge != 1 {
|
|
|
cell.SetString(excel.Name)
|
|
|
}
|
|
|
+ sheet.Col(cNum).Width = excel.Width
|
|
|
cNum++
|
|
|
- if excel.Width > 0 {
|
|
|
- sheet.SetColWidth(cNum, cNum, excel.Width)
|
|
|
- }
|
|
|
-
|
|
|
cell.SetStyle(&xlsx.Style{
|
|
|
Fill: *xlsx.NewFill("solid", excel.Color, excel.Color),
|
|
|
Border: defaultExcelBorder,
|
|
@@ -170,7 +163,6 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
for index, winnerDatas := range winnerMaps {
|
|
|
row = sheet.AddRow()
|
|
|
row.SetHeight(20)
|
|
|
-
|
|
|
for _, v := range excelHead {
|
|
|
if v.Filed == "" {
|
|
|
continue
|
|
@@ -180,15 +172,13 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
Border: defaultExcelBorder,
|
|
|
Alignment: defaultExcelAlignment,
|
|
|
}
|
|
|
-
|
|
|
if v.Filed != "legal_person" && v.Filed != "company_phone" && v.Filed != "company_email" && v.Filed != "company_name" {
|
|
|
if index == 0 {
|
|
|
cell.VMerge = winnerTotal - 1
|
|
|
-
|
|
|
if v.Filed == "title" || v.Filed == "url" {
|
|
|
- cell.SetHyperlink(qutil.ObjToString(data["url_jump"]), qutil.ObjToString(data[v.Filed]), "")
|
|
|
+ cell.SetFormula(fmt.Sprintf("=HYPERLINK(\"%s\",\"%s\")", data["url_jump"], data[v.Filed]))
|
|
|
} else if v.Filed == "href" {
|
|
|
- cell.SetHyperlink(qutil.ObjToString(data["href"]), qutil.ObjToString(data[v.Filed]), "")
|
|
|
+ cell.SetFormula(fmt.Sprintf("=HYPERLINK(\"%s\",\"%s\")", data["href"], data[v.Filed]))
|
|
|
} else {
|
|
|
cell.SetValue(data[v.Filed])
|
|
|
}
|
|
@@ -205,7 +195,6 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
} else {
|
|
|
row = sheet.AddRow()
|
|
|
row.SetHeight(20)
|
|
|
-
|
|
|
for _, v := range excelHead {
|
|
|
if v.Filed == "" {
|
|
|
continue
|
|
@@ -216,9 +205,9 @@ func CreateDataExportExcelFile(list *[]map[string]interface{}, isSenior bool, fi
|
|
|
Alignment: defaultExcelAlignment,
|
|
|
}
|
|
|
if v.Filed == "title" || v.Filed == "url" {
|
|
|
- cell.SetHyperlink(qutil.ObjToString(data["url_jump"]), qutil.ObjToString(data[v.Filed]), "")
|
|
|
+ cell.SetFormula(fmt.Sprintf("=HYPERLINK(\"%s\",\"%s\")", data["url_jump"], data[v.Filed]))
|
|
|
} else if v.Filed == "href" {
|
|
|
- cell.SetHyperlink(qutil.ObjToString(data["href"]), qutil.ObjToString(data[v.Filed]), "")
|
|
|
+ cell.SetFormula(fmt.Sprintf("=HYPERLINK(\"%s\",\"%s\")", data["href"], data[v.Filed]))
|
|
|
} else {
|
|
|
cell.SetValue(data[v.Filed])
|
|
|
}
|