xmlDrawing.go 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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
  3. // the LICENSE file.
  4. //
  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.
  11. package excelize
  12. import (
  13. "encoding/xml"
  14. "sync"
  15. )
  16. // Source relationship and namespace list, associated prefixes and schema in which it was
  17. // introduced.
  18. var (
  19. NameSpaceDocumentPropertiesVariantTypes = xml.Attr{Name: xml.Name{Local: "vt", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"}
  20. NameSpaceDrawing2016SVG = xml.Attr{Name: xml.Name{Local: "asvg", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2016/SVG/main"}
  21. NameSpaceDrawingML = xml.Attr{Name: xml.Name{Local: "a", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/main"}
  22. NameSpaceDrawingMLChart = xml.Attr{Name: xml.Name{Local: "c", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/chart"}
  23. NameSpaceDrawingMLSpreadSheet = xml.Attr{Name: xml.Name{Local: "xdr", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"}
  24. NameSpaceMacExcel2008Main = xml.Attr{Name: xml.Name{Local: "mx", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/mac/excel/2008/main"}
  25. NameSpaceSpreadSheet = xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"}
  26. NameSpaceSpreadSheetExcel2006Main = xml.Attr{Name: xml.Name{Local: "xne", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/excel/2006/main"}
  27. NameSpaceSpreadSheetX14 = xml.Attr{Name: xml.Name{Local: "x14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}
  28. NameSpaceSpreadSheetX15 = xml.Attr{Name: xml.Name{Local: "x15", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"}
  29. SourceRelationship = xml.Attr{Name: xml.Name{Local: "r", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"}
  30. SourceRelationshipChart20070802 = xml.Attr{Name: xml.Name{Local: "c14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2007/8/2/chart"}
  31. SourceRelationshipChart2014 = xml.Attr{Name: xml.Name{Local: "c16", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2014/chart"}
  32. SourceRelationshipChart201506 = xml.Attr{Name: xml.Name{Local: "c16r2", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2015/06/chart"}
  33. SourceRelationshipCompatibility = xml.Attr{Name: xml.Name{Local: "mc", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/markup-compatibility/2006"}
  34. )
  35. // Source relationship and namespace.
  36. const (
  37. ContentTypeAddinMacro = "application/vnd.ms-excel.addin.macroEnabled.main+xml"
  38. ContentTypeDrawing = "application/vnd.openxmlformats-officedocument.drawing+xml"
  39. ContentTypeDrawingML = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"
  40. ContentTypeMacro = "application/vnd.ms-excel.sheet.macroEnabled.main+xml"
  41. ContentTypeSheetML = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"
  42. ContentTypeSpreadSheetMLChartsheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml"
  43. ContentTypeSpreadSheetMLComments = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml"
  44. ContentTypeSpreadSheetMLPivotCacheDefinition = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
  45. ContentTypeSpreadSheetMLPivotTable = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml"
  46. ContentTypeSpreadSheetMLSharedStrings = "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"
  47. ContentTypeSpreadSheetMLTable = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"
  48. ContentTypeSpreadSheetMLWorksheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"
  49. ContentTypeTemplate = "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml"
  50. ContentTypeTemplateMacro = "application/vnd.ms-excel.template.macroEnabled.main+xml"
  51. ContentTypeVBA = "application/vnd.ms-office.vbaProject"
  52. ContentTypeVML = "application/vnd.openxmlformats-officedocument.vmlDrawing"
  53. NameSpaceDrawingMLMain = "http://schemas.openxmlformats.org/drawingml/2006/main"
  54. NameSpaceDublinCore = "http://purl.org/dc/elements/1.1/"
  55. NameSpaceDublinCoreMetadataInitiative = "http://purl.org/dc/dcmitype/"
  56. NameSpaceDublinCoreTerms = "http://purl.org/dc/terms/"
  57. NameSpaceExtendedProperties = "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
  58. NameSpaceXML = "http://www.w3.org/XML/1998/namespace"
  59. NameSpaceXMLSchemaInstance = "http://www.w3.org/2001/XMLSchema-instance"
  60. SourceRelationshipChart = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"
  61. SourceRelationshipChartsheet = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"
  62. SourceRelationshipComments = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"
  63. SourceRelationshipDialogsheet = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet"
  64. SourceRelationshipDrawingML = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing"
  65. SourceRelationshipDrawingVML = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing"
  66. SourceRelationshipExtendProperties = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"
  67. SourceRelationshipHyperLink = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
  68. SourceRelationshipImage = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"
  69. SourceRelationshipOfficeDocument = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"
  70. SourceRelationshipPivotCache = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
  71. SourceRelationshipPivotTable = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
  72. SourceRelationshipSharedStrings = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
  73. SourceRelationshipTable = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table"
  74. SourceRelationshipVBAProject = "http://schemas.microsoft.com/office/2006/relationships/vbaProject"
  75. SourceRelationshipWorkSheet = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
  76. StrictNameSpaceDocumentPropertiesVariantTypes = "http://purl.oclc.org/ooxml/officeDocument/docPropsVTypes"
  77. StrictNameSpaceDrawingMLMain = "http://purl.oclc.org/ooxml/drawingml/main"
  78. StrictNameSpaceExtendedProperties = "http://purl.oclc.org/ooxml/officeDocument/extendedProperties"
  79. StrictNameSpaceSpreadSheet = "http://purl.oclc.org/ooxml/spreadsheetml/main"
  80. StrictSourceRelationship = "http://purl.oclc.org/ooxml/officeDocument/relationships"
  81. StrictSourceRelationshipChart = "http://purl.oclc.org/ooxml/officeDocument/relationships/chart"
  82. StrictSourceRelationshipComments = "http://purl.oclc.org/ooxml/officeDocument/relationships/comments"
  83. StrictSourceRelationshipExtendProperties = "http://purl.oclc.org/ooxml/officeDocument/relationships/extendedProperties"
  84. StrictSourceRelationshipImage = "http://purl.oclc.org/ooxml/officeDocument/relationships/image"
  85. StrictSourceRelationshipOfficeDocument = "http://purl.oclc.org/ooxml/officeDocument/relationships/officeDocument"
  86. // ExtURIConditionalFormattings is the extLst child element
  87. // ([ISO/IEC29500-1:2016] section 18.2.10) of the worksheet element
  88. // ([ISO/IEC29500-1:2016] section 18.3.1.99) is extended by the addition of
  89. // new child ext elements ([ISO/IEC29500-1:2016] section 18.2.7)
  90. ExtURIConditionalFormattingRuleID = "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}"
  91. ExtURIConditionalFormattings = "{78C0D931-6437-407d-A8EE-F0AAD7539E65}"
  92. ExtURIDataValidations = "{CCE6A557-97BC-4B89-ADB6-D9C93CAAB3DF}"
  93. ExtURIDrawingBlip = "{28A0092B-C50C-407E-A947-70E740481C1C}"
  94. ExtURIIgnoredErrors = "{01252117-D84E-4E92-8308-4BE1C098FCBB}"
  95. ExtURIMacExcelMX = "{64002731-A6B0-56B0-2670-7721B7C09600}"
  96. ExtURIProtectedRanges = "{FC87AEE6-9EDD-4A0A-B7FB-166176984837}"
  97. ExtURISlicerCachesListX14 = "{BBE1A952-AA13-448e-AADC-164F8A28A991}"
  98. ExtURISlicerListX14 = "{A8765BA9-456A-4DAB-B4F3-ACF838C121DE}"
  99. ExtURISlicerListX15 = "{3A4CF648-6AED-40f4-86FF-DC5316D8AED3}"
  100. ExtURISparklineGroups = "{05C60535-1F16-4fd2-B633-F4F36F0B64E0}"
  101. ExtURISVG = "{96DAC541-7B7A-43D3-8B79-37D633B846F1}"
  102. ExtURITimelineRefs = "{7E03D99C-DC04-49d9-9315-930204A7B6E9}"
  103. ExtURIWebExtensions = "{F7C9EE02-42E1-4005-9D12-6889AFFD525C}"
  104. )
  105. // extensionURIPriority is the priority of URI in the extension lists.
  106. var extensionURIPriority = []string{
  107. ExtURIConditionalFormattings,
  108. ExtURIDataValidations,
  109. ExtURISparklineGroups,
  110. ExtURISlicerListX14,
  111. ExtURIProtectedRanges,
  112. ExtURIIgnoredErrors,
  113. ExtURIWebExtensions,
  114. ExtURITimelineRefs,
  115. }
  116. // Excel specifications and limits
  117. const (
  118. MaxCellStyles = 65430
  119. MaxColumns = 16384
  120. MaxColumnWidth = 255
  121. MaxFieldLength = 255
  122. MaxFilePathLength = 207
  123. MaxFontFamilyLength = 31
  124. MaxFontSize = 409
  125. MaxRowHeight = 409
  126. MaxSheetNameLength = 31
  127. MinColumns = 1
  128. MinFontSize = 1
  129. StreamChunkSize = 1 << 24
  130. TotalCellChars = 32767
  131. TotalRows = 1048576
  132. TotalSheetHyperlinks = 65529
  133. UnzipSizeLimit = 1000 << 24
  134. // pivotTableVersion should be greater than 3. One or more of the
  135. // PivotTables chosen are created in a version of Excel earlier than
  136. // Excel 2007 or in compatibility mode. Slicer can only be used with
  137. // PivotTables created in Excel 2007 or a newer version of Excel.
  138. pivotTableVersion = 3
  139. defaultPictureScale = 1.0
  140. defaultChartDimensionWidth = 480
  141. defaultChartDimensionHeight = 290
  142. defaultChartLegendPosition = "bottom"
  143. defaultChartShowBlanksAs = "gap"
  144. defaultShapeSize = 160
  145. defaultShapeLineWidth = 1
  146. )
  147. // ColorMappingType is the type of color transformation.
  148. type ColorMappingType byte
  149. // Color transformation types enumeration.
  150. const (
  151. ColorMappingTypeLight1 ColorMappingType = iota
  152. ColorMappingTypeDark1
  153. ColorMappingTypeLight2
  154. ColorMappingTypeDark2
  155. ColorMappingTypeAccent1
  156. ColorMappingTypeAccent2
  157. ColorMappingTypeAccent3
  158. ColorMappingTypeAccent4
  159. ColorMappingTypeAccent5
  160. ColorMappingTypeAccent6
  161. ColorMappingTypeHyperlink
  162. ColorMappingTypeFollowedHyperlink
  163. ColorMappingTypeUnset int = -1
  164. )
  165. // IndexedColorMapping is the table of default mappings from indexed color value
  166. // to RGB value. Note that 0-7 are redundant of 8-15 to preserve backwards
  167. // compatibility. A legacy indexing scheme for colors that is still required
  168. // for some records, and for backwards compatibility with legacy formats. This
  169. // element contains a sequence of RGB color values that correspond to color
  170. // indexes (zero-based). When using the default indexed color palette, the
  171. // values are not written out, but instead are implied. When the color palette
  172. // has been modified from default, then the entire color palette is written
  173. // out.
  174. var IndexedColorMapping = []string{
  175. "000000", "FFFFFF", "FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF",
  176. "000000", "FFFFFF", "FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF",
  177. "800000", "008000", "000080", "808000", "800080", "008080", "C0C0C0", "808080",
  178. "9999FF", "993366", "FFFFCC", "CCFFFF", "660066", "FF8080", "0066CC", "CCCCFF",
  179. "000080", "FF00FF", "FFFF00", "00FFFF", "800080", "800000", "008080", "0000FF",
  180. "00CCFF", "CCFFFF", "CCFFCC", "FFFF99", "99CCFF", "FF99CC", "CC99FF", "FFCC99",
  181. "3366FF", "33CCCC", "99CC00", "FFCC00", "FF9900", "FF6600", "666699", "969696",
  182. "003366", "339966", "003300", "333300", "993300", "993366", "333399", "333333",
  183. "000000", "FFFFFF",
  184. }
  185. // supportedImageTypes defined supported image types.
  186. var supportedImageTypes = map[string]string{
  187. ".bmp": ".bmp", ".emf": ".emf", ".emz": ".emz", ".gif": ".gif",
  188. ".jpeg": ".jpeg", ".jpg": ".jpeg", ".png": ".png", ".svg": ".svg",
  189. ".tif": ".tiff", ".tiff": ".tiff", ".wmf": ".wmf", ".wmz": ".wmz",
  190. }
  191. // supportedContentTypes defined supported file format types.
  192. var supportedContentTypes = map[string]string{
  193. ".xlam": ContentTypeAddinMacro,
  194. ".xlsm": ContentTypeMacro,
  195. ".xlsx": ContentTypeSheetML,
  196. ".xltm": ContentTypeTemplateMacro,
  197. ".xltx": ContentTypeTemplate,
  198. }
  199. // supportedUnderlineTypes defined supported underline types.
  200. var supportedUnderlineTypes = []string{"none", "single", "double"}
  201. // supportedDrawingUnderlineTypes defined supported underline types in drawing
  202. // markup language.
  203. var supportedDrawingUnderlineTypes = []string{
  204. "none", "words", "sng", "dbl", "heavy", "dotted", "dottedHeavy", "dash", "dashHeavy", "dashLong", "dashLongHeavy", "dotDash", "dotDashHeavy", "dotDotDash", "dotDotDashHeavy", "wavy", "wavyHeavy",
  205. "wavyDbl",
  206. }
  207. // xlsxCNvPr directly maps the cNvPr (Non-Visual Drawing Properties). This
  208. // element specifies non-visual canvas properties. This allows for additional
  209. // information that does not affect the appearance of the picture to be stored.
  210. type xlsxCNvPr struct {
  211. ID int `xml:"id,attr"`
  212. Name string `xml:"name,attr"`
  213. Descr string `xml:"descr,attr"`
  214. Title string `xml:"title,attr,omitempty"`
  215. HlinkClick *xlsxHlinkClick `xml:"a:hlinkClick"`
  216. }
  217. // xlsxHlinkClick (Click Hyperlink) Specifies the on-click hyperlink
  218. // information to be applied to a run of text. When the hyperlink text is
  219. // clicked the link is fetched.
  220. type xlsxHlinkClick struct {
  221. R string `xml:"xmlns:r,attr,omitempty"`
  222. RID string `xml:"r:id,attr,omitempty"`
  223. InvalidURL string `xml:"invalidUrl,attr,omitempty"`
  224. Action string `xml:"action,attr,omitempty"`
  225. TgtFrame string `xml:"tgtFrame,attr,omitempty"`
  226. Tooltip string `xml:"tooltip,attr,omitempty"`
  227. History bool `xml:"history,attr,omitempty"`
  228. HighlightClick bool `xml:"highlightClick,attr,omitempty"`
  229. EndSnd bool `xml:"endSnd,attr,omitempty"`
  230. }
  231. // xlsxPicLocks directly maps the picLocks (Picture Locks). This element
  232. // specifies all locking properties for a graphic frame. These properties inform
  233. // the generating application about specific properties that have been
  234. // previously locked and thus should not be changed.
  235. type xlsxPicLocks struct {
  236. NoAdjustHandles bool `xml:"noAdjustHandles,attr,omitempty"`
  237. NoChangeArrowheads bool `xml:"noChangeArrowheads,attr,omitempty"`
  238. NoChangeAspect bool `xml:"noChangeAspect,attr"`
  239. NoChangeShapeType bool `xml:"noChangeShapeType,attr,omitempty"`
  240. NoCrop bool `xml:"noCrop,attr,omitempty"`
  241. NoEditPoints bool `xml:"noEditPoints,attr,omitempty"`
  242. NoGrp bool `xml:"noGrp,attr,omitempty"`
  243. NoMove bool `xml:"noMove,attr,omitempty"`
  244. NoResize bool `xml:"noResize,attr,omitempty"`
  245. NoRot bool `xml:"noRot,attr,omitempty"`
  246. NoSelect bool `xml:"noSelect,attr,omitempty"`
  247. }
  248. // xlsxBlip element specifies the existence of an image (binary large image or
  249. // picture) and contains a reference to the image data.
  250. type xlsxBlip struct {
  251. Embed string `xml:"r:embed,attr"`
  252. Cstate string `xml:"cstate,attr,omitempty"`
  253. R string `xml:"xmlns:r,attr"`
  254. ExtList *xlsxEGOfficeArtExtensionList `xml:"a:extLst"`
  255. }
  256. // xlsxStretch directly maps the stretch element. This element specifies that a
  257. // BLIP should be stretched to fill the target rectangle. The other option is a
  258. // tile where a BLIP is tiled to fill the available area.
  259. type xlsxStretch struct {
  260. FillRect string `xml:"a:fillRect"`
  261. }
  262. // xlsxOff directly maps the colOff and rowOff element. This element is used to
  263. // specify the column offset within a cell.
  264. type xlsxOff struct {
  265. X int `xml:"x,attr"`
  266. Y int `xml:"y,attr"`
  267. }
  268. // xlsxExt directly maps the ext element.
  269. type xlsxExt struct {
  270. Cx int `xml:"cx,attr"`
  271. Cy int `xml:"cy,attr"`
  272. }
  273. // xlsxPrstGeom directly maps the prstGeom (Preset geometry). This element
  274. // specifies when a preset geometric shape should be used instead of a custom
  275. // geometric shape. The generating application should be able to render all
  276. // preset geometries enumerated in the ST_ShapeType list.
  277. type xlsxPrstGeom struct {
  278. Prst string `xml:"prst,attr"`
  279. }
  280. // xlsxXfrm directly maps the xfrm (2D Transform for Graphic Frame). This
  281. // element specifies the transform to be applied to the corresponding graphic
  282. // frame. This transformation is applied to the graphic frame just as it would
  283. // be for a shape or group shape.
  284. type xlsxXfrm struct {
  285. Off xlsxOff `xml:"a:off"`
  286. Ext xlsxExt `xml:"a:ext"`
  287. }
  288. // xlsxCNvPicPr directly maps the cNvPicPr (Non-Visual Picture Drawing
  289. // Properties). This element specifies the non-visual properties for the picture
  290. // canvas. These properties are to be used by the generating application to
  291. // determine how certain properties are to be changed for the picture object in
  292. // question.
  293. type xlsxCNvPicPr struct {
  294. PicLocks xlsxPicLocks `xml:"a:picLocks"`
  295. }
  296. // directly maps the nvPicPr (Non-Visual Properties for a Picture). This element
  297. // specifies all non-visual properties for a picture. This element is a
  298. // container for the non-visual identification properties, shape properties and
  299. // application properties that are to be associated with a picture. This allows
  300. // for additional information that does not affect the appearance of the picture
  301. // to be stored.
  302. type xlsxNvPicPr struct {
  303. CNvPr xlsxCNvPr `xml:"xdr:cNvPr"`
  304. CNvPicPr xlsxCNvPicPr `xml:"xdr:cNvPicPr"`
  305. }
  306. // xlsxCTSVGBlip specifies a graphic element in Scalable Vector Graphics (SVG)
  307. // format.
  308. type xlsxCTSVGBlip struct {
  309. XMLNSaAVG string `xml:"xmlns:asvg,attr"`
  310. Embed string `xml:"r:embed,attr"`
  311. Link string `xml:"r:link,attr,omitempty"`
  312. }
  313. // xlsxCTOfficeArtExtension used for future extensibility and is seen elsewhere
  314. // throughout the drawing area.
  315. type xlsxCTOfficeArtExtension struct {
  316. XMLName xml.Name `xml:"a:ext"`
  317. URI string `xml:"uri,attr"`
  318. SVGBlip xlsxCTSVGBlip `xml:"asvg:svgBlip"`
  319. }
  320. // xlsxEGOfficeArtExtensionList used for future extensibility and is seen
  321. // elsewhere throughout the drawing area.
  322. type xlsxEGOfficeArtExtensionList struct {
  323. Ext []xlsxCTOfficeArtExtension `xml:"ext"`
  324. }
  325. // xlsxBlipFill directly maps the blipFill (Picture Fill). This element
  326. // specifies the kind of picture fill that the picture object has. Because a
  327. // picture has a picture fill already by default, it is possible to have two
  328. // fills specified for a picture object.
  329. type xlsxBlipFill struct {
  330. Blip xlsxBlip `xml:"a:blip"`
  331. Stretch xlsxStretch `xml:"a:stretch"`
  332. }
  333. // xlsxLineProperties specifies the width of a line in EMUs. This simple type
  334. // has a minimum value of greater than or equal to 0. This simple type has a
  335. // maximum value of less than or equal to 20116800.
  336. type xlsxLineProperties struct {
  337. W int `xml:"w,attr,omitempty"`
  338. }
  339. // xlsxSpPr directly maps the spPr (Shape Properties). This element specifies
  340. // the visual shape properties that can be applied to a picture. These are the
  341. // same properties that are allowed to describe the visual properties of a shape
  342. // but are used here to describe the visual appearance of a picture within a
  343. // document.
  344. type xlsxSpPr struct {
  345. Xfrm xlsxXfrm `xml:"a:xfrm"`
  346. PrstGeom xlsxPrstGeom `xml:"a:prstGeom"`
  347. Ln xlsxLineProperties `xml:"a:ln"`
  348. }
  349. // xlsxPic elements encompass the definition of pictures within the DrawingML
  350. // framework. While pictures are in many ways very similar to shapes they have
  351. // specific properties that are unique in order to optimize for picture-
  352. // specific scenarios.
  353. type xlsxPic struct {
  354. NvPicPr xlsxNvPicPr `xml:"xdr:nvPicPr"`
  355. BlipFill xlsxBlipFill `xml:"xdr:blipFill"`
  356. SpPr xlsxSpPr `xml:"xdr:spPr"`
  357. }
  358. // xlsxFrom specifies the starting anchor.
  359. type xlsxFrom struct {
  360. Col int `xml:"xdr:col"`
  361. ColOff int `xml:"xdr:colOff"`
  362. Row int `xml:"xdr:row"`
  363. RowOff int `xml:"xdr:rowOff"`
  364. }
  365. // xlsxTo directly specifies the ending anchor.
  366. type xlsxTo struct {
  367. Col int `xml:"xdr:col"`
  368. ColOff int `xml:"xdr:colOff"`
  369. Row int `xml:"xdr:row"`
  370. RowOff int `xml:"xdr:rowOff"`
  371. }
  372. // xdrClientData directly maps the clientData element. An empty element which
  373. // specifies (via attributes) certain properties related to printing and
  374. // selection of the drawing object. The fLocksWithSheet attribute (either true
  375. // or false) determines whether to disable selection when the sheet is
  376. // protected, and fPrintsWithSheet attribute (either true or false) determines
  377. // whether the object is printed when the sheet is printed.
  378. type xdrClientData struct {
  379. FLocksWithSheet bool `xml:"fLocksWithSheet,attr"`
  380. FPrintsWithSheet bool `xml:"fPrintsWithSheet,attr"`
  381. }
  382. // xdrCellAnchor directly maps the oneCellAnchor (One Cell Anchor Shape Size)
  383. // and twoCellAnchor (Two Cell Anchor Shape Size). This element specifies a two
  384. // cell anchor placeholder for a group, a shape, or a drawing element. It moves
  385. // with cells and its extents are in EMU units.
  386. type xdrCellAnchor struct {
  387. EditAs string `xml:"editAs,attr,omitempty"`
  388. Pos *xlsxPoint2D `xml:"xdr:pos"`
  389. From *xlsxFrom `xml:"xdr:from"`
  390. To *xlsxTo `xml:"xdr:to"`
  391. Ext *xlsxExt `xml:"xdr:ext"`
  392. Sp *xdrSp `xml:"xdr:sp"`
  393. Pic *xlsxPic `xml:"xdr:pic,omitempty"`
  394. GraphicFrame string `xml:",innerxml"`
  395. ClientData *xdrClientData `xml:"xdr:clientData"`
  396. }
  397. // xlsxPoint2D describes the position of a drawing element within a spreadsheet.
  398. type xlsxPoint2D struct {
  399. XMLName xml.Name `xml:"xdr:pos"`
  400. X int `xml:"x,attr"`
  401. Y int `xml:"y,attr"`
  402. }
  403. // xlsxWsDr directly maps the root element for a part of this content type shall
  404. // wsDr.
  405. type xlsxWsDr struct {
  406. sync.Mutex
  407. XMLName xml.Name `xml:"xdr:wsDr"`
  408. A string `xml:"xmlns:a,attr,omitempty"`
  409. Xdr string `xml:"xmlns:xdr,attr,omitempty"`
  410. R string `xml:"xmlns:r,attr,omitempty"`
  411. AlternateContent []*xlsxAlternateContent `xml:"mc:AlternateContent"`
  412. AbsoluteAnchor []*xdrCellAnchor `xml:"xdr:absoluteAnchor"`
  413. OneCellAnchor []*xdrCellAnchor `xml:"xdr:oneCellAnchor"`
  414. TwoCellAnchor []*xdrCellAnchor `xml:"xdr:twoCellAnchor"`
  415. }
  416. // xlsxGraphicFrame (Graphic Frame) directly maps the xdr:graphicFrame element.
  417. // This element specifies the existence of a graphics frame. This frame contains
  418. // a graphic that was generated by an external source and needs a container in
  419. // which to be displayed on the slide surface.
  420. type xlsxGraphicFrame struct {
  421. XMLName xml.Name `xml:"xdr:graphicFrame"`
  422. Macro string `xml:"macro,attr"`
  423. NvGraphicFramePr xlsxNvGraphicFramePr `xml:"xdr:nvGraphicFramePr"`
  424. Xfrm xlsxXfrm `xml:"xdr:xfrm"`
  425. Graphic *xlsxGraphic `xml:"a:graphic"`
  426. }
  427. // xlsxNvGraphicFramePr (Non-Visual Properties for a Graphic Frame) directly
  428. // maps the xdr:nvGraphicFramePr element. This element specifies all non-visual
  429. // properties for a graphic frame. This element is a container for the non-
  430. // visual identification properties, shape properties and application properties
  431. // that are to be associated with a graphic frame. This allows for additional
  432. // information that does not affect the appearance of the graphic frame to be
  433. // stored.
  434. type xlsxNvGraphicFramePr struct {
  435. CNvPr *xlsxCNvPr `xml:"xdr:cNvPr"`
  436. ChicNvGraphicFramePr string `xml:"xdr:cNvGraphicFramePr"`
  437. }
  438. // xlsxGraphic (Graphic Object) directly maps the a:graphic element. This
  439. // element specifies the existence of a single graphic object. Document authors
  440. // should refer to this element when they wish to persist a graphical object of
  441. // some kind. The specification for this graphical object is provided entirely
  442. // by the document author and referenced within the graphicData child element.
  443. type xlsxGraphic struct {
  444. GraphicData *xlsxGraphicData `xml:"a:graphicData"`
  445. }
  446. // xlsxGraphicData (Graphic Object Data) directly maps the a:graphicData
  447. // element. This element specifies the reference to a graphic object within the
  448. // document. This graphic object is provided entirely by the document authors
  449. // who choose to persist this data within the document.
  450. type xlsxGraphicData struct {
  451. URI string `xml:"uri,attr"`
  452. Chart *xlsxChart `xml:"c:chart,omitempty"`
  453. }
  454. // xlsxChart (Chart) directly maps the c:chart element.
  455. type xlsxChart struct {
  456. C string `xml:"xmlns:c,attr"`
  457. RID string `xml:"r:id,attr"`
  458. R string `xml:"xmlns:r,attr"`
  459. }
  460. // xdrSp (Shape) directly maps the xdr:sp element. This element specifies the
  461. // existence of a single shape. A shape can either be a preset or a custom
  462. // geometry, defined using the SpreadsheetDrawingML framework. In addition to a
  463. // geometry each shape can have both visual and non-visual properties attached.
  464. // Text and corresponding styling information can also be attached to a shape.
  465. // This shape is specified along with all other shapes within either the shape
  466. // tree or group shape elements.
  467. type xdrSp struct {
  468. Macro string `xml:"macro,attr"`
  469. Textlink string `xml:"textlink,attr"`
  470. NvSpPr *xdrNvSpPr `xml:"xdr:nvSpPr"`
  471. SpPr *xlsxSpPr `xml:"xdr:spPr"`
  472. Style *xdrStyle `xml:"xdr:style"`
  473. TxBody *xdrTxBody `xml:"xdr:txBody"`
  474. }
  475. // xdrNvSpPr (Non-Visual Properties for a Shape) directly maps the xdr:nvSpPr
  476. // element. This element specifies all non-visual properties for a shape. This
  477. // element is a container for the non-visual identification properties, shape
  478. // properties and application properties that are to be associated with a shape.
  479. // This allows for additional information that does not affect the appearance of
  480. // the shape to be stored.
  481. type xdrNvSpPr struct {
  482. CNvPr *xlsxCNvPr `xml:"xdr:cNvPr"`
  483. CNvSpPr *xdrCNvSpPr `xml:"xdr:cNvSpPr"`
  484. }
  485. // xdrCNvSpPr (Connection Non-Visual Shape Properties) directly maps the
  486. // xdr:cNvSpPr element. This element specifies the set of non-visual properties
  487. // for a connection shape. These properties specify all data about the
  488. // connection shape which do not affect its display within a spreadsheet.
  489. type xdrCNvSpPr struct {
  490. TxBox bool `xml:"txBox,attr"`
  491. }
  492. // xdrStyle (Shape Style) directly maps the xdr:style element. The element
  493. // specifies the style that is applied to a shape and the corresponding
  494. // references for each of the style components such as lines and fills.
  495. type xdrStyle struct {
  496. LnRef *aRef `xml:"a:lnRef"`
  497. FillRef *aRef `xml:"a:fillRef"`
  498. EffectRef *aRef `xml:"a:effectRef"`
  499. FontRef *aFontRef `xml:"a:fontRef"`
  500. }
  501. // aRef directly maps the a:lnRef, a:fillRef and a:effectRef element.
  502. type aRef struct {
  503. Idx int `xml:"idx,attr"`
  504. ScrgbClr *aScrgbClr `xml:"a:scrgbClr"`
  505. SchemeClr *attrValString `xml:"a:schemeClr"`
  506. SrgbClr *attrValString `xml:"a:srgbClr"`
  507. }
  508. // aScrgbClr (RGB Color Model - Percentage Variant) directly maps the a:scrgbClr
  509. // element. This element specifies a color using the red, green, blue RGB color
  510. // model. Each component, red, green, and blue is expressed as a percentage from
  511. // 0% to 100%. A linear gamma of 1.0 is assumed.
  512. type aScrgbClr struct {
  513. R float64 `xml:"r,attr"`
  514. G float64 `xml:"g,attr"`
  515. B float64 `xml:"b,attr"`
  516. }
  517. // aFontRef (Font Reference) directly maps the a:fontRef element. This element
  518. // represents a reference to a themed font. When used it specifies which themed
  519. // font to use along with a choice of color.
  520. type aFontRef struct {
  521. Idx string `xml:"idx,attr"`
  522. SchemeClr *attrValString `xml:"a:schemeClr"`
  523. }
  524. // xdrTxBody (Shape Text Body) directly maps the xdr:txBody element. This
  525. // element specifies the existence of text to be contained within the
  526. // corresponding shape. All visible text and visible text related properties are
  527. // contained within this element. There can be multiple paragraphs and within
  528. // paragraphs multiple runs of text.
  529. type xdrTxBody struct {
  530. BodyPr *aBodyPr `xml:"a:bodyPr"`
  531. P []*aP `xml:"a:p"`
  532. }
  533. // Picture maps the format settings of the picture.
  534. type Picture struct {
  535. Extension string
  536. File []byte
  537. Format *GraphicOptions
  538. }
  539. // GraphicOptions directly maps the format settings of the picture.
  540. type GraphicOptions struct {
  541. AltText string
  542. PrintObject *bool
  543. Locked *bool
  544. LockAspectRatio bool
  545. AutoFit bool
  546. OffsetX int
  547. OffsetY int
  548. ScaleX float64
  549. ScaleY float64
  550. Hyperlink string
  551. HyperlinkType string
  552. Positioning string
  553. }
  554. // Shape directly maps the format settings of the shape.
  555. type Shape struct {
  556. Type string
  557. Macro string
  558. Width uint
  559. Height uint
  560. Format GraphicOptions
  561. Fill Fill
  562. Line ShapeLine
  563. Paragraph []RichTextRun
  564. }
  565. // ShapeColor directly maps the color settings of the shape.
  566. type ShapeColor struct {
  567. Line string
  568. Fill string
  569. Effect string
  570. }
  571. // ShapeLine directly maps the line settings of the shape.
  572. type ShapeLine struct {
  573. Color string
  574. Width *float64
  575. }