value fields xlsxPatternFill.FgColor & xlsxPatternFill.BgColor cause … (#770)

* value fields xlsxPatternFill.FgColor & xlsxPatternFill.BgColor cause ineffective omitempty tags

* remove useless omitempty tag on xlsxPatternFill.FgColor and xlsxPatternFill.BgColor
This commit is contained in:
Eagle Xiang 2021-01-28 21:13:23 +08:00 committed by GitHub
parent b84bd1abc0
commit 219add2f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -2432,8 +2432,14 @@ func newFills(style *Style, fg bool) *xlsxFill {
var pattern xlsxPatternFill
pattern.PatternType = patterns[style.Fill.Pattern]
if fg {
if pattern.FgColor == nil {
pattern.FgColor = new(xlsxColor)
}
pattern.FgColor.RGB = getPaletteColor(style.Fill.Color[0])
} else {
if pattern.BgColor == nil {
pattern.BgColor = new(xlsxColor)
}
pattern.BgColor.RGB = getPaletteColor(style.Fill.Color[0])
}
fill.PatternFill = &pattern

View File

@ -121,8 +121,8 @@ type xlsxFill struct {
// specified by the bgColor element.
type xlsxPatternFill struct {
PatternType string `xml:"patternType,attr,omitempty"`
FgColor xlsxColor `xml:"fgColor,omitempty"`
BgColor xlsxColor `xml:"bgColor,omitempty"`
FgColor *xlsxColor `xml:"fgColor"`
BgColor *xlsxColor `xml:"bgColor"`
}
// xlsxGradientFill defines a gradient-style cell fill. Gradient cell fills can