From 236ee61d201e45b1fe33a58b290adb7ee32d3488 Mon Sep 17 00:00:00 2001
From: xuri <xuri.me@gmail.com>
Date: Sat, 15 Jan 2022 00:06:34 +0800
Subject: This closes #1119, style parsing issue fixed

---
 lib.go              |  2 ++
 xmlDecodeDrawing.go |  2 +-
 xmlStyles.go        | 62 ++++++++++++++++++++++++++---------------------------
 xmlWorksheet.go     | 12 +++++------
 4 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/lib.go b/lib.go
index c125da6..caaeab2 100644
--- a/lib.go
+++ b/lib.go
@@ -473,6 +473,8 @@ func (avb *attrValBool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) err
 			return nil
 		}
 	}
+	defaultVal := true
+	avb.Val = &defaultVal
 	return nil
 }
 
diff --git a/xmlDecodeDrawing.go b/xmlDecodeDrawing.go
index ad0b751..0ca63d1 100644
--- a/xmlDecodeDrawing.go
+++ b/xmlDecodeDrawing.go
@@ -78,7 +78,7 @@ type decodeWsDr struct {
 type decodeTwoCellAnchor struct {
 	From       *decodeFrom       `xml:"from"`
 	To         *decodeTo         `xml:"to"`
-	Pic        *decodePic        `xml:"pic,omitempty"`
+	Pic        *decodePic        `xml:"pic"`
 	ClientData *decodeClientData `xml:"clientData"`
 }
 
diff --git a/xmlStyles.go b/xmlStyles.go
index d6fc43d..a9c3f3b 100644
--- a/xmlStyles.go
+++ b/xmlStyles.go
@@ -20,16 +20,16 @@ import (
 type xlsxStyleSheet struct {
 	sync.Mutex
 	XMLName      xml.Name          `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main styleSheet"`
-	NumFmts      *xlsxNumFmts      `xml:"numFmts,omitempty"`
-	Fonts        *xlsxFonts        `xml:"fonts,omitempty"`
-	Fills        *xlsxFills        `xml:"fills,omitempty"`
-	Borders      *xlsxBorders      `xml:"borders,omitempty"`
-	CellStyleXfs *xlsxCellStyleXfs `xml:"cellStyleXfs,omitempty"`
-	CellXfs      *xlsxCellXfs      `xml:"cellXfs,omitempty"`
-	CellStyles   *xlsxCellStyles   `xml:"cellStyles,omitempty"`
-	Dxfs         *xlsxDxfs         `xml:"dxfs,omitempty"`
-	TableStyles  *xlsxTableStyles  `xml:"tableStyles,omitempty"`
-	Colors       *xlsxStyleColors  `xml:"colors,omitempty"`
+	NumFmts      *xlsxNumFmts      `xml:"numFmts"`
+	Fonts        *xlsxFonts        `xml:"fonts"`
+	Fills        *xlsxFills        `xml:"fills"`
+	Borders      *xlsxBorders      `xml:"borders"`
+	CellStyleXfs *xlsxCellStyleXfs `xml:"cellStyleXfs"`
+	CellXfs      *xlsxCellXfs      `xml:"cellXfs"`
+	CellStyles   *xlsxCellStyles   `xml:"cellStyles"`
+	Dxfs         *xlsxDxfs         `xml:"dxfs"`
+	TableStyles  *xlsxTableStyles  `xml:"tableStyles"`
+	Colors       *xlsxStyleColors  `xml:"colors"`
 	ExtLst       *xlsxExtLst       `xml:"extLst"`
 }
 
@@ -60,7 +60,7 @@ type xlsxProtection struct {
 // xlsxLine expresses a single set of cell border.
 type xlsxLine struct {
 	Style string     `xml:"style,attr,omitempty"`
-	Color *xlsxColor `xml:"color,omitempty"`
+	Color *xlsxColor `xml:"color"`
 }
 
 // xlsxColor is a common mapping used for both the fgColor and bgColor elements.
@@ -87,13 +87,13 @@ type xlsxFonts struct {
 // xlsxFont directly maps the font element. This element defines the
 // properties for one of the fonts used in this workbook.
 type xlsxFont struct {
-	B        *attrValBool   `xml:"b,omitempty"`
-	I        *attrValBool   `xml:"i,omitempty"`
-	Strike   *attrValBool   `xml:"strike,omitempty"`
-	Outline  *attrValBool   `xml:"outline,omitempty"`
-	Shadow   *attrValBool   `xml:"shadow,omitempty"`
-	Condense *attrValBool   `xml:"condense,omitempty"`
-	Extend   *attrValBool   `xml:"extend,omitempty"`
+	B        *attrValBool   `xml:"b"`
+	I        *attrValBool   `xml:"i"`
+	Strike   *attrValBool   `xml:"strike"`
+	Outline  *attrValBool   `xml:"outline"`
+	Shadow   *attrValBool   `xml:"shadow"`
+	Condense *attrValBool   `xml:"condense"`
+	Extend   *attrValBool   `xml:"extend"`
 	U        *attrValString `xml:"u"`
 	Sz       *attrValFloat  `xml:"sz"`
 	Color    *xlsxColor     `xml:"color"`
@@ -109,14 +109,14 @@ type xlsxFont struct {
 // applied across the cell.
 type xlsxFills struct {
 	Count int         `xml:"count,attr"`
-	Fill  []*xlsxFill `xml:"fill,omitempty"`
+	Fill  []*xlsxFill `xml:"fill"`
 }
 
 // xlsxFill directly maps the fill element. This element specifies fill
 // formatting.
 type xlsxFill struct {
-	PatternFill  *xlsxPatternFill  `xml:"patternFill,omitempty"`
-	GradientFill *xlsxGradientFill `xml:"gradientFill,omitempty"`
+	PatternFill  *xlsxPatternFill  `xml:"patternFill"`
+	GradientFill *xlsxGradientFill `xml:"gradientFill"`
 }
 
 // xlsxPatternFill is used to specify cell fill information for pattern and
@@ -138,7 +138,7 @@ type xlsxGradientFill struct {
 	Right  float64                 `xml:"right,attr,omitempty"`
 	Top    float64                 `xml:"top,attr,omitempty"`
 	Type   string                  `xml:"type,attr,omitempty"`
-	Stop   []*xlsxGradientFillStop `xml:"stop,omitempty"`
+	Stop   []*xlsxGradientFillStop `xml:"stop"`
 }
 
 // xlsxGradientFillStop directly maps the stop element.
@@ -152,7 +152,7 @@ type xlsxGradientFillStop struct {
 // the workbook.
 type xlsxBorders struct {
 	Count  int           `xml:"count,attr"`
-	Border []*xlsxBorder `xml:"border,omitempty"`
+	Border []*xlsxBorder `xml:"border"`
 }
 
 // xlsxBorder directly maps the border element. Expresses a single set of cell
@@ -177,7 +177,7 @@ type xlsxBorder struct {
 type xlsxCellStyles struct {
 	XMLName   xml.Name         `xml:"cellStyles"`
 	Count     int              `xml:"count,attr"`
-	CellStyle []*xlsxCellStyle `xml:"cellStyle,omitempty"`
+	CellStyle []*xlsxCellStyle `xml:"cellStyle"`
 }
 
 // xlsxCellStyle directly maps the cellStyle element. This element represents
@@ -187,10 +187,10 @@ type xlsxCellStyle struct {
 	XMLName       xml.Name `xml:"cellStyle"`
 	Name          string   `xml:"name,attr"`
 	XfID          int      `xml:"xfId,attr"`
-	BuiltInID     *int     `xml:"builtinId,attr,omitempty"`
-	ILevel        *int     `xml:"iLevel,attr,omitempty"`
-	Hidden        *bool    `xml:"hidden,attr,omitempty"`
-	CustomBuiltIn *bool    `xml:"customBuiltin,attr,omitempty"`
+	BuiltInID     *int     `xml:"builtinId,attr"`
+	ILevel        *int     `xml:"iLevel,attr"`
+	Hidden        *bool    `xml:"hidden,attr"`
+	CustomBuiltIn *bool    `xml:"customBuiltin,attr"`
 }
 
 // xlsxCellStyleXfs directly maps the cellStyleXfs element. This element
@@ -245,7 +245,7 @@ type xlsxCellXfs struct {
 // to any formatting already present on the object using the dxf record.
 type xlsxDxfs struct {
 	Count int        `xml:"count,attr"`
-	Dxfs  []*xlsxDxf `xml:"dxf,omitempty"`
+	Dxfs  []*xlsxDxf `xml:"dxf"`
 }
 
 // xlsxDxf directly maps the dxf element. A single dxf record, expressing
@@ -273,7 +273,7 @@ type xlsxTableStyles struct {
 	Count             int               `xml:"count,attr"`
 	DefaultPivotStyle string            `xml:"defaultPivotStyle,attr"`
 	DefaultTableStyle string            `xml:"defaultTableStyle,attr"`
-	TableStyles       []*xlsxTableStyle `xml:"tableStyle,omitempty"`
+	TableStyles       []*xlsxTableStyle `xml:"tableStyle"`
 }
 
 // xlsxTableStyle directly maps the tableStyle element. This element represents
@@ -293,7 +293,7 @@ type xlsxTableStyle struct {
 // to format and render the numeric value of a cell.
 type xlsxNumFmts struct {
 	Count  int           `xml:"count,attr"`
-	NumFmt []*xlsxNumFmt `xml:"numFmt,omitempty"`
+	NumFmt []*xlsxNumFmt `xml:"numFmt"`
 }
 
 // xlsxNumFmt directly maps the numFmt element. This element specifies number
diff --git a/xmlWorksheet.go b/xmlWorksheet.go
index 649377b..76c6188 100644
--- a/xmlWorksheet.go
+++ b/xmlWorksheet.go
@@ -113,15 +113,15 @@ type xlsxPageSetUp struct {
 	Errors             string   `xml:"errors,attr,omitempty"`
 	FirstPageNumber    string   `xml:"firstPageNumber,attr,omitempty"`
 	FitToHeight        *int     `xml:"fitToHeight,attr"`
-	FitToWidth         *int     `xml:"fitToWidth,attr,omitempty"`
+	FitToWidth         *int     `xml:"fitToWidth,attr"`
 	HorizontalDPI      int      `xml:"horizontalDpi,attr,omitempty"`
 	RID                string   `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
 	Orientation        string   `xml:"orientation,attr,omitempty"`
 	PageOrder          string   `xml:"pageOrder,attr,omitempty"`
 	PaperHeight        string   `xml:"paperHeight,attr,omitempty"`
-	PaperSize          *int     `xml:"paperSize,attr,omitempty"`
+	PaperSize          *int     `xml:"paperSize,attr"`
 	PaperWidth         string   `xml:"paperWidth,attr,omitempty"`
-	Scale              int      `xml:"scale,attr"`
+	Scale              int      `xml:"scale,attr,omitempty"`
 	UseFirstPageNumber bool     `xml:"useFirstPageNumber,attr,omitempty"`
 	UsePrinterDefaults bool     `xml:"usePrinterDefaults,attr,omitempty"`
 	VerticalDPI        int      `xml:"verticalDpi,attr,omitempty"`
@@ -239,9 +239,9 @@ type xlsxSheetPr struct {
 	CodeName                          string           `xml:"codeName,attr,omitempty"`
 	FilterMode                        bool             `xml:"filterMode,attr,omitempty"`
 	EnableFormatConditionsCalculation *bool            `xml:"enableFormatConditionsCalculation,attr"`
-	TabColor                          *xlsxTabColor    `xml:"tabColor,omitempty"`
-	OutlinePr                         *xlsxOutlinePr   `xml:"outlinePr,omitempty"`
-	PageSetUpPr                       *xlsxPageSetUpPr `xml:"pageSetUpPr,omitempty"`
+	TabColor                          *xlsxTabColor    `xml:"tabColor"`
+	OutlinePr                         *xlsxOutlinePr   `xml:"outlinePr"`
+	PageSetUpPr                       *xlsxPageSetUpPr `xml:"pageSetUpPr"`
 }
 
 // xlsxOutlinePr maps to the outlinePr element. SummaryBelow allows you to
-- 
cgit v1.2.1