Skip to content

Commit ee9c6fc

Browse files
Remove hash symbol in hex color values (#2381)
1 parent 46a5eb2 commit ee9c6fc

6 files changed

Lines changed: 44 additions & 44 deletions

File tree

adjust_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ func TestAdjustConditionalFormats(t *testing.T) {
10381038
Criteria: "=",
10391039
MinType: "min",
10401040
MaxType: "max",
1041-
BarColor: "#638EC6",
1041+
BarColor: "638EC6",
10421042
}}
10431043
assert.NoError(t, f.SetConditionalFormat("Sheet1", "D2:D3", format))
10441044
assert.NoError(t, f.SetConditionalFormat("Sheet1", "D5", format))
@@ -1054,7 +1054,7 @@ func TestAdjustConditionalFormats(t *testing.T) {
10541054
Criteria: "=",
10551055
MinType: "min",
10561056
MaxType: "max",
1057-
BarColor: "#638EC6",
1057+
BarColor: "638EC6",
10581058
}}
10591059
assert.NoError(t, f.SetConditionalFormat("Sheet1", "D2:E2", format))
10601060
assert.NoError(t, f.SetConditionalFormat("Sheet1", "F2", format))
@@ -1070,7 +1070,7 @@ func TestAdjustConditionalFormats(t *testing.T) {
10701070
Criteria: "=",
10711071
MinType: "min",
10721072
MaxType: "max",
1073-
BarColor: "#638EC6",
1073+
BarColor: "638EC6",
10741074
}}
10751075
assert.NoError(t, f.SetConditionalFormat("Sheet1", "D2:D3", format))
10761076
assert.NoError(t, f.SetConditionalFormat("Sheet1", "D5", format))

chart_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func TestAddChart(t *testing.T) {
171171
Border: LineOptions{
172172
Type: LineSolid,
173173
Dash: LineDashDot,
174-
Fill: Fill{Type: "pattern", Color: []string{"#FFFF00"}, Pattern: 1},
174+
Fill: Fill{Type: "pattern", Color: []string{"FFFF00"}, Pattern: 1},
175175
Width: 1,
176176
},
177177
},

excelize_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,8 +1140,8 @@ func TestConditionalFormat(t *testing.T) {
11401140
Criteria: "=",
11411141
MinType: "min",
11421142
MaxType: "max",
1143-
MinColor: "#F8696B",
1144-
MaxColor: "#63BE7B",
1143+
MinColor: "F8696B",
1144+
MaxColor: "63BE7B",
11451145
},
11461146
},
11471147
))
@@ -1154,9 +1154,9 @@ func TestConditionalFormat(t *testing.T) {
11541154
MinType: "min",
11551155
MidType: "percentile",
11561156
MaxType: "max",
1157-
MinColor: "#F8696B",
1158-
MidColor: "#FFEB84",
1159-
MaxColor: "#63BE7B",
1157+
MinColor: "F8696B",
1158+
MidColor: "FFEB84",
1159+
MaxColor: "63BE7B",
11601160
},
11611161
},
11621162
))
@@ -1255,7 +1255,7 @@ func TestConditionalFormat(t *testing.T) {
12551255
Criteria: "=",
12561256
MinType: "min",
12571257
MaxType: "max",
1258-
BarColor: "#638EC6",
1258+
BarColor: "638EC6",
12591259
},
12601260
},
12611261
))
@@ -1298,7 +1298,7 @@ func TestConditionalFormat(t *testing.T) {
12981298
Criteria: "=",
12991299
MinType: "min",
13001300
MaxType: "max",
1301-
BarColor: "#638EC6",
1301+
BarColor: "638EC6",
13021302
},
13031303
},
13041304
))
@@ -1310,7 +1310,7 @@ func TestConditionalFormat(t *testing.T) {
13101310
Criteria: "",
13111311
MinType: "min",
13121312
MaxType: "max",
1313-
BarColor: "#638EC6",
1313+
BarColor: "638EC6",
13141314
},
13151315
},
13161316
))

