浏览代码

Merge branch 'bzq1/excel_download_style'

hsun 3 周之前
父节点
当前提交
f4d588903a

+ 6 - 1
controllers/data_manage/excel/balance_table.go

@@ -1425,7 +1425,12 @@ func downloadBalanceTable(excelInfo *excel.ExcelInfo, lang string) (savePath, zi
 				err = fmt.Errorf("转换成table失败,Err:" + err.Error())
 				err = fmt.Errorf("转换成table失败,Err:" + err.Error())
 				return
 				return
 			}
 			}
-
+			tableData, err = excel2.HandleRuleToTableCell(childExcelInfo.ExcelInfoId, tableData)
+			if err != nil {
+				errMsg = "获取失败"
+				err = fmt.Errorf("处理条件格式管理规则失败,Err:%w", err)
+				return
+			}
 			// 将单个sheet的数据写入到excel
 			// 将单个sheet的数据写入到excel
 			err = tableData.WriteExcelSheetData(xlsxFile, childExcelInfo.ExcelName)
 			err = tableData.WriteExcelSheetData(xlsxFile, childExcelInfo.ExcelName)
 			if err != nil {
 			if err != nil {

+ 6 - 0
controllers/data_manage/excel/excel_info.go

@@ -2725,6 +2725,12 @@ func (c *ExcelInfoController) Download() {
 			br.ErrMsg = "转换成table失败,Err:" + err.Error()
 			br.ErrMsg = "转换成table失败,Err:" + err.Error()
 			return
 			return
 		}
 		}
+		tableData, err = excel.HandleRuleToTableCell(excelInfo.ExcelInfoId, tableData)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "处理条件格式管理规则失败,Err:" + err.Error()
+			return
+		}
 	case utils.BALANCE_TABLE: // 混合表格
 	case utils.BALANCE_TABLE: // 混合表格
 		savePath, fileName, uploadDir, err, errMsg := downloadBalanceTable(excelInfo, c.Lang)
 		savePath, fileName, uploadDir, err, errMsg := downloadBalanceTable(excelInfo, c.Lang)
 		if err != nil {
 		if err != nil {

+ 15 - 15
services/excel/lucky_sheet.go

@@ -9,6 +9,7 @@ import (
 	"fmt"
 	"fmt"
 	"os"
 	"os"
 	"reflect"
 	"reflect"
+	"regexp"
 	"strconv"
 	"strconv"
 	"strings"
 	"strings"
 	"time"
 	"time"
@@ -824,13 +825,12 @@ func getExcelFontConf(cellInfo LuckySheetDataValue) xlsx.Font {
 		}
 		}
 		familyName = tmpFamilyName
 		familyName = tmpFamilyName
 	}
 	}
-
 	return xlsx.Font{
 	return xlsx.Font{
 		Size: fontSize,
 		Size: fontSize,
 		Name: familyName,
 		Name: familyName,
 		//Family: v2.FontFamily,
 		//Family: v2.FontFamily,
 		//Charset:   0,
 		//Charset:   0,
-		Color:     strings.TrimPrefix(cellInfo.FontColor, "#"),
+		Color:     strings.TrimPrefix(getColor(cellInfo.FontColor), "#"),
 		Bold:      isBold,
 		Bold:      isBold,
 		Italic:    isItalic,
 		Italic:    isItalic,
 		Underline: isUnderline,
 		Underline: isUnderline,
@@ -1429,22 +1429,22 @@ func getExcelizeAlignmentConf(cellInfo LuckySheetDataValue) *excelize.Alignment
 
 
 // getColor 获取hex颜色
 // getColor 获取hex颜色
 func getColor(bgStr string) string {
 func getColor(bgStr string) string {
-	if strings.Contains(bgStr, "(") {
-		arr := strings.Split(bgStr, ",")
-		if len(arr) != 3 {
+	isRgb := strings.HasPrefix(bgStr, "rgb")
+	re := regexp.MustCompile(`\(([^)]+)\)`)
+	matches := re.FindStringSubmatch(bgStr)
+	if len(matches) != 2 {
+		return bgStr
+	}
+	if isRgb {
+		arr := strings.Split(matches[1], ",")
+		if len(arr) < 3 {
 			return bgStr
 			return bgStr
 		}
 		}
-
-		// 第一位
-		tmpFirstArr := strings.Split(arr[0], "(")
-		arr[0] = tmpFirstArr[len(tmpFirstArr)-1]
-
-		// 最后一位
-		tmpLastArr := strings.Split(arr[2], ")")
-		arr[2] = tmpLastArr[0]
-
 		rgbArr := make([]int64, 0)
 		rgbArr := make([]int64, 0)
-		for _, v := range arr {
+		for i, v := range arr {
+			if i >= 3 {
+				continue
+			}
 			tmpInt, err := strconv.Atoi(utils.TrimStr(v))
 			tmpInt, err := strconv.Atoi(utils.TrimStr(v))
 			if err != nil {
 			if err != nil {
 				return bgStr
 				return bgStr