ソースを参照

fix:表格样式添加字体和背景颜色

zqbao 6 ヶ月 前
コミット
f557cfa1a4
2 ファイル変更14 行追加2 行削除
  1. 4 2
      models/request/mixed_table.go
  2. 10 0
      services/excel/lucky_sheet.go

+ 4 - 2
models/request/mixed_table.go

@@ -160,8 +160,10 @@ type MixDateCalculateTagReq struct {
 
 // MixCellShowStyle 混合表格 单元格样式展示计算
 type MixCellShowStyle struct {
-	Pn int    `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
-	Nt string `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
+	Pn              int    `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
+	Nt              string `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
+	Color           string `description:"颜色值,#RRG" json:"color"`
+	BackgroundColor string `description:"背景颜色值,#RRG" json:"background-color"`
 }
 
 type DateDataBeforeAfterReq struct {

+ 10 - 0
services/excel/lucky_sheet.go

@@ -1211,7 +1211,17 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 					tmp.MergeCell.Column = cell.MerData.Mer.Col
 				}
 				if cell.ShowStyle != "" {
+					var styleConfig request.MixCellShowStyle
+					if err := json.Unmarshal([]byte(cell.ShowStyle), &styleConfig); err != nil {
+						utils.FileLog.Info("表格样式showStyle解析失败", err.Error())
+					}
 					tmp.Monitor = cell.ShowFormatValue
+					if styleConfig.BackgroundColor != "" {
+						tmp.Background = styleConfig.BackgroundColor
+					}
+					if styleConfig.Color != "" {
+						tmp.FontColor = styleConfig.Color
+					}
 				}
 				dataCol = append(dataCol, tmp)
 			}