This closes #1492, fix data bar min/max value doesn't work

This commit is contained in:
xuri 2023-03-14 00:58:20 +08:00
parent dc3bf331d5
commit 0d193c76ac
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
2 changed files with 4 additions and 2 deletions

View File

@ -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,

View File

@ -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}},