1 // Copyright 2016 - 2023 The excelize Authors. All rights reserved. Use of
2 // this source code is governed by a BSD-style license that can be found in
5 // Package excelize providing a set of functions that allow you to write to and
6 // read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and
7 // writing spreadsheet documents generated by Microsoft Excelâ„¢ 2007 and later.
8 // Supports complex components by high compatibility, and provided streaming
9 // API for generating or reading data from a worksheet with huge amounts of
10 // data. This library needs Go version 1.16 or later.
16 // xlsxTheme directly maps the theme element in the namespace
17 // http://schemas.openxmlformats.org/drawingml/2006/main
18 type xlsxTheme struct {
19 XMLName xml.Name `xml:"a:theme"`
20 XMLNSa string `xml:"xmlns:a,attr"`
21 XMLNSr string `xml:"xmlns:r,attr"`
22 Name string `xml:"name,attr"`
23 ThemeElements xlsxBaseStyles `xml:"a:themeElements"`
24 ObjectDefaults xlsxObjectDefaults `xml:"a:objectDefaults"`
25 ExtraClrSchemeLst xlsxExtraClrSchemeLst `xml:"a:extraClrSchemeLst"`
26 CustClrLst *xlsxInnerXML `xml:"a:custClrLst"`
27 ExtLst *xlsxExtLst `xml:"a:extLst"`
30 // xlsxBaseStyles defines the theme elements for a theme, and is the workhorse
31 // of the theme. The bulk of the shared theme information that is used by a
32 // given document is defined here. Within this complex type is defined a color
33 // scheme, a font scheme, and a style matrix (format scheme) that defines
34 // different formatting options for different pieces of a document.
35 type xlsxBaseStyles struct {
36 ClrScheme xlsxColorScheme `xml:"a:clrScheme"`
37 FontScheme xlsxFontScheme `xml:"a:fontScheme"`
38 FmtScheme xlsxStyleMatrix `xml:"a:fmtScheme"`
39 ExtLst *xlsxExtLst `xml:"a:extLst"`
42 // xlsxCTColor holds the actual color values that are to be applied to a given
43 // diagram and how those colors are to be applied.
44 type xlsxCTColor struct {
45 ScrgbClr *xlsxInnerXML `xml:"a:scrgbClr"`
46 SrgbClr *attrValString `xml:"a:srgbClr"`
47 HslClr *xlsxInnerXML `xml:"a:hslClr"`
48 SysClr *xlsxSysClr `xml:"a:sysClr"`
49 SchemeClr *xlsxInnerXML `xml:"a:schemeClr"`
50 PrstClr *xlsxInnerXML `xml:"a:prstClr"`
53 // xlsxColorScheme defines a set of colors for the theme. The set of colors
54 // consists of twelve color slots that can each hold a color of choice.
55 type xlsxColorScheme struct {
56 Name string `xml:"name,attr"`
57 Dk1 xlsxCTColor `xml:"a:dk1"`
58 Lt1 xlsxCTColor `xml:"a:lt1"`
59 Dk2 xlsxCTColor `xml:"a:dk2"`
60 Lt2 xlsxCTColor `xml:"a:lt2"`
61 Accent1 xlsxCTColor `xml:"a:accent1"`
62 Accent2 xlsxCTColor `xml:"a:accent2"`
63 Accent3 xlsxCTColor `xml:"a:accent3"`
64 Accent4 xlsxCTColor `xml:"a:accent4"`
65 Accent5 xlsxCTColor `xml:"a:accent5"`
66 Accent6 xlsxCTColor `xml:"a:accent6"`
67 Hlink xlsxCTColor `xml:"a:hlink"`
68 FolHlink xlsxCTColor `xml:"a:folHlink"`
69 ExtLst *xlsxExtLst `xml:"a:extLst"`
72 // objectDefaults element allows for the definition of default shape, line,
73 // and textbox formatting properties. An application can use this information
74 // to format a shape (or text) initially on insertion into a document.
75 type xlsxObjectDefaults struct {
76 ObjectDefaults string `xml:",innerxml"`
79 // xlsxExtraClrSchemeLst element is a container for the list of extra color
80 // schemes present in a document.
81 type xlsxExtraClrSchemeLst struct {
82 ExtraClrSchemeLst string `xml:",innerxml"`
85 // xlsxCTSupplementalFont defines an additional font that is used for language
86 // specific fonts in themes. For example, one can specify a font that gets used
87 // only within the Japanese language context.
88 type xlsxCTSupplementalFont struct {
89 Script string `xml:"script,attr"`
90 Typeface string `xml:"typeface,attr"`
93 // xlsxFontCollection defines a major and minor font which is used in the font
94 // scheme. A font collection consists of a font definition for Latin, East
95 // Asian, and complex script. On top of these three definitions, one can also
96 // define a font for use in a specific language or languages.
97 type xlsxFontCollection struct {
98 Latin *xlsxCTTextFont `xml:"a:latin"`
99 Ea *xlsxCTTextFont `xml:"a:ea"`
100 Cs *xlsxCTTextFont `xml:"a:cs"`
101 Font []xlsxCTSupplementalFont `xml:"a:font"`
102 ExtLst *xlsxExtLst `xml:"a:extLst"`
105 // xlsxFontScheme element defines the font scheme within the theme. The font
106 // scheme consists of a pair of major and minor fonts for which to use in a
107 // document. The major font corresponds well with the heading areas of a
108 // document, and the minor font corresponds well with the normal text or
110 type xlsxFontScheme struct {
111 Name string `xml:"name,attr"`
112 MajorFont xlsxFontCollection `xml:"a:majorFont"`
113 MinorFont xlsxFontCollection `xml:"a:minorFont"`
114 ExtLst *xlsxExtLst `xml:"a:extLst"`
117 // xlsxStyleMatrix defines a set of formatting options, which can be referenced
118 // by documents that apply a certain style to a given part of an object. For
119 // example, in a given shape, say a rectangle, one can reference a themed line
120 // style, themed effect, and themed fill that would be theme specific and
121 // change when the theme is changed.
122 type xlsxStyleMatrix struct {
123 Name string `xml:"name,attr,omitempty"`
124 FillStyleLst xlsxFillStyleLst `xml:"a:fillStyleLst"`
125 LnStyleLst xlsxLnStyleLst `xml:"a:lnStyleLst"`
126 EffectStyleLst xlsxEffectStyleLst `xml:"a:effectStyleLst"`
127 BgFillStyleLst xlsxBgFillStyleLst `xml:"a:bgFillStyleLst"`
130 // xlsxFillStyleLst element defines a set of three fill styles that are used
131 // within a theme. The three fill styles are arranged in order from subtle to
132 // moderate to intense.
133 type xlsxFillStyleLst struct {
134 FillStyleLst string `xml:",innerxml"`
137 // xlsxLnStyleLst element defines a list of three line styles for use within a
138 // theme. The three line styles are arranged in order from subtle to moderate
139 // to intense versions of lines. This list makes up part of the style matrix.
140 type xlsxLnStyleLst struct {
141 LnStyleLst string `xml:",innerxml"`
144 // xlsxEffectStyleLst element defines a set of three effect styles that create
145 // the effect style list for a theme. The effect styles are arranged in order
146 // of subtle to moderate to intense.
147 type xlsxEffectStyleLst struct {
148 EffectStyleLst string `xml:",innerxml"`
151 // xlsxBgFillStyleLst element defines a list of background fills that are
152 // used within a theme. The background fills consist of three fills, arranged
153 // in order from subtle to moderate to intense.
154 type xlsxBgFillStyleLst struct {
155 BgFillStyleLst string `xml:",innerxml"`
158 // xlsxSysClr element specifies a color bound to predefined operating system
160 type xlsxSysClr struct {
161 Val string `xml:"val,attr"`
162 LastClr string `xml:"lastClr,attr"`
165 // decodeTheme defines the structure used to parse the a:theme element for the
167 type decodeTheme struct {
168 XMLName xml.Name `xml:"http://schemas.openxmlformats.org/drawingml/2006/main theme"`
169 Name string `xml:"name,attr"`
170 ThemeElements decodeBaseStyles `xml:"themeElements"`
171 ObjectDefaults xlsxObjectDefaults `xml:"objectDefaults"`
172 ExtraClrSchemeLst xlsxExtraClrSchemeLst `xml:"extraClrSchemeLst"`
173 CustClrLst *xlsxInnerXML `xml:"custClrLst"`
174 ExtLst *xlsxExtLst `xml:"extLst"`
177 // decodeBaseStyles defines the structure used to parse the theme elements for a
178 // theme, and is the workhorse of the theme.
179 type decodeBaseStyles struct {
180 ClrScheme decodeColorScheme `xml:"clrScheme"`
181 FontScheme decodeFontScheme `xml:"fontScheme"`
182 FmtScheme decodeStyleMatrix `xml:"fmtScheme"`
183 ExtLst *xlsxExtLst `xml:"extLst"`
186 // decodeColorScheme defines the structure used to parse a set of colors for the
188 type decodeColorScheme struct {
189 Name string `xml:"name,attr"`
190 Dk1 decodeCTColor `xml:"dk1"`
191 Lt1 decodeCTColor `xml:"lt1"`
192 Dk2 decodeCTColor `xml:"dk2"`
193 Lt2 decodeCTColor `xml:"lt2"`
194 Accent1 decodeCTColor `xml:"accent1"`
195 Accent2 decodeCTColor `xml:"accent2"`
196 Accent3 decodeCTColor `xml:"accent3"`
197 Accent4 decodeCTColor `xml:"accent4"`
198 Accent5 decodeCTColor `xml:"accent5"`
199 Accent6 decodeCTColor `xml:"accent6"`
200 Hlink decodeCTColor `xml:"hlink"`
201 FolHlink decodeCTColor `xml:"folHlink"`
202 ExtLst *xlsxExtLst `xml:"extLst"`
205 // decodeFontScheme defines the structure used to parse font scheme within the
207 type decodeFontScheme struct {
208 Name string `xml:"name,attr"`
209 MajorFont decodeFontCollection `xml:"majorFont"`
210 MinorFont decodeFontCollection `xml:"minorFont"`
211 ExtLst *xlsxExtLst `xml:"extLst"`
214 // decodeFontCollection defines the structure used to parse a major and minor
215 // font which is used in the font scheme.
216 type decodeFontCollection struct {
217 Latin *xlsxCTTextFont `xml:"latin"`
218 Ea *xlsxCTTextFont `xml:"ea"`
219 Cs *xlsxCTTextFont `xml:"cs"`
220 Font []xlsxCTSupplementalFont `xml:"font"`
221 ExtLst *xlsxExtLst `xml:"extLst"`
224 // decodeCTColor defines the structure used to parse the actual color values
225 // that are to be applied to a given diagram and how those colors are to be
227 type decodeCTColor struct {
228 ScrgbClr *xlsxInnerXML `xml:"scrgbClr"`
229 SrgbClr *attrValString `xml:"srgbClr"`
230 HslClr *xlsxInnerXML `xml:"hslClr"`
231 SysClr *xlsxSysClr `xml:"sysClr"`
232 SchemeClr *xlsxInnerXML `xml:"schemeClr"`
233 PrstClr *xlsxInnerXML `xml:"prstClr"`
236 // decodeStyleMatrix defines the structure used to parse a set of formatting
237 // options, which can be referenced by documents that apply a certain style to
238 // a given part of an object.
239 type decodeStyleMatrix struct {
240 Name string `xml:"name,attr,omitempty"`
241 FillStyleLst xlsxFillStyleLst `xml:"fillStyleLst"`
242 LnStyleLst xlsxLnStyleLst `xml:"lnStyleLst"`
243 EffectStyleLst xlsxEffectStyleLst `xml:"effectStyleLst"`
244 BgFillStyleLst xlsxBgFillStyleLst `xml:"bgFillStyleLst"`