Skip to content

Commit 8d26cbd

Browse files
committed
This closes #2384, fix GetStyle returning invalid style for fills without a pattern
- Upgrade the dependencies package version
1 parent 744cdc0 commit 8d26cbd

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

styles.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,9 @@ func (f *File) extractGradientFill(gf *xlsxGradientFill, fill *Fill) {
15561556
// settings by given pattern fill definition.
15571557
func (f *File) extractPatternFill(pf *xlsxPatternFill, fill *Fill) {
15581558
fill.Type = "pattern"
1559-
fill.Pattern = inStrSlice(styleFillPatterns, pf.PatternType, false)
1559+
if pattern := inStrSlice(styleFillPatterns, pf.PatternType, false); pattern != -1 {
1560+
fill.Pattern = pattern
1561+
}
15601562
if pf.BgColor != nil && !pf.BgColor.Auto {
15611563
fill.Color = []string{f.getThemeColor(pf.BgColor)}
15621564
}

styles_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,4 +936,12 @@ func TestGetStyle(t *testing.T) {
936936
assert.NoError(t, f.Close(), testCase.label)
937937
}
938938
})
939+
t.Run("without_fill_pattern", func(t *testing.T) {
940+
f := NewFile()
941+
f.Styles = nil
942+
f.Pkg.Store(defaultXMLPathStyles, fmt.Appendf(nil, `<styleSheet xmlns="%s"><fills count="1"><fill><patternFill/></fill></fills><cellXfs count="1"><xf fillId="0"></xf></cellXfs></styleSheet>`, NameSpaceSpreadSheet.Value))
943+
style, err := f.GetStyle(0)
944+
assert.NoError(t, err)
945+
assert.Zero(t, style.Fill.Pattern)
946+
})
939947
}

0 commit comments

Comments
 (0)