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.
19 // xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This
20 // element specifies non-visual canvas properties. This allows for additional
21 // information that does not affect the appearance of the picture to be stored.
22 type xlsxCNvPr struct {
23 ID int `xml:"id,attr"`
24 Name string `xml:"name,attr"`
25 Descr string `xml:"descr,attr"`
26 Title string `xml:"title,attr,omitempty"`
27 HlinkClick *xlsxHlinkClick `xml:"a:hlinkClick"`
30 // xlsxHlinkClick (Click Hyperlink) Specifies the on-click hyperlink
31 // information to be applied to a run of text. When the hyperlink text is
32 // clicked the link is fetched.
33 type xlsxHlinkClick struct {
34 R string `xml:"xmlns:r,attr,omitempty"`
35 RID string `xml:"r:id,attr,omitempty"`
36 InvalidURL string `xml:"invalidUrl,attr,omitempty"`
37 Action string `xml:"action,attr,omitempty"`
38 TgtFrame string `xml:"tgtFrame,attr,omitempty"`
39 Tooltip string `xml:"tooltip,attr,omitempty"`
40 History bool `xml:"history,attr,omitempty"`
41 HighlightClick bool `xml:"highlightClick,attr,omitempty"`
42 EndSnd bool `xml:"endSnd,attr,omitempty"`
45 // xlsxPicLocks directly maps the picLocks (Picture Locks). This element
46 // specifies all locking properties for a graphic frame. These properties inform
47 // the generating application about specific properties that have been
48 // previously locked and thus should not be changed.
49 type xlsxPicLocks struct {
50 NoAdjustHandles bool `xml:"noAdjustHandles,attr,omitempty"`
51 NoChangeArrowheads bool `xml:"noChangeArrowheads,attr,omitempty"`
52 NoChangeAspect bool `xml:"noChangeAspect,attr"`
53 NoChangeShapeType bool `xml:"noChangeShapeType,attr,omitempty"`
54 NoCrop bool `xml:"noCrop,attr,omitempty"`
55 NoEditPoints bool `xml:"noEditPoints,attr,omitempty"`
56 NoGrp bool `xml:"noGrp,attr,omitempty"`
57 NoMove bool `xml:"noMove,attr,omitempty"`
58 NoResize bool `xml:"noResize,attr,omitempty"`
59 NoRot bool `xml:"noRot,attr,omitempty"`
60 NoSelect bool `xml:"noSelect,attr,omitempty"`
63 // xlsxBlip element specifies the existence of an image (binary large image or
64 // picture) and contains a reference to the image data.
65 type xlsxBlip struct {
66 Embed string `xml:"r:embed,attr"`
67 Cstate string `xml:"cstate,attr,omitempty"`
68 R string `xml:"xmlns:r,attr"`
69 ExtList *xlsxEGOfficeArtExtensionList `xml:"a:extLst"`
72 // xlsxStretch directly maps the stretch element. This element specifies that a
73 // BLIP should be stretched to fill the target rectangle. The other option is a
74 // tile where a BLIP is tiled to fill the available area.
75 type xlsxStretch struct {
76 FillRect string `xml:"a:fillRect"`
79 // xlsxOff directly maps the colOff and rowOff element. This element is used to
80 // specify the column offset within a cell.
86 // aExt directly maps the a:ext element.
88 Cx int `xml:"cx,attr"`
89 Cy int `xml:"cy,attr"`
92 // xlsxPrstGeom directly maps the prstGeom (Preset geometry). This element
93 // specifies when a preset geometric shape should be used instead of a custom
94 // geometric shape. The generating application should be able to render all
95 // preset geometries enumerated in the ST_ShapeType list.
96 type xlsxPrstGeom struct {
97 Prst string `xml:"prst,attr"`
100 // xlsxXfrm directly maps the xfrm (2D Transform for Graphic Frame). This
101 // element specifies the transform to be applied to the corresponding graphic
102 // frame. This transformation is applied to the graphic frame just as it would
103 // be for a shape or group shape.
104 type xlsxXfrm struct {
105 Off xlsxOff `xml:"a:off"`
106 Ext aExt `xml:"a:ext"`
109 // xlsxCNvPicPr directly maps the cNvPicPr (Non-Visual Picture Drawing
110 // Properties). This element specifies the non-visual properties for the picture
111 // canvas. These properties are to be used by the generating application to
112 // determine how certain properties are to be changed for the picture object in
114 type xlsxCNvPicPr struct {
115 PicLocks xlsxPicLocks `xml:"a:picLocks"`
118 // directly maps the nvPicPr (Non-Visual Properties for a Picture). This element
119 // specifies all non-visual properties for a picture. This element is a
120 // container for the non-visual identification properties, shape properties and
121 // application properties that are to be associated with a picture. This allows
122 // for additional information that does not affect the appearance of the picture
124 type xlsxNvPicPr struct {
125 CNvPr xlsxCNvPr `xml:"xdr:cNvPr"`
126 CNvPicPr xlsxCNvPicPr `xml:"xdr:cNvPicPr"`
129 // xlsxCTSVGBlip specifies a graphic element in Scalable Vector Graphics (SVG)
131 type xlsxCTSVGBlip struct {
132 XMLNSaAVG string `xml:"xmlns:asvg,attr"`
133 Embed string `xml:"r:embed,attr"`
134 Link string `xml:"r:link,attr,omitempty"`
137 // xlsxCTOfficeArtExtension used for future extensibility and is seen elsewhere
138 // throughout the drawing area.
139 type xlsxCTOfficeArtExtension struct {
140 XMLName xml.Name `xml:"a:ext"`
141 URI string `xml:"uri,attr"`
142 SVGBlip xlsxCTSVGBlip `xml:"asvg:svgBlip"`
145 // xlsxEGOfficeArtExtensionList used for future extensibility and is seen
146 // elsewhere throughout the drawing area.
147 type xlsxEGOfficeArtExtensionList struct {
148 Ext []xlsxCTOfficeArtExtension `xml:"ext"`
151 // xlsxBlipFill directly maps the blipFill (Picture Fill). This element
152 // specifies the kind of picture fill that the picture object has. Because a
153 // picture has a picture fill already by default, it is possible to have two
154 // fills specified for a picture object.
155 type xlsxBlipFill struct {
156 Blip xlsxBlip `xml:"a:blip"`
157 Stretch xlsxStretch `xml:"a:stretch"`
160 // xlsxLineProperties specifies the width of a line in EMUs. This simple type
161 // has a minimum value of greater than or equal to 0. This simple type has a
162 // maximum value of less than or equal to 20116800.
163 type xlsxLineProperties struct {
164 W int `xml:"w,attr,omitempty"`
165 SolidFill *xlsxInnerXML `xml:"a:solidFill"`
168 // xlsxSpPr directly maps the spPr (Shape Properties). This element specifies
169 // the visual shape properties that can be applied to a picture. These are the
170 // same properties that are allowed to describe the visual properties of a shape
171 // but are used here to describe the visual appearance of a picture within a
173 type xlsxSpPr struct {
174 Xfrm xlsxXfrm `xml:"a:xfrm"`
175 PrstGeom xlsxPrstGeom `xml:"a:prstGeom"`
176 SolidFill *xlsxInnerXML `xml:"a:solidFill"`
177 Ln xlsxLineProperties `xml:"a:ln"`
180 // xlsxPic elements encompass the definition of pictures within the DrawingML
181 // framework. While pictures are in many ways very similar to shapes they have
182 // specific properties that are unique in order to optimize for picture-
183 // specific scenarios.
184 type xlsxPic struct {
185 NvPicPr xlsxNvPicPr `xml:"xdr:nvPicPr"`
186 BlipFill xlsxBlipFill `xml:"xdr:blipFill"`
187 SpPr xlsxSpPr `xml:"xdr:spPr"`
190 // xlsxFrom specifies the starting anchor.
191 type xlsxFrom struct {
192 Col int `xml:"xdr:col"`
193 ColOff int `xml:"xdr:colOff"`
194 Row int `xml:"xdr:row"`
195 RowOff int `xml:"xdr:rowOff"`
198 // xlsxTo directly specifies the ending anchor.
200 Col int `xml:"xdr:col"`
201 ColOff int `xml:"xdr:colOff"`
202 Row int `xml:"xdr:row"`
203 RowOff int `xml:"xdr:rowOff"`
206 // xdrClientData directly maps the clientData element. An empty element which
207 // specifies (via attributes) certain properties related to printing and
208 // selection of the drawing object. The fLocksWithSheet attribute (either true
209 // or false) determines whether to disable selection when the sheet is
210 // protected, and fPrintsWithSheet attribute (either true or false) determines
211 // whether the object is printed when the sheet is printed.
212 type xdrClientData struct {
213 FLocksWithSheet bool `xml:"fLocksWithSheet,attr"`
214 FPrintsWithSheet bool `xml:"fPrintsWithSheet,attr"`
217 // xdrCellAnchor specifies a oneCellAnchor (One Cell Anchor Shape Size) and
218 // twoCellAnchor (Two Cell Anchor Shape Size) placeholder for a group, a shape,
219 // or a drawing element. It moves with cells and its extents are in EMU units.
220 type xdrCellAnchor struct {
221 EditAs string `xml:"editAs,attr,omitempty"`
222 Pos *xlsxPoint2D `xml:"xdr:pos"`
223 From *xlsxFrom `xml:"xdr:from"`
224 To *xlsxTo `xml:"xdr:to"`
225 Ext *aExt `xml:"xdr:ext"`
226 Sp *xdrSp `xml:"xdr:sp"`
227 Pic *xlsxPic `xml:"xdr:pic,omitempty"`
228 GraphicFrame string `xml:",innerxml"`
229 AlternateContent []*xlsxAlternateContent `xml:"mc:AlternateContent"`
230 ClientData *xdrClientData `xml:"xdr:clientData"`
233 // xlsxCellAnchorPos defines the structure used to serialize the cell anchor for
234 // adjust drawing object on inserting/deleting column/rows.
235 type xlsxCellAnchorPos struct {
236 EditAs string `xml:"editAs,attr,omitempty"`
237 From *xlsxFrom `xml:"xdr:from"`
238 To *xlsxTo `xml:"xdr:to"`
239 Pos *xlsxInnerXML `xml:"xdr:pos"`
240 Ext *xlsxInnerXML `xml:"xdr:ext"`
241 Sp *xlsxInnerXML `xml:"xdr:sp"`
242 GrpSp *xlsxInnerXML `xml:"xdr:grpSp"`
243 GraphicFrame *xlsxInnerXML `xml:"xdr:graphicFrame"`
244 CxnSp *xlsxInnerXML `xml:"xdr:cxnSp"`
245 Pic *xlsxInnerXML `xml:"xdr:pic"`
246 ContentPart *xlsxInnerXML `xml:"xdr:contentPart"`
247 AlternateContent []*xlsxAlternateContent `xml:"mc:AlternateContent"`
248 ClientData *xlsxInnerXML `xml:"xdr:clientData"`
251 // xlsxPoint2D describes the position of a drawing element within a spreadsheet.
252 type xlsxPoint2D struct {
253 XMLName xml.Name `xml:"xdr:pos"`
258 // xlsxWsDr directly maps the root element for a part of this content type shall
260 type xlsxWsDr struct {
262 XMLName xml.Name `xml:"xdr:wsDr"`
263 NS string `xml:"xmlns,attr,omitempty"`
264 A string `xml:"xmlns:a,attr,omitempty"`
265 Xdr string `xml:"xmlns:xdr,attr,omitempty"`
266 R string `xml:"xmlns:r,attr,omitempty"`
267 AlternateContent []*xlsxAlternateContent `xml:"mc:AlternateContent"`
268 AbsoluteAnchor []*xdrCellAnchor `xml:"xdr:absoluteAnchor"`
269 OneCellAnchor []*xdrCellAnchor `xml:"xdr:oneCellAnchor"`
270 TwoCellAnchor []*xdrCellAnchor `xml:"xdr:twoCellAnchor"`
273 // xlsxGraphicFrame (Graphic Frame) directly maps the xdr:graphicFrame element.
274 // This element specifies the existence of a graphics frame. This frame contains
275 // a graphic that was generated by an external source and needs a container in
276 // which to be displayed on the slide surface.
277 type xlsxGraphicFrame struct {
278 XMLName xml.Name `xml:"xdr:graphicFrame"`
279 Macro string `xml:"macro,attr"`
280 NvGraphicFramePr xlsxNvGraphicFramePr `xml:"xdr:nvGraphicFramePr"`
281 Xfrm xlsxXfrm `xml:"xdr:xfrm"`
282 Graphic *xlsxGraphic `xml:"a:graphic"`
285 // xlsxNvGraphicFramePr (Non-Visual Properties for a Graphic Frame) directly
286 // maps the xdr:nvGraphicFramePr element. This element specifies all non-visual
287 // properties for a graphic frame. This element is a container for the non-
288 // visual identification properties, shape properties and application properties
289 // that are to be associated with a graphic frame. This allows for additional
290 // information that does not affect the appearance of the graphic frame to be
292 type xlsxNvGraphicFramePr struct {
293 CNvPr *xlsxCNvPr `xml:"xdr:cNvPr"`
294 ChicNvGraphicFramePr string `xml:"xdr:cNvGraphicFramePr"`
297 // xlsxGraphic (Graphic Object) directly maps the a:graphic element. This
298 // element specifies the existence of a single graphic object. Document authors
299 // should refer to this element when they wish to persist a graphical object of
300 // some kind. The specification for this graphical object is provided entirely
301 // by the document author and referenced within the graphicData child element.
302 type xlsxGraphic struct {
303 GraphicData *xlsxGraphicData `xml:"a:graphicData"`
306 // xlsxGraphicData (Graphic Object Data) directly maps the a:graphicData
307 // element. This element specifies the reference to a graphic object within the
308 // document. This graphic object is provided entirely by the document authors
309 // who choose to persist this data within the document.
310 type xlsxGraphicData struct {
311 URI string `xml:"uri,attr"`
312 Chart *xlsxChart `xml:"c:chart,omitempty"`
313 Sle *xlsxSle `xml:"sle:slicer"`
316 type xlsxSle struct {
317 XMLNS string `xml:"xmlns:sle,attr"`
318 Name string `xml:"name,attr"`
321 // xlsxChart (Chart) directly maps the c:chart element.
322 type xlsxChart struct {
323 C string `xml:"xmlns:c,attr"`
324 RID string `xml:"r:id,attr"`
325 R string `xml:"xmlns:r,attr"`
328 // xdrSp (Shape) directly maps the xdr:sp element. This element specifies the
329 // existence of a single shape. A shape can either be a preset or a custom
330 // geometry, defined using the SpreadsheetDrawingML framework. In addition to a
331 // geometry each shape can have both visual and non-visual properties attached.
332 // Text and corresponding styling information can also be attached to a shape.
333 // This shape is specified along with all other shapes within either the shape
334 // tree or group shape elements.
336 XMLName xml.Name `xml:"xdr:sp"`
337 Macro string `xml:"macro,attr"`
338 Textlink string `xml:"textlink,attr"`
339 NvSpPr *xdrNvSpPr `xml:"xdr:nvSpPr"`
340 SpPr *xlsxSpPr `xml:"xdr:spPr"`
341 Style *xdrStyle `xml:"xdr:style"`
342 TxBody *xdrTxBody `xml:"xdr:txBody"`
345 // xdrNvSpPr (Non-Visual Properties for a Shape) directly maps the xdr:nvSpPr
346 // element. This element specifies all non-visual properties for a shape. This
347 // element is a container for the non-visual identification properties, shape
348 // properties and application properties that are to be associated with a shape.
349 // This allows for additional information that does not affect the appearance of
350 // the shape to be stored.
351 type xdrNvSpPr struct {
352 CNvPr *xlsxCNvPr `xml:"xdr:cNvPr"`
353 CNvSpPr *xdrCNvSpPr `xml:"xdr:cNvSpPr"`
356 // xdrCNvSpPr (Connection Non-Visual Shape Properties) directly maps the
357 // xdr:cNvSpPr element. This element specifies the set of non-visual properties
358 // for a connection shape. These properties specify all data about the
359 // connection shape which do not affect its display within a spreadsheet.
360 type xdrCNvSpPr struct {
361 TxBox bool `xml:"txBox,attr"`
364 // xdrStyle (Shape Style) directly maps the xdr:style element. The element
365 // specifies the style that is applied to a shape and the corresponding
366 // references for each of the style components such as lines and fills.
367 type xdrStyle struct {
368 LnRef *aRef `xml:"a:lnRef"`
369 FillRef *aRef `xml:"a:fillRef"`
370 EffectRef *aRef `xml:"a:effectRef"`
371 FontRef *aFontRef `xml:"a:fontRef"`
374 // aRef directly maps the a:lnRef, a:fillRef and a:effectRef element.
376 Idx int `xml:"idx,attr"`
377 ScrgbClr *aScrgbClr `xml:"a:scrgbClr"`
378 SchemeClr *attrValString `xml:"a:schemeClr"`
379 SrgbClr *attrValString `xml:"a:srgbClr"`
382 // aScrgbClr (RGB Color Model - Percentage Variant) directly maps the a:scrgbClr
383 // element. This element specifies a color using the red, green, blue RGB color
384 // model. Each component, red, green, and blue is expressed as a percentage from
385 // 0% to 100%. A linear gamma of 1.0 is assumed.
386 type aScrgbClr struct {
387 R float64 `xml:"r,attr"`
388 G float64 `xml:"g,attr"`
389 B float64 `xml:"b,attr"`
392 // aFontRef (Font Reference) directly maps the a:fontRef element. This element
393 // represents a reference to a themed font. When used it specifies which themed
394 // font to use along with a choice of color.
395 type aFontRef struct {
396 Idx string `xml:"idx,attr"`
397 SchemeClr *attrValString `xml:"a:schemeClr"`
400 // xdrTxBody (Shape Text Body) directly maps the xdr:txBody element. This
401 // element specifies the existence of text to be contained within the
402 // corresponding shape. All visible text and visible text related properties are
403 // contained within this element. There can be multiple paragraphs and within
404 // paragraphs multiple runs of text.
405 type xdrTxBody struct {
406 BodyPr *aBodyPr `xml:"a:bodyPr"`
410 // Picture maps the format settings of the picture.
411 type Picture struct {
414 Format *GraphicOptions
417 // GraphicOptions directly maps the format settings of the picture.
418 type GraphicOptions struct {
433 // Shape directly maps the format settings of the shape.
440 Format GraphicOptions
443 Paragraph []RichTextRun
446 // ShapeColor directly maps the color settings of the shape.
447 type ShapeColor struct {
453 // ShapeLine directly maps the line settings of the shape.
454 type ShapeLine struct {