From 5dd00b9a004d5a7bc867ed09387cbd88fed240e4 Mon Sep 17 00:00:00 2001 From: "Michael W. Mitton" Date: Wed, 9 Jan 2019 10:12:53 -0500 Subject: Do not create a blank fill if no fill is specified in the style format --- styles.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'styles.go') diff --git a/styles.go b/styles.go index d075266..7ffc8ff 100644 --- a/styles.go +++ b/styles.go @@ -1907,9 +1907,11 @@ func (f *File) NewStyle(style string) (int, error) { s.Borders.Border = append(s.Borders.Border, setBorders(fs)) borderID = s.Borders.Count - 1 - s.Fills.Count++ - s.Fills.Fill = append(s.Fills.Fill, setFills(fs, true)) - fillID = s.Fills.Count - 1 + if fill := setFills(fs, true); fill != nil { + s.Fills.Count++ + s.Fills.Fill = append(s.Fills.Fill, fill) + fillID = s.Fills.Count - 1 + } applyAlignment, alignment := fs.Alignment != nil, setAlignment(fs) applyProtection, protection := fs.Protection != nil, setProtection(fs) @@ -2145,6 +2147,8 @@ func setFills(formatStyle *formatStyle, fg bool) *xlsxFill { pattern.BgColor.RGB = getPaletteColor(formatStyle.Fill.Color[0]) } fill.PatternFill = &pattern + default: + return nil } return &fill } -- cgit v1.2.1