styles.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,7 +2558,7 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
25582558
// &excelize.Style{
25592559
// Font: &excelize.Font{Color: "9A0511"},
25602560
// Fill: excelize.Fill{
2561-
// Type: "pattern", Color: []string{"#FEC7CE"}, Pattern: 1,
2561+
// Type: "pattern", Color: []string{"FEC7CE"}, Pattern: 1,
25622562
// },
25632563
// },
25642564
// )
@@ -2652,7 +2652,7 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
26522652
// type: top - The top type is used to specify the top n values by number or
26532653
// percentage in a range:
26542654
//
2655-
// // Top/Bottom rules: Top 10.
2655+
// // Top/Bottom rules: Top 6.
26562656
// err := f.SetConditionalFormat("Sheet1", "H1:H10",
26572657
// []excelize.ConditionalFormatOptions{
26582658
// {
@@ -2689,8 +2689,8 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
26892689
// Criteria: "=",
26902690
// MinType: "min",
26912691
// MaxType: "max",
2692-
// MinColor: "#F8696B",
2693-
// MaxColor: "#63BE7B",
2692+
// MinColor: "F8696B",
2693+
// MaxColor: "63BE7B",
26942694
// },
26952695
// },
26962696
// )
@@ -2710,9 +2710,9 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
27102710
// MinType: "min",
27112711
// MidType: "percentile",
27122712
// MaxType: "max",
2713-
// MinColor: "#F8696B",
2714-
// MidColor: "#FFEB84",
2715-
// MaxColor: "#63BE7B",
2713+
// MinColor: "F8696B",
2714+
// MidColor: "FFEB84",
2715+
// MaxColor: "63BE7B",
27162716
// },
27172717
// },
27182718
// )
@@ -2737,7 +2737,7 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
27372737
// Criteria: "=",
27382738
// MinType: "min",
27392739
// MaxType: "max",
2740-
// BarColor: "#638EC6",
2740+
// BarColor: "638EC6",
27412741
// },
27422742
// },
27432743
// )
@@ -2778,9 +2778,9 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
27782778
// MinType: "min",
27792779
// MidType: "percentile",
27802780
// MaxType: "max",
2781-
// MinColor: "#F8696B",
2782-
// MidColor: "#FFEB84",
2783-
// MaxColor: "#63BE7B",
2781+
// MinColor: "F8696B",
2782+
// MidColor: "FFEB84",
2783+
// MaxColor: "63BE7B",
27842784
// },
27852785
// },
27862786
// )
@@ -2792,7 +2792,7 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
27922792
// BarBorderColor - Used for sets the color for the border line of a data bar,
27932793
// this is only visible in Excel 2010 and later.
27942794
//
2795-
// BarDirection - sets the direction for data bars. The available options are:
2795+
// BarDirection - Sets the direction for data bars. The available options are:
27962796
//
27972797
// context - Data bar direction is set by spreadsheet application based on the context of the data displayed.
27982798
// leftToRight - Data bar direction is from right to left.
@@ -2830,7 +2830,7 @@ func (f *File) SetCellStyle(sheet, topLeftCell, bottomRightCell string, styleID
28302830
//
28312831
// IconsOnly - Used for set displayed without the cell value.
28322832
//
2833-
// StopIfTrue - used to set the "stop if true" feature of a conditional
2833+
// StopIfTrue - Used to set the "stop if true" feature of a conditional
28342834
// formatting rule when more than one rule is applied to a cell or a range of
28352835
// cells. When this parameter is set then subsequent rules are not evaluated
28362836
// if the current rule is true.
@@ -3141,25 +3141,25 @@ func (f *File) extractCondFmtColorScale(c *xlsxCfRule, extLst *xlsxExtLst) Condi
31413141
if c.ColorScale.Cfvo[0].Val != "0" {
31423142
format.MinValue = c.ColorScale.Cfvo[0].Val
31433143
}
3144-
format.MinColor = "#" + f.getThemeColor(c.ColorScale.Color[0])
3144+
format.MinColor = f.getThemeColor(c.ColorScale.Color[0])
31453145
format.MaxType = c.ColorScale.Cfvo[1].Type
31463146
if c.ColorScale.Cfvo[1].Val != "0" {
31473147
format.MaxValue = c.ColorScale.Cfvo[1].Val
31483148
}
3149-
format.MaxColor = "#" + f.getThemeColor(c.ColorScale.Color[1])
3149+
format.MaxColor = f.getThemeColor(c.ColorScale.Color[1])
31503150
}
31513151
if colors == 3 && values > 2 {
31523152
format.Type = "3_color_scale"
31533153
format.MidType = c.ColorScale.Cfvo[1].Type
31543154
if c.ColorScale.Cfvo[1].Val != "0" {
31553155
format.MidValue = c.ColorScale.Cfvo[1].Val
31563156
}
3157-
format.MidColor = "#" + f.getThemeColor(c.ColorScale.Color[1])
3157+
format.MidColor = f.getThemeColor(c.ColorScale.Color[1])
31583158
format.MaxType = c.ColorScale.Cfvo[2].Type
31593159
if c.ColorScale.Cfvo[2].Val != "0" {
31603160
format.MaxValue = c.ColorScale.Cfvo[2].Val
31613161
}
3162-
format.MaxColor = "#" + f.getThemeColor(c.ColorScale.Color[2])
3162+
format.MaxColor = f.getThemeColor(c.ColorScale.Color[2])
31633163
}
31643164
return format
31653165
}
@@ -3175,7 +3175,7 @@ func (f *File) extractCondFmtDataBarRule(ID string, format *ConditionalFormatOpt
31753175
format.BarSolid = true
31763176
}
31773177
if rule.DataBar.BorderColor != nil {
3178-
format.BarBorderColor = "#" + f.getThemeColor(rule.DataBar.BorderColor)
3178+
format.BarBorderColor = f.getThemeColor(rule.DataBar.BorderColor)
31793179
}
31803180
}
31813181
}
@@ -3192,7 +3192,7 @@ func (f *File) extractCondFmtDataBar(c *xlsxCfRule, extLst *xlsxExtLst) Conditio
31923192
format.MinValue = c.DataBar.Cfvo[0].Val
31933193
format.MaxType = c.DataBar.Cfvo[1].Type
31943194
format.MaxValue = c.DataBar.Cfvo[1].Val
3195-
format.BarColor = "#" + f.getThemeColor(c.DataBar.Color[0])
3195+
format.BarColor = f.getThemeColor(c.DataBar.Color[0])
31963196
if c.DataBar.ShowValue != nil {
31973197
format.BarOnly = !*c.DataBar.ShowValue
31983198
}

