Browse Source

fix:混合表格水平对齐格式

zqbao 6 months ago
parent
commit
b0a63eb294
2 changed files with 16 additions and 6 deletions
  1. 8 6
      models/request/mixed_table.go
  2. 8 0
      services/excel/lucky_sheet.go

+ 8 - 6
models/request/mixed_table.go

@@ -160,12 +160,14 @@ type MixDateCalculateTagReq struct {
 
 // MixCellShowStyle 混合表格 单元格样式展示计算
 type MixCellShowStyle struct {
-	Pn              int    `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
-	Nt              string `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
-	Decimal         *int   `description:"小数点位数"`
-	Last            string `description:"起始操作:nt|decimal"`
-	Color           string `description:"颜色值,#RRG" json:"color"`
-	BackgroundColor string `description:"背景颜色值,#RRG" json:"background-color"`
+	Pn              int     `description:"小数点位数增加或减少,正数表述增加,负数表示减少" json:"pn"`
+	Nt              string  `description:"变换类型:number 小数点位数改变,percent百分比," json:"nt"`
+	Decimal         *int    `description:"小数点位数"`
+	Last            string  `description:"起始操作:nt|decimal"`
+	Color           string  `description:"颜色值,#RRG" json:"color"`
+	BackgroundColor string  `description:"背景颜色值,#RRG" json:"background-color"`
+	Width           float64 `description:"单元格宽度" json:"width"`
+	Align           string  `description:"对齐方式:left|center|right" json:"align"`
 }
 
 type DateDataBeforeAfterReq struct {

+ 8 - 0
services/excel/lucky_sheet.go

@@ -1222,6 +1222,14 @@ func GetTableDataByMixedTableData(config [][]request.MixedTableCellDataReq, hide
 					if styleConfig.Color != "" {
 						tmp.FontColor = styleConfig.Color
 					}
+					switch styleConfig.Align {
+					case "center":
+						tmp.HorizontalType = 0
+					case "left":
+						tmp.HorizontalType = 1
+					case "right":
+						tmp.HorizontalType = 2
+					}
 					tmp.Monitor = cell.ShowFormatValue
 					tmpShowValue, err := strconv.ParseFloat(cell.Value, 64)
 					if err == nil {