xmlWorksheet.go 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. // Copyright 2016 - 2019 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
  6. // and read from XLSX files. Support reads and writes XLSX file generated by
  7. // Microsoft Excel™ 2007 and later. Support save file without losing original
  8. // charts of XLSX. This library needs Go version 1.8 or later.
  9. package excelize
  10. import "encoding/xml"
  11. // xlsxWorksheet directly maps the worksheet element in the namespace
  12. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  13. // not checked it for completeness - it does as much as I need.
  14. type xlsxWorksheet struct {
  15. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main worksheet"`
  16. SheetPr *xlsxSheetPr `xml:"sheetPr"`
  17. Dimension xlsxDimension `xml:"dimension"`
  18. SheetViews xlsxSheetViews `xml:"sheetViews,omitempty"`
  19. SheetFormatPr *xlsxSheetFormatPr `xml:"sheetFormatPr"`
  20. Cols *xlsxCols `xml:"cols,omitempty"`
  21. SheetData xlsxSheetData `xml:"sheetData"`
  22. SheetProtection *xlsxSheetProtection `xml:"sheetProtection"`
  23. AutoFilter *xlsxAutoFilter `xml:"autoFilter"`
  24. CustomSheetViews *xlsxCustomSheetViews `xml:"customSheetViews"`
  25. MergeCells *xlsxMergeCells `xml:"mergeCells"`
  26. PhoneticPr *xlsxPhoneticPr `xml:"phoneticPr"`
  27. ConditionalFormatting []*xlsxConditionalFormatting `xml:"conditionalFormatting"`
  28. DataValidations *xlsxDataValidations `xml:"dataValidations,omitempty"`
  29. Hyperlinks *xlsxHyperlinks `xml:"hyperlinks"`
  30. PrintOptions *xlsxPrintOptions `xml:"printOptions"`
  31. PageMargins *xlsxPageMargins `xml:"pageMargins"`
  32. PageSetUp *xlsxPageSetUp `xml:"pageSetup"`
  33. HeaderFooter *xlsxHeaderFooter `xml:"headerFooter"`
  34. RowBreaks *xlsxBreaks `xml:"rowBreaks"`
  35. ColBreaks *xlsxBreaks `xml:"colBreaks"`
  36. Drawing *xlsxDrawing `xml:"drawing"`
  37. LegacyDrawing *xlsxLegacyDrawing `xml:"legacyDrawing"`
  38. Picture *xlsxPicture `xml:"picture"`
  39. TableParts *xlsxTableParts `xml:"tableParts"`
  40. ExtLst *xlsxExtLst `xml:"extLst"`
  41. }
  42. // xlsxDrawing change r:id to rid in the namespace.
  43. type xlsxDrawing struct {
  44. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  45. }
  46. // xlsxHeaderFooter directly maps the headerFooter element in the namespace
  47. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - When printed or
  48. // viewed in page layout view (§18.18.69), each page of a worksheet can have a
  49. // page header, a page footer, or both. The headers and footers on odd-numbered
  50. // pages can differ from those on even-numbered pages, and the headers and
  51. // footers on the first page can differ from those on odd- and even-numbered
  52. // pages. In the latter case, the first page is not considered an odd page.
  53. type xlsxHeaderFooter struct {
  54. AlignWithMargins bool `xml:"alignWithMargins,attr,omitempty"`
  55. DifferentFirst bool `xml:"differentFirst,attr,omitempty"`
  56. DifferentOddEven bool `xml:"differentOddEven,attr,omitempty"`
  57. ScaleWithDoc bool `xml:"scaleWithDoc,attr,omitempty"`
  58. OddHeader string `xml:"oddHeader,omitempty"`
  59. OddFooter string `xml:"oddFooter,omitempty"`
  60. EvenHeader string `xml:"evenHeader,omitempty"`
  61. EvenFooter string `xml:"evenFooter,omitempty"`
  62. FirstFooter string `xml:"firstFooter,omitempty"`
  63. FirstHeader string `xml:"firstHeader,omitempty"`
  64. DrawingHF *xlsxDrawingHF `xml:"drawingHF"`
  65. }
  66. // xlsxDrawingHF (Drawing Reference in Header Footer) specifies the usage of
  67. // drawing objects to be rendered in the headers and footers of the sheet. It
  68. // specifies an explicit relationship to the part containing the DrawingML
  69. // shapes used in the headers and footers. It also indicates where in the
  70. // headers and footers each shape belongs. One drawing object can appear in
  71. // each of the left section, center section and right section of a header and
  72. // a footer.
  73. type xlsxDrawingHF struct {
  74. Content string `xml:",chardata"`
  75. }
  76. // xlsxPageSetUp directly maps the pageSetup element in the namespace
  77. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page setup
  78. // settings for the worksheet.
  79. type xlsxPageSetUp struct {
  80. BlackAndWhite bool `xml:"blackAndWhite,attr,omitempty"`
  81. CellComments string `xml:"cellComments,attr,omitempty"`
  82. Copies int `xml:"copies,attr,omitempty"`
  83. Draft bool `xml:"draft,attr,omitempty"`
  84. Errors string `xml:"errors,attr,omitempty"`
  85. FirstPageNumber int `xml:"firstPageNumber,attr,omitempty"`
  86. FitToHeight int `xml:"fitToHeight,attr,omitempty"`
  87. FitToWidth int `xml:"fitToWidth,attr,omitempty"`
  88. HorizontalDPI float32 `xml:"horizontalDpi,attr,omitempty"`
  89. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  90. Orientation string `xml:"orientation,attr,omitempty"`
  91. PageOrder string `xml:"pageOrder,attr,omitempty"`
  92. PaperHeight string `xml:"paperHeight,attr,omitempty"`
  93. PaperSize int `xml:"paperSize,attr,omitempty"`
  94. PaperWidth string `xml:"paperWidth,attr,omitempty"`
  95. Scale int `xml:"scale,attr,omitempty"`
  96. UseFirstPageNumber bool `xml:"useFirstPageNumber,attr,omitempty"`
  97. UsePrinterDefaults bool `xml:"usePrinterDefaults,attr,omitempty"`
  98. VerticalDPI float32 `xml:"verticalDpi,attr,omitempty"`
  99. }
  100. // xlsxPrintOptions directly maps the printOptions element in the namespace
  101. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Print options for
  102. // the sheet. Printer-specific settings are stored separately in the Printer
  103. // Settings part.
  104. type xlsxPrintOptions struct {
  105. GridLines bool `xml:"gridLines,attr,omitempty"`
  106. GridLinesSet bool `xml:"gridLinesSet,attr,omitempty"`
  107. Headings bool `xml:"headings,attr,omitempty"`
  108. HorizontalCentered bool `xml:"horizontalCentered,attr,omitempty"`
  109. VerticalCentered bool `xml:"verticalCentered,attr,omitempty"`
  110. }
  111. // xlsxPageMargins directly maps the pageMargins element in the namespace
  112. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page margins for
  113. // a sheet or a custom sheet view.
  114. type xlsxPageMargins struct {
  115. Bottom float64 `xml:"bottom,attr"`
  116. Footer float64 `xml:"footer,attr"`
  117. Header float64 `xml:"header,attr"`
  118. Left float64 `xml:"left,attr"`
  119. Right float64 `xml:"right,attr"`
  120. Top float64 `xml:"top,attr"`
  121. }
  122. // xlsxSheetFormatPr directly maps the sheetFormatPr element in the namespace
  123. // http://schemas.openxmlformats.org/spreadsheetml/2006/main. This element
  124. // specifies the sheet formatting properties.
  125. type xlsxSheetFormatPr struct {
  126. BaseColWidth uint8 `xml:"baseColWidth,attr,omitempty"`
  127. DefaultColWidth float64 `xml:"defaultColWidth,attr,omitempty"`
  128. DefaultRowHeight float64 `xml:"defaultRowHeight,attr"`
  129. CustomHeight bool `xml:"customHeight,attr,omitempty"`
  130. ZeroHeight bool `xml:"zeroHeight,attr,omitempty"`
  131. ThickTop bool `xml:"thickTop,attr,omitempty"`
  132. ThickBottom bool `xml:"thickBottom,attr,omitempty"`
  133. OutlineLevelRow uint8 `xml:"outlineLevelRow,attr,omitempty"`
  134. OutlineLevelCol uint8 `xml:"outlineLevelCol,attr,omitempty"`
  135. }
  136. // xlsxSheetViews directly maps the sheetViews element in the namespace
  137. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Worksheet views
  138. // collection.
  139. type xlsxSheetViews struct {
  140. SheetView []xlsxSheetView `xml:"sheetView"`
  141. }
  142. // xlsxSheetView directly maps the sheetView element in the namespace
  143. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  144. // not checked it for completeness - it does as much as I need. A single sheet
  145. // view definition. When more than one sheet view is defined in the file, it
  146. // means that when opening the workbook, each sheet view corresponds to a
  147. // separate window within the spreadsheet application, where each window is
  148. // showing the particular sheet containing the same workbookViewId value, the
  149. // last sheetView definition is loaded, and the others are discarded. When
  150. // multiple windows are viewing the same sheet, multiple sheetView elements
  151. // (with corresponding workbookView entries) are saved.
  152. // See https://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.sheetview.aspx
  153. type xlsxSheetView struct {
  154. WindowProtection bool `xml:"windowProtection,attr,omitempty"`
  155. ShowFormulas bool `xml:"showFormulas,attr,omitempty"`
  156. ShowGridLines *bool `xml:"showGridLines,attr"`
  157. ShowRowColHeaders *bool `xml:"showRowColHeaders,attr"`
  158. ShowZeros bool `xml:"showZeros,attr,omitempty"`
  159. RightToLeft bool `xml:"rightToLeft,attr,omitempty"`
  160. TabSelected bool `xml:"tabSelected,attr,omitempty"`
  161. ShowWhiteSpace *bool `xml:"showWhiteSpace,attr"`
  162. ShowOutlineSymbols bool `xml:"showOutlineSymbols,attr,omitempty"`
  163. DefaultGridColor *bool `xml:"defaultGridColor,attr"`
  164. View string `xml:"view,attr,omitempty"`
  165. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  166. ColorID int `xml:"colorId,attr,omitempty"`
  167. ZoomScale float64 `xml:"zoomScale,attr,omitempty"`
  168. ZoomScaleNormal float64 `xml:"zoomScaleNormal,attr,omitempty"`
  169. ZoomScalePageLayoutView float64 `xml:"zoomScalePageLayoutView,attr,omitempty"`
  170. ZoomScaleSheetLayoutView float64 `xml:"zoomScaleSheetLayoutView,attr,omitempty"`
  171. WorkbookViewID int `xml:"workbookViewId,attr"`
  172. Pane *xlsxPane `xml:"pane,omitempty"`
  173. Selection []*xlsxSelection `xml:"selection"`
  174. }
  175. // xlsxSelection directly maps the selection element in the namespace
  176. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Worksheet view
  177. // selection.
  178. type xlsxSelection struct {
  179. ActiveCell string `xml:"activeCell,attr,omitempty"`
  180. ActiveCellID *int `xml:"activeCellId,attr"`
  181. Pane string `xml:"pane,attr,omitempty"`
  182. SQRef string `xml:"sqref,attr,omitempty"`
  183. }
  184. // xlsxSelection directly maps the selection element. Worksheet view pane.
  185. type xlsxPane struct {
  186. ActivePane string `xml:"activePane,attr,omitempty"`
  187. State string `xml:"state,attr,omitempty"` // Either "split" or "frozen"
  188. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  189. XSplit float64 `xml:"xSplit,attr,omitempty"`
  190. YSplit float64 `xml:"ySplit,attr,omitempty"`
  191. }
  192. // xlsxSheetPr directly maps the sheetPr element in the namespace
  193. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Sheet-level
  194. // properties.
  195. type xlsxSheetPr struct {
  196. XMLName xml.Name `xml:"sheetPr"`
  197. CodeName string `xml:"codeName,attr,omitempty"`
  198. EnableFormatConditionsCalculation *bool `xml:"enableFormatConditionsCalculation,attr"`
  199. FilterMode bool `xml:"filterMode,attr,omitempty"`
  200. Published *bool `xml:"published,attr"`
  201. SyncHorizontal bool `xml:"syncHorizontal,attr,omitempty"`
  202. SyncVertical bool `xml:"syncVertical,attr,omitempty"`
  203. TransitionEntry bool `xml:"transitionEntry,attr,omitempty"`
  204. TabColor *xlsxTabColor `xml:"tabColor,omitempty"`
  205. PageSetUpPr *xlsxPageSetUpPr `xml:"pageSetUpPr,omitempty"`
  206. OutlinePr *xlsxOutlinePr `xml:"outlinePr,omitempty"`
  207. }
  208. // xlsxOutlinePr maps to the outlinePr element
  209. // SummaryBelow allows you to adjust the direction of grouper controls
  210. type xlsxOutlinePr struct {
  211. SummaryBelow bool `xml:"summaryBelow,attr"`
  212. }
  213. // xlsxPageSetUpPr directly maps the pageSetupPr element in the namespace
  214. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page setup
  215. // properties of the worksheet.
  216. type xlsxPageSetUpPr struct {
  217. AutoPageBreaks bool `xml:"autoPageBreaks,attr,omitempty"`
  218. FitToPage bool `xml:"fitToPage,attr,omitempty"` // Flag indicating whether the Fit to Page print option is enabled.
  219. }
  220. // xlsxTabColor directly maps the tabColor element in the namespace currently I
  221. // have not checked it for completeness - it does as much as I need.
  222. type xlsxTabColor struct {
  223. RGB string `xml:"rgb,attr,omitempty"`
  224. Theme int `xml:"theme,attr,omitempty"`
  225. Tint float64 `xml:"tint,attr,omitempty"`
  226. }
  227. // xlsxCols directly maps the cols element in the namespace
  228. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  229. // not checked it for completeness - it does as much as I need.
  230. type xlsxCols struct {
  231. Col []xlsxCol `xml:"col"`
  232. }
  233. // xlsxCol directly maps the col (Column Width & Formatting). Defines column
  234. // width and column formatting for one or more columns of the worksheet.
  235. type xlsxCol struct {
  236. BestFit bool `xml:"bestFit,attr,omitempty"`
  237. Collapsed bool `xml:"collapsed,attr"`
  238. CustomWidth bool `xml:"customWidth,attr,omitempty"`
  239. Hidden bool `xml:"hidden,attr"`
  240. Max int `xml:"max,attr"`
  241. Min int `xml:"min,attr"`
  242. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  243. Phonetic bool `xml:"phonetic,attr,omitempty"`
  244. Style int `xml:"style,attr"`
  245. Width float64 `xml:"width,attr"`
  246. }
  247. // xlsxDimension directly maps the dimension element in the namespace
  248. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - This element
  249. // specifies the used range of the worksheet. It specifies the row and column
  250. // bounds of used cells in the worksheet. This is optional and is not required.
  251. // Used cells include cells with formulas, text content, and cell formatting.
  252. // When an entire column is formatted, only the first cell in that column is
  253. // considered used.
  254. type xlsxDimension struct {
  255. Ref string `xml:"ref,attr"`
  256. }
  257. // xlsxSheetData directly maps the sheetData element in the namespace
  258. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  259. // not checked it for completeness - it does as much as I need.
  260. type xlsxSheetData struct {
  261. XMLName xml.Name `xml:"sheetData"`
  262. Row []xlsxRow `xml:"row"`
  263. }
  264. // xlsxRow directly maps the row element. The element expresses information
  265. // about an entire row of a worksheet, and contains all cell definitions for a
  266. // particular row in the worksheet.
  267. type xlsxRow struct {
  268. Collapsed bool `xml:"collapsed,attr,omitempty"`
  269. CustomFormat bool `xml:"customFormat,attr,omitempty"`
  270. CustomHeight bool `xml:"customHeight,attr,omitempty"`
  271. Hidden bool `xml:"hidden,attr,omitempty"`
  272. Ht float64 `xml:"ht,attr,omitempty"`
  273. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  274. Ph bool `xml:"ph,attr,omitempty"`
  275. R int `xml:"r,attr,omitempty"`
  276. S int `xml:"s,attr,omitempty"`
  277. Spans string `xml:"spans,attr,omitempty"`
  278. ThickBot bool `xml:"thickBot,attr,omitempty"`
  279. ThickTop bool `xml:"thickTop,attr,omitempty"`
  280. C []xlsxC `xml:"c"`
  281. }
  282. // xlsxCustomSheetViews directly maps the customSheetViews element. This is a
  283. // collection of custom sheet views.
  284. type xlsxCustomSheetViews struct {
  285. CustomSheetView []*xlsxCustomSheetView `xml:"customSheetView"`
  286. }
  287. // xlsxBrk directly maps the row or column break to use when paginating a
  288. // worksheet.
  289. type xlsxBrk struct {
  290. ID int `xml:"id,attr,omitempty"`
  291. Min int `xml:"min,attr,omitempty"`
  292. Max int `xml:"max,attr,omitempty"`
  293. Man bool `xml:"man,attr,omitempty"`
  294. Pt bool `xml:"pt,attr,omitempty"`
  295. }
  296. // xlsxBreaks directly maps a collection of the row or column breaks.
  297. type xlsxBreaks struct {
  298. Brk *xlsxBrk `xml:"brk"`
  299. Count int `xml:"count,attr,omitempty"`
  300. ManualBreakCount int `xml:"manualBreakCount,attr,omitempty"`
  301. }
  302. // xlsxCustomSheetView directly maps the customSheetView element.
  303. type xlsxCustomSheetView struct {
  304. Pane *xlsxPane `xml:"pane"`
  305. Selection *xlsxSelection `xml:"selection"`
  306. RowBreaks *xlsxBreaks `xml:"rowBreaks"`
  307. ColBreaks *xlsxBreaks `xml:"colBreaks"`
  308. PageMargins *xlsxPageMargins `xml:"pageMargins"`
  309. PrintOptions *xlsxPrintOptions `xml:"printOptions"`
  310. PageSetup *xlsxPageSetUp `xml:"pageSetup"`
  311. HeaderFooter *xlsxHeaderFooter `xml:"headerFooter"`
  312. AutoFilter *xlsxAutoFilter `xml:"autoFilter"`
  313. ExtLst *xlsxExtLst `xml:"extLst"`
  314. GUID string `xml:"guid,attr"`
  315. Scale int `xml:"scale,attr,omitempty"`
  316. ColorID int `xml:"colorId,attr,omitempty"`
  317. ShowPageBreaks bool `xml:"showPageBreaks,attr,omitempty"`
  318. ShowFormulas bool `xml:"showFormulas,attr,omitempty"`
  319. ShowGridLines bool `xml:"showGridLines,attr,omitempty"`
  320. ShowRowCol bool `xml:"showRowCol,attr,omitempty"`
  321. OutlineSymbols bool `xml:"outlineSymbols,attr,omitempty"`
  322. ZeroValues bool `xml:"zeroValues,attr,omitempty"`
  323. FitToPage bool `xml:"fitToPage,attr,omitempty"`
  324. PrintArea bool `xml:"printArea,attr,omitempty"`
  325. Filter bool `xml:"filter,attr,omitempty"`
  326. ShowAutoFilter bool `xml:"showAutoFilter,attr,omitempty"`
  327. HiddenRows bool `xml:"hiddenRows,attr,omitempty"`
  328. HiddenColumns bool `xml:"hiddenColumns,attr,omitempty"`
  329. State string `xml:"state,attr,omitempty"`
  330. FilterUnique bool `xml:"filterUnique,attr,omitempty"`
  331. View string `xml:"view,attr,omitempty"`
  332. ShowRuler bool `xml:"showRuler,attr,omitempty"`
  333. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  334. }
  335. // xlsxMergeCell directly maps the mergeCell element. A single merged cell.
  336. type xlsxMergeCell struct {
  337. Ref string `xml:"ref,attr,omitempty"`
  338. }
  339. // xlsxMergeCells directly maps the mergeCells element. This collection
  340. // expresses all the merged cells in the sheet.
  341. type xlsxMergeCells struct {
  342. Count int `xml:"count,attr,omitempty"`
  343. Cells []*xlsxMergeCell `xml:"mergeCell,omitempty"`
  344. }
  345. // xlsxDataValidations expresses all data validation information for cells in a
  346. // sheet which have data validation features applied.
  347. type xlsxDataValidations struct {
  348. Count int `xml:"count,attr,omitempty"`
  349. DisablePrompts bool `xml:"disablePrompts,attr,omitempty"`
  350. XWindow int `xml:"xWindow,attr,omitempty"`
  351. YWindow int `xml:"yWindow,attr,omitempty"`
  352. DataValidation []*DataValidation `xml:"dataValidation"`
  353. }
  354. // DataValidation directly maps the a single item of data validation defined
  355. // on a range of the worksheet.
  356. type DataValidation struct {
  357. AllowBlank bool `xml:"allowBlank,attr"`
  358. Error *string `xml:"error,attr"`
  359. ErrorStyle *string `xml:"errorStyle,attr"`
  360. ErrorTitle *string `xml:"errorTitle,attr"`
  361. Operator string `xml:"operator,attr,omitempty"`
  362. Prompt *string `xml:"prompt,attr"`
  363. PromptTitle *string `xml:"promptTitle,attr"`
  364. ShowDropDown bool `xml:"showDropDown,attr,omitempty"`
  365. ShowErrorMessage bool `xml:"showErrorMessage,attr,omitempty"`
  366. ShowInputMessage bool `xml:"showInputMessage,attr,omitempty"`
  367. Sqref string `xml:"sqref,attr"`
  368. Type string `xml:"type,attr"`
  369. Formula1 string `xml:",innerxml"`
  370. Formula2 string `xml:",innerxml"`
  371. }
  372. // xlsxC directly maps the c element in the namespace
  373. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  374. // not checked it for completeness - it does as much as I need.
  375. //
  376. // This simple type is restricted to the values listed in the following table:
  377. //
  378. // Enumeration Value | Description
  379. // ---------------------------+---------------------------------
  380. // b (Boolean) | Cell containing a boolean.
  381. // d (Date) | Cell contains a date in the ISO 8601 format.
  382. // e (Error) | Cell containing an error.
  383. // inlineStr (Inline String) | Cell containing an (inline) rich string, i.e., one not in the shared string table. If this cell type is used, then the cell value is in the is element rather than the v element in the cell (c element).
  384. // n (Number) | Cell containing a number.
  385. // s (Shared String) | Cell containing a shared string.
  386. // str (String) | Cell containing a formula string.
  387. //
  388. type xlsxC struct {
  389. R string `xml:"r,attr"` // Cell ID, e.g. A1
  390. S int `xml:"s,attr,omitempty"` // Style reference.
  391. // Str string `xml:"str,attr,omitempty"` // Style reference.
  392. T string `xml:"t,attr,omitempty"` // Type.
  393. F *xlsxF `xml:"f,omitempty"` // Formula
  394. V string `xml:"v,omitempty"` // Value
  395. IS *xlsxIS `xml:"is"`
  396. XMLSpace xml.Attr `xml:"space,attr,omitempty"`
  397. }
  398. // xlsxIS directly maps the t element. Cell containing an (inline) rich
  399. // string, i.e., one not in the shared string table. If this cell type is
  400. // used, then the cell value is in the is element rather than the v element in
  401. // the cell (c element).
  402. type xlsxIS struct {
  403. T string `xml:"t"`
  404. }
  405. // xlsxF directly maps the f element in the namespace
  406. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  407. // not checked it for completeness - it does as much as I need.
  408. type xlsxF struct {
  409. Content string `xml:",chardata"`
  410. T string `xml:"t,attr,omitempty"` // Formula type
  411. Ref string `xml:"ref,attr,omitempty"` // Shared formula ref
  412. Si string `xml:"si,attr,omitempty"` // Shared formula index
  413. }
  414. // xlsxSheetProtection collection expresses the sheet protection options to
  415. // enforce when the sheet is protected.
  416. type xlsxSheetProtection struct {
  417. AlgorithmName string `xml:"algorithmName,attr,omitempty"`
  418. Password string `xml:"password,attr,omitempty"`
  419. HashValue string `xml:"hashValue,attr,omitempty"`
  420. SaltValue string `xml:"saltValue,attr,omitempty"`
  421. SpinCount int `xml:"spinCount,attr,omitempty"`
  422. Sheet bool `xml:"sheet,attr"`
  423. Objects bool `xml:"objects,attr"`
  424. Scenarios bool `xml:"scenarios,attr"`
  425. FormatCells bool `xml:"formatCells,attr"`
  426. FormatColumns bool `xml:"formatColumns,attr"`
  427. FormatRows bool `xml:"formatRows,attr"`
  428. InsertColumns bool `xml:"insertColumns,attr"`
  429. InsertRows bool `xml:"insertRows,attr"`
  430. InsertHyperlinks bool `xml:"insertHyperlinks,attr"`
  431. DeleteColumns bool `xml:"deleteColumns,attr"`
  432. DeleteRows bool `xml:"deleteRows,attr"`
  433. SelectLockedCells bool `xml:"selectLockedCells,attr"`
  434. Sort bool `xml:"sort,attr"`
  435. AutoFilter bool `xml:"autoFilter,attr"`
  436. PivotTables bool `xml:"pivotTables,attr"`
  437. SelectUnlockedCells bool `xml:"selectUnlockedCells,attr"`
  438. }
  439. // xlsxPhoneticPr (Phonetic Properties) represents a collection of phonetic
  440. // properties that affect the display of phonetic text for this String Item
  441. // (si). Phonetic text is used to give hints as to the pronunciation of an East
  442. // Asian language, and the hints are displayed as text within the spreadsheet
  443. // cells across the top portion of the cell. Since the phonetic hints are text,
  444. // every phonetic hint is expressed as a phonetic run (rPh), and these
  445. // properties specify how to display that phonetic run.
  446. type xlsxPhoneticPr struct {
  447. Alignment string `xml:"alignment,attr,omitempty"`
  448. FontID *int `xml:"fontId,attr"`
  449. Type string `xml:"type,attr,omitempty"`
  450. }
  451. // A Conditional Format is a format, such as cell shading or font color, that a
  452. // spreadsheet application can automatically apply to cells if a specified
  453. // condition is true. This collection expresses conditional formatting rules
  454. // applied to a particular cell or range.
  455. type xlsxConditionalFormatting struct {
  456. SQRef string `xml:"sqref,attr,omitempty"`
  457. CfRule []*xlsxCfRule `xml:"cfRule"`
  458. }
  459. // xlsxCfRule (Conditional Formatting Rule) represents a description of a
  460. // conditional formatting rule.
  461. type xlsxCfRule struct {
  462. AboveAverage *bool `xml:"aboveAverage,attr"`
  463. Bottom bool `xml:"bottom,attr,omitempty"`
  464. DxfID *int `xml:"dxfId,attr"`
  465. EqualAverage bool `xml:"equalAverage,attr,omitempty"`
  466. Operator string `xml:"operator,attr,omitempty"`
  467. Percent bool `xml:"percent,attr,omitempty"`
  468. Priority int `xml:"priority,attr,omitempty"`
  469. Rank int `xml:"rank,attr,omitempty"`
  470. StdDev int `xml:"stdDev,attr,omitempty"`
  471. StopIfTrue bool `xml:"stopIfTrue,attr,omitempty"`
  472. Text string `xml:"text,attr,omitempty"`
  473. TimePeriod string `xml:"timePeriod,attr,omitempty"`
  474. Type string `xml:"type,attr,omitempty"`
  475. Formula []string `xml:"formula,omitempty"`
  476. ColorScale *xlsxColorScale `xml:"colorScale"`
  477. DataBar *xlsxDataBar `xml:"dataBar"`
  478. IconSet *xlsxIconSet `xml:"iconSet"`
  479. ExtLst *xlsxExtLst `xml:"extLst"`
  480. }
  481. // xlsxColorScale (Color Scale) describes a gradated color scale in this
  482. // conditional formatting rule.
  483. type xlsxColorScale struct {
  484. Cfvo []*xlsxCfvo `xml:"cfvo"`
  485. Color []*xlsxColor `xml:"color"`
  486. }
  487. // dataBar (Data Bar) describes a data bar conditional formatting rule.
  488. type xlsxDataBar struct {
  489. MaxLength int `xml:"maxLength,attr,omitempty"`
  490. MinLength int `xml:"minLength,attr,omitempty"`
  491. ShowValue bool `xml:"showValue,attr,omitempty"`
  492. Cfvo []*xlsxCfvo `xml:"cfvo"`
  493. Color []*xlsxColor `xml:"color"`
  494. }
  495. // xlsxIconSet (Icon Set) describes an icon set conditional formatting rule.
  496. type xlsxIconSet struct {
  497. Cfvo []*xlsxCfvo `xml:"cfvo"`
  498. IconSet string `xml:"iconSet,attr,omitempty"`
  499. ShowValue bool `xml:"showValue,attr,omitempty"`
  500. Percent bool `xml:"percent,attr,omitempty"`
  501. Reverse bool `xml:"reverse,attr,omitempty"`
  502. }
  503. // cfvo (Conditional Format Value Object) describes the values of the
  504. // interpolation points in a gradient scale.
  505. type xlsxCfvo struct {
  506. Gte bool `xml:"gte,attr,omitempty"`
  507. Type string `xml:"type,attr,omitempty"`
  508. Val string `xml:"val,attr,omitempty"`
  509. ExtLst *xlsxExtLst `xml:"extLst"`
  510. }
  511. // xlsxHyperlinks directly maps the hyperlinks element in the namespace
  512. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - A hyperlink can
  513. // be stored in a package as a relationship. Hyperlinks shall be identified by
  514. // containing a target which specifies the destination of the given hyperlink.
  515. type xlsxHyperlinks struct {
  516. Hyperlink []xlsxHyperlink `xml:"hyperlink"`
  517. }
  518. // xlsxHyperlink directly maps the hyperlink element in the namespace
  519. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  520. type xlsxHyperlink struct {
  521. Ref string `xml:"ref,attr"`
  522. Location string `xml:"location,attr,omitempty"`
  523. Display string `xml:"display,attr,omitempty"`
  524. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  525. }
  526. // xlsxTableParts directly maps the tableParts element in the namespace
  527. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - The table element
  528. // has several attributes applied to identify the table and the data range it
  529. // covers. The table id attribute needs to be unique across all table parts, the
  530. // same goes for the name and displayName. The displayName has the further
  531. // restriction that it must be unique across all defined names in the workbook.
  532. // Later on we will see that you can define names for many elements, such as
  533. // cells or formulas. The name value is used for the object model in Microsoft
  534. // Office Excel. The displayName is used for references in formulas. The ref
  535. // attribute is used to identify the cell range that the table covers. This
  536. // includes not only the table data, but also the table header containing column
  537. // names.
  538. // To add columns to your table you add new tableColumn elements to the
  539. // tableColumns container. Similar to the shared string table the collection
  540. // keeps a count attribute identifying the number of columns. Besides the table
  541. // definition in the table part there is also the need to identify which tables
  542. // are displayed in the worksheet. The worksheet part has a separate element
  543. // tableParts to store this information. Each table part is referenced through
  544. // the relationship ID and again a count of the number of table parts is
  545. // maintained. The following markup sample is taken from the documents
  546. // accompanying this book. The sheet data element has been removed to reduce the
  547. // size of the sample. To reference the table, just add the tableParts element,
  548. // of course after having created and stored the table part. For example:
  549. //
  550. // <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  551. // ...
  552. // <tableParts count="1">
  553. // <tablePart r:id="rId1" />
  554. // </tableParts>
  555. // </worksheet>
  556. //
  557. type xlsxTableParts struct {
  558. Count int `xml:"count,attr,omitempty"`
  559. TableParts []*xlsxTablePart `xml:"tablePart"`
  560. }
  561. // xlsxTablePart directly maps the tablePart element in the namespace
  562. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  563. type xlsxTablePart struct {
  564. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  565. }
  566. // xlsxPicture directly maps the picture element in the namespace
  567. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Background sheet
  568. // image. For example:
  569. //
  570. // <picture r:id="rId1"/>
  571. //
  572. type xlsxPicture struct {
  573. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  574. }
  575. // xlsxLegacyDrawing directly maps the legacyDrawing element in the namespace
  576. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - A comment is a
  577. // rich text note that is attached to, and associated with, a cell, separate
  578. // from other cell content. Comment content is stored separate from the cell,
  579. // and is displayed in a drawing object (like a text box) that is separate from,
  580. // but associated with, a cell. Comments are used as reminders, such as noting
  581. // how a complex formula works, or to provide feedback to other users. Comments
  582. // can also be used to explain assumptions made in a formula or to call out
  583. // something special about the cell.
  584. type xlsxLegacyDrawing struct {
  585. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  586. }
  587. // xlsxWorksheetExt directly maps the ext element in the worksheet.
  588. type xlsxWorksheetExt struct {
  589. XMLName xml.Name `xml:"ext"`
  590. XMLNSX14 string `xml:"xmlns:x14,attr,omitempty"`
  591. XMLNSX15 string `xml:"xmlns:x15,attr,omitempty"`
  592. X14 string `xml:"x14,attr,omitempty"`
  593. X15 string `xml:"x15,attr,omitempty"`
  594. URI string `xml:"uri,attr"`
  595. Content string `xml:",innerxml"`
  596. }
  597. // decodeWorksheetExt directly maps the ext element.
  598. type decodeWorksheetExt struct {
  599. XMLName xml.Name `xml:"extLst"`
  600. Ext []*xlsxWorksheetExt `xml:"ext"`
  601. }
  602. // decodeX14SparklineGroups directly maps the sparklineGroups element.
  603. type decodeX14SparklineGroups struct {
  604. XMLName xml.Name `xml:"sparklineGroups"`
  605. XMLNSXM string `xml:"xmlns:xm,attr"`
  606. Content string `xml:",innerxml"`
  607. }
  608. // xlsxX14SparklineGroups directly maps the sparklineGroups element.
  609. type xlsxX14SparklineGroups struct {
  610. XMLName xml.Name `xml:"x14:sparklineGroups"`
  611. XMLNSXM string `xml:"xmlns:xm,attr"`
  612. SparklineGroups []*xlsxX14SparklineGroup `xml:"x14:sparklineGroup"`
  613. Content string `xml:",innerxml"`
  614. }
  615. // xlsxX14SparklineGroup directly maps the sparklineGroup element.
  616. type xlsxX14SparklineGroup struct {
  617. XMLName xml.Name `xml:"x14:sparklineGroup"`
  618. ManualMax int `xml:"manualMax,attr,omitempty"`
  619. ManualMin int `xml:"manualMin,attr,omitempty"`
  620. LineWeight float64 `xml:"lineWeight,attr,omitempty"`
  621. Type string `xml:"type,attr,omitempty"`
  622. DateAxis bool `xml:"dateAxis,attr,omitempty"`
  623. DisplayEmptyCellsAs string `xml:"displayEmptyCellsAs,attr,omitempty"`
  624. Markers bool `xml:"markers,attr,omitempty"`
  625. High bool `xml:"high,attr,omitempty"`
  626. Low bool `xml:"low,attr,omitempty"`
  627. First bool `xml:"first,attr,omitempty"`
  628. Last bool `xml:"last,attr,omitempty"`
  629. Negative bool `xml:"negative,attr,omitempty"`
  630. DisplayXAxis bool `xml:"displayXAxis,attr,omitempty"`
  631. DisplayHidden bool `xml:"displayHidden,attr,omitempty"`
  632. MinAxisType string `xml:"minAxisType,attr,omitempty"`
  633. MaxAxisType string `xml:"maxAxisType,attr,omitempty"`
  634. RightToLeft bool `xml:"rightToLeft,attr,omitempty"`
  635. ColorSeries *xlsxTabColor `xml:"x14:colorSeries"`
  636. ColorNegative *xlsxTabColor `xml:"x14:colorNegative"`
  637. ColorAxis *xlsxColor `xml:"x14:colorAxis"`
  638. ColorMarkers *xlsxTabColor `xml:"x14:colorMarkers"`
  639. ColorFirst *xlsxTabColor `xml:"x14:colorFirst"`
  640. ColorLast *xlsxTabColor `xml:"x14:colorLast"`
  641. ColorHigh *xlsxTabColor `xml:"x14:colorHigh"`
  642. ColorLow *xlsxTabColor `xml:"x14:colorLow"`
  643. Sparklines xlsxX14Sparklines `xml:"x14:sparklines"`
  644. }
  645. // xlsxX14Sparklines directly maps the sparklines element.
  646. type xlsxX14Sparklines struct {
  647. Sparkline []*xlsxX14Sparkline `xml:"x14:sparkline"`
  648. }
  649. // xlsxX14Sparkline directly maps the sparkline element.
  650. type xlsxX14Sparkline struct {
  651. F string `xml:"xm:f"`
  652. Sqref string `xml:"xm:sqref"`
  653. }
  654. // SparklineOption directly maps the settings of the sparkline.
  655. type SparklineOption struct {
  656. Location []string
  657. Range []string
  658. Max int
  659. CustMax int
  660. Min int
  661. CustMin int
  662. Type string
  663. Weight float64
  664. DateAxis bool
  665. Markers bool
  666. High bool
  667. Low bool
  668. First bool
  669. Last bool
  670. Negative bool
  671. Axis bool
  672. Hidden bool
  673. Reverse bool
  674. Style int
  675. SeriesColor string
  676. NegativeColor string
  677. MarkersColor string
  678. FirstColor string
  679. LastColor string
  680. HightColor string
  681. LowColor string
  682. EmptyCells string
  683. }
  684. // formatPanes directly maps the settings of the panes.
  685. type formatPanes struct {
  686. Freeze bool `json:"freeze"`
  687. Split bool `json:"split"`
  688. XSplit int `json:"x_split"`
  689. YSplit int `json:"y_split"`
  690. TopLeftCell string `json:"top_left_cell"`
  691. ActivePane string `json:"active_pane"`
  692. Panes []struct {
  693. SQRef string `json:"sqref"`
  694. ActiveCell string `json:"active_cell"`
  695. Pane string `json:"pane"`
  696. } `json:"panes"`
  697. }
  698. // formatConditional directly maps the conditional format settings of the cells.
  699. type formatConditional struct {
  700. Type string `json:"type"`
  701. AboveAverage bool `json:"above_average"`
  702. Percent bool `json:"percent"`
  703. Format int `json:"format"`
  704. Criteria string `json:"criteria"`
  705. Value string `json:"value,omitempty"`
  706. Minimum string `json:"minimum,omitempty"`
  707. Maximum string `json:"maximum,omitempty"`
  708. MinType string `json:"min_type,omitempty"`
  709. MidType string `json:"mid_type,omitempty"`
  710. MaxType string `json:"max_type,omitempty"`
  711. MinValue string `json:"min_value,omitempty"`
  712. MidValue string `json:"mid_value,omitempty"`
  713. MaxValue string `json:"max_value,omitempty"`
  714. MinColor string `json:"min_color,omitempty"`
  715. MidColor string `json:"mid_color,omitempty"`
  716. MaxColor string `json:"max_color,omitempty"`
  717. MinLength string `json:"min_length,omitempty"`
  718. MaxLength string `json:"max_length,omitempty"`
  719. MultiRange string `json:"multi_range,omitempty"`
  720. BarColor string `json:"bar_color,omitempty"`
  721. }
  722. // FormatSheetProtection directly maps the settings of worksheet protection.
  723. type FormatSheetProtection struct {
  724. AutoFilter bool
  725. DeleteColumns bool
  726. DeleteRows bool
  727. EditObjects bool
  728. EditScenarios bool
  729. FormatCells bool
  730. FormatColumns bool
  731. FormatRows bool
  732. InsertColumns bool
  733. InsertHyperlinks bool
  734. InsertRows bool
  735. Password string
  736. PivotTables bool
  737. SelectLockedCells bool
  738. SelectUnlockedCells bool
  739. Sort bool
  740. }
  741. // FormatHeaderFooter directly maps the settings of header and footer.
  742. type FormatHeaderFooter struct {
  743. AlignWithMargins bool
  744. DifferentFirst bool
  745. DifferentOddEven bool
  746. ScaleWithDoc bool
  747. OddHeader string
  748. OddFooter string
  749. EvenHeader string
  750. EvenFooter string
  751. FirstFooter string
  752. FirstHeader string
  753. }