styles_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func TestSetConditionalFormat(t *testing.T) {
172172
// Test creating a conditional format with a solid color data bar style
173173
f := NewFile()
174174
condFmts := []ConditionalFormatOptions{
175-
{Type: "data_bar", BarColor: "#A9D08E", BarSolid: true, Format: intPtr(0), Criteria: "=", MinType: "min", MaxType: "max"},
175+
{Type: "data_bar", BarColor: "A9D08E", BarSolid: true, Format: intPtr(0), Criteria: "=", MinType: "min", MaxType: "max"},
176176
}
177177
for _, ref := range []string{"A1:A2", "B1:B2"} {
178178
assert.NoError(t, f.SetConditionalFormat("Sheet1", ref, condFmts))
@@ -186,7 +186,7 @@ func TestSetConditionalFormat(t *testing.T) {
186186
ws, ok := f.Sheet.Load("xl/worksheets/sheet1.xml")
187187
assert.True(t, ok)
188188
ws.(*xlsxWorksheet).ExtLst = &xlsxExtLst{Ext: fmt.Sprintf(`<ext uri="%s"><x14:slicerList /></ext><ext uri="%s"><x14:sparklineGroups /></ext>`, ExtURISlicerListX14, ExtURISparklineGroups)}
189-
assert.NoError(t, f.SetConditionalFormat("Sheet1", "A1:A2", []ConditionalFormatOptions{{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarSolid: true}}))
189+
assert.NoError(t, f.SetConditionalFormat("Sheet1", "A1:A2", []ConditionalFormatOptions{{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "0000FF", BarColor: "638EC6", BarSolid: true}}))
190190
f = NewFile()
191191
// Test creating a conditional format with invalid extension list characters
192192
ws, ok = f.Sheet.Load("xl/worksheets/sheet1.xml")
@@ -202,9 +202,9 @@ func TestSetConditionalFormat(t *testing.T) {
202202
f := NewFile()
203203
var condFmts []ConditionalFormatOptions
204204
for _, color := range []string{
205-
"#264B96", // Blue
206-
"#F9A73E", // Yellow
207-
"#006F3C", // Green
205+
"264B96", // Blue
206+
"F9A73E", // Yellow
207+
"006F3C", // Green
208208
} {
209209
condFmts = append(condFmts, ConditionalFormatOptions{
210210
Type: "data_bar",
@@ -267,10 +267,10 @@ func TestGetConditionalFormats(t *testing.T) {
267267
{{Type: "average", AboveAverage: true, Format: &idx, Criteria: "="}},
268268
{{Type: "duplicate", Format: &idx, Criteria: "="}},
269269
{{Type: "unique", Format: &idx, Criteria: "="}},
270-
{{Type: "3_color_scale", Criteria: "=", MinType: "num", MidType: "num", MaxType: "num", MinValue: "-10", MidValue: "50", MaxValue: "10", MinColor: "#FF0000", MidColor: "#00FF00", MaxColor: "#0000FF"}},
271-
{{Type: "2_color_scale", Criteria: "=", MinType: "num", MaxType: "num", MinColor: "#FF0000", MaxColor: "#0000FF"}},
272-
{{Type: "data_bar", Criteria: "=", MinType: "num", MaxType: "num", MinValue: "-10", MaxValue: "10", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarOnly: true, BarSolid: true, StopIfTrue: true}},
273-
{{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarDirection: "rightToLeft", BarOnly: true, BarSolid: true, StopIfTrue: true}},
270+
{{Type: "3_color_scale", Criteria: "=", MinType: "num", MidType: "num", MaxType: "num", MinValue: "-10", MidValue: "50", MaxValue: "10", MinColor: "FF0000", MidColor: "00FF00", MaxColor: "0000FF"}},
271+
{{Type: "2_color_scale", Criteria: "=", MinType: "num", MaxType: "num", MinColor: "FF0000", MaxColor: "0000FF"}},
272+
{{Type: "data_bar", Criteria: "=", MinType: "num", MaxType: "num", MinValue: "-10", MaxValue: "10", BarBorderColor: "0000FF", BarColor: "638EC6", BarOnly: true, BarSolid: true, StopIfTrue: true}},
273+
{{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "0000FF", BarColor: "638EC6", BarDirection: "rightToLeft", BarOnly: true, BarSolid: true, StopIfTrue: true}},
274274
{{Type: "formula", Format: &idx, Criteria: "1"}},
275275
{{Type: "blanks", Format: &idx}},
276276
{{Type: "no_blanks", Format: &idx}},
@@ -312,8 +312,8 @@ func TestGetConditionalFormats(t *testing.T) {
312312
// Test get multiple conditional formats
313313
f = NewFile()
314314
expected := []ConditionalFormatOptions{
315-
{Type: "data_bar", Criteria: "=", MinType: "num", MaxType: "num", MinValue: "-10", MaxValue: "10", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarOnly: true, BarSolid: true, StopIfTrue: true},
316-
{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "#0000FF", BarColor: "#638EC6", BarDirection: "rightToLeft", BarOnly: true, BarSolid: false, StopIfTrue: true},
315+
{Type: "data_bar", Criteria: "=", MinType: "num", MaxType: "num", MinValue: "-10", MaxValue: "10", BarBorderColor: "0000FF", BarColor: "638EC6", BarOnly: true, BarSolid: true, StopIfTrue: true},
316+
{Type: "data_bar", Criteria: "=", MinType: "min", MaxType: "max", BarBorderColor: "0000FF", BarColor: "638EC6", BarDirection: "rightToLeft", BarOnly: true, BarSolid: false, StopIfTrue: true},
317317
}
318318
err = f.SetConditionalFormat("Sheet1", "A2:A1,B:B,2:2", expected)
319319
assert.NoError(t, err)

vml_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,13 +371,13 @@ func TestFormControl(t *testing.T) {
371371
assert.True(t, formControls[0].Paragraph[0].Font.Italic)
372372
// Test get form controls with font format
373373
f.DecodeVMLDrawing["xl/drawings/vmlDrawing1.vml"] = &decodeVmlDrawing{
374-
Shape: []decodeShape{{Type: "#_x0000_t201", Val: "<v:textbox><div><font face=\"Calibri\" size=\"280\" color=\"#777777\">Text</font></div></v:textbox><x:ClientData ObjectType=\"Scroll\"><x:Anchor>0,0,0,0,0,0,0,0</x:Anchor></x:ClientData>"}},
374+
Shape: []decodeShape{{Type: "#_x0000_t201", Val: "<v:textbox><div><font face=\"Calibri\" size=\"280\" color=\"777777\">Text</font></div></v:textbox><x:ClientData ObjectType=\"Scroll\"><x:Anchor>0,0,0,0,0,0,0,0</x:Anchor></x:ClientData>"}},
375375
}
376376
formControls, err = f.GetFormControls("Sheet1")
377377
assert.NoError(t, err)
378378
assert.Equal(t, "Calibri", formControls[0].Paragraph[0].Font.Family)
379379
assert.Equal(t, 14.0, formControls[0].Paragraph[0].Font.Size)
380-
assert.Equal(t, "#777777", formControls[0].Paragraph[0].Font.Color)
380+
assert.Equal(t, "777777", formControls[0].Paragraph[0].Font.Color)
381381
// Test get form controls with italic font format
382382
f.DecodeVMLDrawing["xl/drawings/vmlDrawing1.vml"] = &decodeVmlDrawing{
383383
Shape: []decodeShape{{Type: "#_x0000_t201", Val: "<v:textbox><div><font><i>Text</i></font></div></v:textbox><x:ClientData ObjectType=\"Scroll\"><x:Anchor>0,0,0,0,0,0,0,0</x:Anchor></x:ClientData>"}},

0 commit comments

Comments
 (0)