From f91f548614a7182ce66d55d10ed311e9b7e08a2a Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 17 May 2019 22:58:12 +0800 Subject: Resolve #404, get sheet map by target rels. --- xmlStyles.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index fc53f77..5c198e7 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -82,8 +82,9 @@ 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 { Name *attrValString `xml:"name"` Charset *attrValInt `xml:"charset"` Family *attrValInt `xml:"family"` @@ -100,12 +101,6 @@ type font struct { 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 @@ -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"` -- cgit v1.2.1 From 3997dee1f58c81444733e1756da6138d4ce445f1 Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 7 Jun 2019 09:16:55 +0800 Subject: Fix #411, change font size to float type --- xmlStyles.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) mode change 100644 => 100755 xmlStyles.go (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go old mode 100644 new mode 100755 index 5c198e7..46587da --- a/xmlStyles.go +++ b/xmlStyles.go @@ -96,7 +96,7 @@ type xlsxFont struct { Condense bool `xml:"condense,omitempty"` Extend bool `xml:"extend,omitempty"` Color *xlsxColor `xml:"color"` - Sz *attrValInt `xml:"sz"` + Sz *attrValFloat `xml:"sz"` U *attrValString `xml:"u"` Scheme *attrValString `xml:"scheme"` } @@ -315,12 +315,12 @@ type xlsxStyleColors struct { // 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"` + Bold bool `json:"bold"` + Italic bool `json:"italic"` + Underline string `json:"underline"` + Family string `json:"family"` + Size float64 `json:"size"` + Color string `json:"color"` } // formatStyle directly maps the styles settings of the cells. -- cgit v1.2.1 From 421f945f51f254054991127758db0520cf0f5456 Mon Sep 17 00:00:00 2001 From: xuri Date: Sat, 8 Jun 2019 00:00:55 +0800 Subject: Fixed #418, #420, #421, init adjust calculation chain support Update testing case --- xmlStyles.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index 46587da..49abe3c 100755 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -88,13 +88,13 @@ type xlsxFont struct { 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"` + 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 *attrValFloat `xml:"sz"` U *attrValString `xml:"u"` -- cgit v1.2.1 From 821632cf89422b9955160a3af7f28f05a12f70f8 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 12 Jun 2019 08:10:33 +0800 Subject: Fix #424, refactor merged cells adjuster --- xmlStyles.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 xmlStyles.go (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go old mode 100755 new mode 100644 -- cgit v1.2.1 From 9c70d0ac868f66badf2663cc7b4b3c46d5411131 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 11 Aug 2019 00:36:14 +0800 Subject: Documentation updated, Go 1.10+ required --- xmlStyles.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index 49abe3c..5823bc9 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -5,7 +5,7 @@ // 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 -- cgit v1.2.1 From 75d66a03f33f25c29167c5f75ee8a4cc58598420 Mon Sep 17 00:00:00 2001 From: xuri Date: Mon, 23 Sep 2019 21:50:03 +0800 Subject: Fix #482, font strike style support --- xmlStyles.go | 1 + 1 file changed, 1 insertion(+) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index 5823bc9..7e02d6e 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -320,6 +320,7 @@ type formatFont struct { Underline string `json:"underline"` Family string `json:"family"` Size float64 `json:"size"` + Strike bool `json:"strike"` Color string `json:"color"` } -- cgit v1.2.1 From a34d3b8c86d67d3ad0bc0dbedb69d3b4ebbc210f Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 24 Sep 2019 21:53:19 +0800 Subject: Compatibility improvement --- xmlStyles.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index 7e02d6e..16a89ab 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -85,9 +85,6 @@ 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 { - 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"` @@ -95,9 +92,12 @@ type xlsxFont struct { Shadow *bool `xml:"shadow,omitempty"` Condense *bool `xml:"condense,omitempty"` Extend *bool `xml:"extend,omitempty"` - Color *xlsxColor `xml:"color"` - Sz *attrValFloat `xml:"sz"` U *attrValString `xml:"u"` + Sz *attrValFloat `xml:"sz"` + Color *xlsxColor `xml:"color"` + Name *attrValString `xml:"name"` + Family *attrValInt `xml:"family"` + Charset *attrValInt `xml:"charset"` Scheme *attrValString `xml:"scheme"` } -- cgit v1.2.1 From 09485b3f9f0aefc58d51462aed65c2416205c591 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 29 Dec 2019 16:02:31 +0800 Subject: Improve code coverage unit tests --- xmlStyles.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index 16a89ab..0313008 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -1,4 +1,4 @@ -// 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. // -- cgit v1.2.1 From 9e2318cefa4ebaa7bf6b1dbc95b30ad7a32366b1 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 10 Mar 2020 00:04:23 +0800 Subject: Resolve #470, export Style structs to allow create the style for cells by given JSON or structure --- xmlStyles.go | 84 ++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 36 deletions(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index 0313008..d6aa4f9 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -313,8 +313,28 @@ type xlsxStyleColors struct { Color string `xml:",innerxml"` } -// formatFont directly maps the styles settings of the fonts. -type formatFont struct { +// 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"` @@ -324,38 +344,30 @@ type formatFont struct { 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"` +// 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"` } -- cgit v1.2.1 From 1f73a19e0f3bff9869e333675957dd5c027d0ab9 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 6 May 2020 00:32:53 +0800 Subject: Resolve #628, omit number format empty --- xmlStyles.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index d6aa4f9..b5ec41d 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -186,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 @@ -209,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"` + NumFmtID int `xml:"numFmtId,attr,omitempty"` + FontID int `xml:"fontId,attr,omitempty"` + FillID int `xml:"fillId,attr,omitempty"` + BorderID int `xml:"borderId,attr,omitempty"` + XfID *int `xml:"xfId,attr,omitempty"` QuotePrefix bool `xml:"quotePrefix,attr,omitempty"` - XfID *int `xml:"xfId,attr"` + PivotButton bool `xml:"pivotButton,attr,omitempty"` + ApplyNumberFormat bool `xml:"applyNumberFormat,attr,omitempty"` + ApplyFont bool `xml:"applyFont,attr,omitempty"` + ApplyFill bool `xml:"applyFill,attr,omitempty"` + ApplyBorder bool `xml:"applyBorder,attr,omitempty"` + ApplyAlignment bool `xml:"applyAlignment,attr,omitempty"` + ApplyProtection bool `xml:"applyProtection,attr,omitempty"` Alignment *xlsxAlignment `xml:"alignment"` Protection *xlsxProtection `xml:"protection"` } -- cgit v1.2.1 From 882abb80988b7c50286dd2e6c6589fab10662db6 Mon Sep 17 00:00:00 2001 From: xuri Date: Sun, 10 May 2020 16:56:08 +0800 Subject: - formula engine: reduce cyclomatic complexity - styles: allow empty and default cell formats, #628 --- xmlStyles.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'xmlStyles.go') diff --git a/xmlStyles.go b/xmlStyles.go index b5ec41d..42d535b 100644 --- a/xmlStyles.go +++ b/xmlStyles.go @@ -209,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 { - NumFmtID int `xml:"numFmtId,attr,omitempty"` - FontID int `xml:"fontId,attr,omitempty"` - FillID int `xml:"fillId,attr,omitempty"` - BorderID int `xml:"borderId,attr,omitempty"` - XfID *int `xml:"xfId,attr,omitempty"` - QuotePrefix bool `xml:"quotePrefix,attr,omitempty"` - PivotButton bool `xml:"pivotButton,attr,omitempty"` - ApplyNumberFormat bool `xml:"applyNumberFormat,attr,omitempty"` - ApplyFont bool `xml:"applyFont,attr,omitempty"` - ApplyFill bool `xml:"applyFill,attr,omitempty"` - ApplyBorder bool `xml:"applyBorder,attr,omitempty"` - ApplyAlignment bool `xml:"applyAlignment,attr,omitempty"` - ApplyProtection bool `xml:"applyProtection,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"` } -- cgit v1.2.1