diff options
Diffstat (limited to 'xmlStyles.go')
-rw-r--r-- | xmlStyles.go | 172 |
1 files changed, 90 insertions, 82 deletions
diff --git a/xmlStyles.go b/xmlStyles.go index fc53f77..42d535b 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -1,11 +1,11 @@ -// Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of +// Copyright 2016 - 2020 The excelize Authors. All rights reserved. Use of // this source code is governed by a BSD-style license that can be found in // the LICENSE file. // // Package excelize providing a set of functions that allow you to write to // and read from XLSX files. Support reads and writes XLSX file generated by // Microsoft Excelâ„¢ 2007 and later. Support save file without losing original -// charts of XLSX. This library needs Go version 1.8 or later. +// charts of XLSX. This library needs Go version 1.10 or later. package excelize @@ -82,30 +82,25 @@ type xlsxFonts struct { Font []*xlsxFont `xml:"font"` } -// font directly maps the font element. -type font 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 *bool `xml:"b,omitempty"` + I *bool `xml:"i,omitempty"` + Strike *bool `xml:"strike,omitempty"` + Outline *bool `xml:"outline,omitempty"` + Shadow *bool `xml:"shadow,omitempty"` + Condense *bool `xml:"condense,omitempty"` + Extend *bool `xml:"extend,omitempty"` + U *attrValString `xml:"u"` + Sz *attrValFloat `xml:"sz"` + Color *xlsxColor `xml:"color"` Name *attrValString `xml:"name"` - Charset *attrValInt `xml:"charset"` Family *attrValInt `xml:"family"` - B bool `xml:"b,omitempty"` - I bool `xml:"i,omitempty"` - Strike bool `xml:"strike,omitempty"` - Outline bool `xml:"outline,omitempty"` - Shadow bool `xml:"shadow,omitempty"` - Condense bool `xml:"condense,omitempty"` - Extend bool `xml:"extend,omitempty"` - Color *xlsxColor `xml:"color"` - Sz *attrValInt `xml:"sz"` - U *attrValString `xml:"u"` + Charset *attrValInt `xml:"charset"` Scheme *attrValString `xml:"scheme"` } -// xlsxFont directly maps the font element. This element defines the properties -// for one of the fonts used in this workbook. -type xlsxFont struct { - Font string `xml:",innerxml"` -} - // xlsxFills directly maps the fills element. This element defines the cell // fills portion of the Styles part, consisting of a sequence of fill records. A // cell fill consists of a background color, foreground color, and pattern to be @@ -191,12 +186,12 @@ type xlsxCellStyles struct { // workbook. type xlsxCellStyle struct { XMLName xml.Name `xml:"cellStyle"` - BuiltInID *int `xml:"builtinId,attr,omitempty"` - CustomBuiltIn *bool `xml:"customBuiltin,attr,omitempty"` - Hidden *bool `xml:"hidden,attr,omitempty"` - ILevel *bool `xml:"iLevel,attr,omitempty"` 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"` } // xlsxCellStyleXfs directly maps the cellStyleXfs element. This element @@ -214,19 +209,19 @@ type xlsxCellStyleXfs struct { // xlsxXf directly maps the xf element. A single xf element describes all of the // formatting for a cell. type xlsxXf struct { - ApplyAlignment bool `xml:"applyAlignment,attr"` - ApplyBorder bool `xml:"applyBorder,attr"` - ApplyFill bool `xml:"applyFill,attr"` - ApplyFont bool `xml:"applyFont,attr"` - ApplyNumberFormat bool `xml:"applyNumberFormat,attr"` - ApplyProtection bool `xml:"applyProtection,attr"` - BorderID int `xml:"borderId,attr"` - FillID int `xml:"fillId,attr"` - FontID int `xml:"fontId,attr"` - NumFmtID int `xml:"numFmtId,attr"` - PivotButton bool `xml:"pivotButton,attr,omitempty"` - QuotePrefix bool `xml:"quotePrefix,attr,omitempty"` + NumFmtID *int `xml:"numFmtId,attr"` + FontID *int `xml:"fontId,attr"` + FillID *int `xml:"fillId,attr"` + BorderID *int `xml:"borderId,attr"` XfID *int `xml:"xfId,attr"` + QuotePrefix *bool `xml:"quotePrefix,attr"` + PivotButton *bool `xml:"pivotButton,attr"` + ApplyNumberFormat *bool `xml:"applyNumberFormat,attr"` + ApplyFont *bool `xml:"applyFont,attr"` + ApplyFill *bool `xml:"applyFill,attr"` + ApplyBorder *bool `xml:"applyBorder,attr"` + ApplyAlignment *bool `xml:"applyAlignment,attr"` + ApplyProtection *bool `xml:"applyProtection,attr"` Alignment *xlsxAlignment `xml:"alignment"` Protection *xlsxProtection `xml:"protection"` } @@ -262,7 +257,7 @@ type xlsxDxf struct { // dxf directly maps the dxf element. type dxf struct { - Font *font `xml:"font"` + Font *xlsxFont `xml:"font"` NumFmt *xlsxNumFmt `xml:"numFmt"` Fill *xlsxFill `xml:"fill"` Alignment *xlsxAlignment `xml:"alignment"` @@ -318,48 +313,61 @@ type xlsxStyleColors struct { Color string `xml:",innerxml"` } -// formatFont directly maps the styles settings of the fonts. -type formatFont struct { - Bold bool `json:"bold"` - Italic bool `json:"italic"` - Underline string `json:"underline"` - Family string `json:"family"` - Size int `json:"size"` - Color string `json:"color"` -} - -// formatStyle directly maps the styles settings of the cells. -type formatStyle struct { - Border []struct { - Type string `json:"type"` - Color string `json:"color"` - Style int `json:"style"` - } `json:"border"` - Fill struct { - Type string `json:"type"` - Pattern int `json:"pattern"` - Color []string `json:"color"` - Shading int `json:"shading"` - } `json:"fill"` - Font *formatFont `json:"font"` - Alignment *struct { - Horizontal string `json:"horizontal"` - Indent int `json:"indent"` - JustifyLastLine bool `json:"justify_last_line"` - ReadingOrder uint64 `json:"reading_order"` - RelativeIndent int `json:"relative_indent"` - ShrinkToFit bool `json:"shrink_to_fit"` - TextRotation int `json:"text_rotation"` - Vertical string `json:"vertical"` - WrapText bool `json:"wrap_text"` - } `json:"alignment"` - Protection *struct { - Hidden bool `json:"hidden"` - Locked bool `json:"locked"` - } `json:"protection"` - NumFmt int `json:"number_format"` - DecimalPlaces int `json:"decimal_places"` - CustomNumFmt *string `json:"custom_number_format"` - Lang string `json:"lang"` - NegRed bool `json:"negred"` +// Alignment directly maps the alignment settings of the cells. +type Alignment struct { + Horizontal string `json:"horizontal"` + Indent int `json:"indent"` + JustifyLastLine bool `json:"justify_last_line"` + ReadingOrder uint64 `json:"reading_order"` + RelativeIndent int `json:"relative_indent"` + ShrinkToFit bool `json:"shrink_to_fit"` + TextRotation int `json:"text_rotation"` + Vertical string `json:"vertical"` + WrapText bool `json:"wrap_text"` +} + +// Border directly maps the border settings of the cells. +type Border struct { + Type string `json:"type"` + Color string `json:"color"` + Style int `json:"style"` +} + +// Font directly maps the font settings of the fonts. +type Font struct { + Bold bool `json:"bold"` + Italic bool `json:"italic"` + Underline string `json:"underline"` + Family string `json:"family"` + Size float64 `json:"size"` + Strike bool `json:"strike"` + Color string `json:"color"` +} + +// Fill directly maps the fill settings of the cells. +type Fill struct { + Type string `json:"type"` + Pattern int `json:"pattern"` + Color []string `json:"color"` + Shading int `json:"shading"` +} + +// Protection directly maps the protection settings of the cells. +type Protection struct { + Hidden bool `json:"hidden"` + Locked bool `json:"locked"` +} + +// Style directly maps the style settings of the cells. +type Style struct { + Border []Border `json:"border"` + Fill Fill `json:"fill"` + Font *Font `json:"font"` + Alignment *Alignment `json:"alignment"` + Protection *Protection `json:"protection"` + NumFmt int `json:"number_format"` + DecimalPlaces int `json:"decimal_places"` + CustomNumFmt *string `json:"custom_number_format"` + Lang string `json:"lang"` + NegRed bool `json:"negred"` } |