xmlWorksheet.go 40 KB

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