From 0d193c76ac49eebade9802434b9288264176c072 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 14 Mar 2023 00:58:20 +0800 Subject: [PATCH] This closes #1492, fix data bar min/max value doesn't work --- styles.go | 4 +++- styles_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/styles.go b/styles.go index 3c02e2d..7c679c2 100644 --- a/styles.go +++ b/styles.go @@ -3457,7 +3457,9 @@ func extractCondFmtDataBar(c *xlsxCfRule, extLst *xlsxExtLst) ConditionalFormatO if c.DataBar != nil { format.StopIfTrue = c.StopIfTrue format.MinType = c.DataBar.Cfvo[0].Type + format.MinValue = c.DataBar.Cfvo[0].Val format.MaxType = c.DataBar.Cfvo[1].Type + format.MaxValue = c.DataBar.Cfvo[1].Val format.BarColor = "#" + strings.TrimPrefix(strings.ToUpper(c.DataBar.Color[0].RGB), "FF") if c.DataBar.ShowValue != nil { format.BarOnly = !*c.DataBar.ShowValue @@ -3707,7 +3709,7 @@ func drawCondFmtDataBar(p int, ct, GUID string, format *ConditionalFormatOptions Type: validType[format.Type], DataBar: &xlsxDataBar{ ShowValue: boolPtr(!format.BarOnly), - Cfvo: []*xlsxCfvo{{Type: format.MinType}, {Type: format.MaxType}}, + Cfvo: []*xlsxCfvo{{Type: format.MinType, Val: format.MinValue}, {Type: format.MaxType, Val: format.MaxValue}}, Color: []*xlsxColor{{RGB: getPaletteColor(format.BarColor)}}, }, ExtLst: extLst, diff --git a/styles_test.go b/styles_test.go index 257547a..f8ca15e 100644 --- a/styles_test.go +++ b/styles_test.go @@ -205,7 +205,7 @@ func TestGetConditionalFormats(t *testing.T) { {{Type: "unique", Format: 1, Criteria: "="}}, {{Type: "3_color_scale", Criteria: "=", MinType: "num", MidType: "num", MaxType: "num", MinValue: "-10", MidValue: "50", MaxValue: "10", MinColor: "#FF0000", MidColor: "#00FF00", MaxColor: "#0000FF"}}, {{Type: "2_color_scale", Criteria: "=", MinType: "num", MaxType: "num", MinColor: "#FF0000", MaxColor: "#0000FF"}}, - {{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarOnly: true, BarSolid: true, StopIfTrue: true}}, + {{Type: "data_bar", Criteria: "=", MinType: "num", MaxType: "num", MinValue: "-10", MaxValue: "10", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarOnly: true, BarSolid: true, StopIfTrue: true}}, {{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarDirection: "rightToLeft", BarOnly: true, BarSolid: true, StopIfTrue: true}}, {{Type: "formula", Format: 1, Criteria: "="}}, {{Type: "icon_set", IconStyle: "3Arrows", ReverseIcons: true, IconsOnly: true}},