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.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,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. SyncHorizontal bool `xml:"syncHorizontal,attr,omitempty"`
  198. SyncVertical bool `xml:"syncVertical,attr,omitempty"`
  199. SyncRef string `xml:"syncRef,attr,omitempty"`
  200. TransitionEvaluation bool `xml:"transitionEvaluation,attr,omitempty"`
  201. Published *bool `xml:"published,attr"`
  202. CodeName string `xml:"codeName,attr,omitempty"`
  203. FilterMode bool `xml:"filterMode,attr,omitempty"`
  204. EnableFormatConditionsCalculation *bool `xml:"enableFormatConditionsCalculation,attr"`
  205. TransitionEntry bool `xml:"transitionEntry,attr,omitempty"`
  206. TabColor *xlsxTabColor `xml:"tabColor,omitempty"`
  207. OutlinePr *xlsxOutlinePr `xml:"outlinePr,omitempty"`
  208. PageSetUpPr *xlsxPageSetUpPr `xml:"pageSetUpPr,omitempty"`
  209. }
  210. // xlsxOutlinePr maps to the outlinePr element
  211. // SummaryBelow allows you to adjust the direction of grouper controls
  212. type xlsxOutlinePr struct {
  213. SummaryBelow bool `xml:"summaryBelow,attr"`
  214. }
  215. // xlsxPageSetUpPr directly maps the pageSetupPr element in the namespace
  216. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page setup
  217. // properties of the worksheet.
  218. type xlsxPageSetUpPr struct {
  219. AutoPageBreaks bool `xml:"autoPageBreaks,attr,omitempty"`
  220. FitToPage bool `xml:"fitToPage,attr,omitempty"` // Flag indicating whether the Fit to Page print option is enabled.
  221. }
  222. // xlsxTabColor directly maps the tabColor element in the namespace currently I
  223. // have not checked it for completeness - it does as much as I need.
  224. type xlsxTabColor struct {
  225. RGB string `xml:"rgb,attr,omitempty"`
  226. Theme int `xml:"theme,attr,omitempty"`
  227. Tint float64 `xml:"tint,attr,omitempty"`
  228. }
  229. // xlsxCols directly maps the cols element in the namespace
  230. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  231. // not checked it for completeness - it does as much as I need.
  232. type xlsxCols struct {
  233. Col []xlsxCol `xml:"col"`
  234. }
  235. // xlsxCol directly maps the col (Column Width & Formatting). Defines column
  236. // width and column formatting for one or more columns of the worksheet.
  237. type xlsxCol struct {
  238. BestFit bool `xml:"bestFit,attr,omitempty"`
  239. Collapsed bool `xml:"collapsed,attr"`
  240. CustomWidth bool `xml:"customWidth,attr,omitempty"`
  241. Hidden bool `xml:"hidden,attr"`
  242. Max int `xml:"max,attr"`
  243. Min int `xml:"min,attr"`
  244. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  245. Phonetic bool `xml:"phonetic,attr,omitempty"`
  246. Style int `xml:"style,attr"`
  247. Width float64 `xml:"width,attr"`
  248. }
  249. // xlsxDimension directly maps the dimension element in the namespace
  250. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - This element
  251. // specifies the used range of the worksheet. It specifies the row and column
  252. // bounds of used cells in the worksheet. This is optional and is not required.
  253. // Used cells include cells with formulas, text content, and cell formatting.
  254. // When an entire column is formatted, only the first cell in that column is
  255. // considered used.
  256. type xlsxDimension struct {
  257. Ref string `xml:"ref,attr"`
  258. }
  259. // xlsxSheetData directly maps the sheetData element in the namespace
  260. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  261. // not checked it for completeness - it does as much as I need.
  262. type xlsxSheetData struct {
  263. XMLName xml.Name `xml:"sheetData"`
  264. Row []xlsxRow `xml:"row"`
  265. }
  266. // xlsxRow directly maps the row element. The element expresses information
  267. // about an entire row of a worksheet, and contains all cell definitions for a
  268. // particular row in the worksheet.
  269. type xlsxRow struct {
  270. Collapsed bool `xml:"collapsed,attr,omitempty"`
  271. CustomFormat bool `xml:"customFormat,attr,omitempty"`
  272. CustomHeight bool `xml:"customHeight,attr,omitempty"`
  273. Hidden bool `xml:"hidden,attr,omitempty"`
  274. Ht float64 `xml:"ht,attr,omitempty"`
  275. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  276. Ph bool `xml:"ph,attr,omitempty"`
  277. R int `xml:"r,attr,omitempty"`
  278. S int `xml:"s,attr,omitempty"`
  279. Spans string `xml:"spans,attr,omitempty"`
  280. ThickBot bool `xml:"thickBot,attr,omitempty"`
  281. ThickTop bool `xml:"thickTop,attr,omitempty"`
  282. C []xlsxC `xml:"c"`
  283. }
  284. // xlsxCustomSheetViews directly maps the customSheetViews element. This is a
  285. // collection of custom sheet views.
  286. type xlsxCustomSheetViews struct {
  287. CustomSheetView []*xlsxCustomSheetView `xml:"customSheetView"`
  288. }
  289. // xlsxBrk directly maps the row or column break to use when paginating a
  290. // worksheet.
  291. type xlsxBrk struct {
  292. ID int `xml:"id,attr,omitempty"`
  293. Min int `xml:"min,attr,omitempty"`
  294. Max int `xml:"max,attr,omitempty"`
  295. Man bool `xml:"man,attr,omitempty"`
  296. Pt bool `xml:"pt,attr,omitempty"`
  297. }
  298. // xlsxBreaks directly maps a collection of the row or column breaks.
  299. type xlsxBreaks struct {
  300. Brk *xlsxBrk `xml:"brk"`
  301. Count int `xml:"count,attr,omitempty"`
  302. ManualBreakCount int `xml:"manualBreakCount,attr,omitempty"`
  303. }
  304. // xlsxCustomSheetView directly maps the customSheetView element.
  305. type xlsxCustomSheetView struct {
  306. Pane *xlsxPane `xml:"pane"`
  307. Selection *xlsxSelection `xml:"selection"`
  308. RowBreaks *xlsxBreaks `xml:"rowBreaks"`
  309. ColBreaks *xlsxBreaks `xml:"colBreaks"`
  310. PageMargins *xlsxPageMargins `xml:"pageMargins"`
  311. PrintOptions *xlsxPrintOptions `xml:"printOptions"`
  312. PageSetup *xlsxPageSetUp `xml:"pageSetup"`
  313. HeaderFooter *xlsxHeaderFooter `xml:"headerFooter"`
  314. AutoFilter *xlsxAutoFilter `xml:"autoFilter"`
  315. ExtLst *xlsxExtLst `xml:"extLst"`
  316. GUID string `xml:"guid,attr"`
  317. Scale int `xml:"scale,attr,omitempty"`
  318. ColorID int `xml:"colorId,attr,omitempty"`
  319. ShowPageBreaks bool `xml:"showPageBreaks,attr,omitempty"`
  320. ShowFormulas bool `xml:"showFormulas,attr,omitempty"`
  321. ShowGridLines bool `xml:"showGridLines,attr,omitempty"`
  322. ShowRowCol bool `xml:"showRowCol,attr,omitempty"`
  323. OutlineSymbols bool `xml:"outlineSymbols,attr,omitempty"`
  324. ZeroValues bool `xml:"zeroValues,attr,omitempty"`
  325. FitToPage bool `xml:"fitToPage,attr,omitempty"`
  326. PrintArea bool `xml:"printArea,attr,omitempty"`
  327. Filter bool `xml:"filter,attr,omitempty"`
  328. ShowAutoFilter bool `xml:"showAutoFilter,attr,omitempty"`
  329. HiddenRows bool `xml:"hiddenRows,attr,omitempty"`
  330. HiddenColumns bool `xml:"hiddenColumns,attr,omitempty"`
  331. State string `xml:"state,attr,omitempty"`
  332. FilterUnique bool `xml:"filterUnique,attr,omitempty"`
  333. View string `xml:"view,attr,omitempty"`
  334. ShowRuler bool `xml:"showRuler,attr,omitempty"`
  335. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  336. }
  337. // xlsxMergeCell directly maps the mergeCell element. A single merged cell.
  338. type xlsxMergeCell struct {
  339. Ref string `xml:"ref,attr,omitempty"`
  340. }
  341. // xlsxMergeCells directly maps the mergeCells element. This collection
  342. // expresses all the merged cells in the sheet.
  343. type xlsxMergeCells struct {
  344. Count int `xml:"count,attr,omitempty"`
  345. Cells []*xlsxMergeCell `xml:"mergeCell,omitempty"`
  346. }
  347. // xlsxDataValidations expresses all data validation information for cells in a
  348. // sheet which have data validation features applied.
  349. type xlsxDataValidations struct {
  350. Count int `xml:"count,attr,omitempty"`
  351. DisablePrompts bool `xml:"disablePrompts,attr,omitempty"`
  352. XWindow int `xml:"xWindow,attr,omitempty"`
  353. YWindow int `xml:"yWindow,attr,omitempty"`
  354. DataValidation []*DataValidation `xml:"dataValidation"`
  355. }
  356. // DataValidation directly maps the a single item of data validation defined
  357. // on a range of the worksheet.
  358. type DataValidation struct {
  359. AllowBlank bool `xml:"allowBlank,attr"`
  360. Error *string `xml:"error,attr"`
  361. ErrorStyle *string `xml:"errorStyle,attr"`
  362. ErrorTitle *string `xml:"errorTitle,attr"`
  363. Operator string `xml:"operator,attr,omitempty"`
  364. Prompt *string `xml:"prompt,attr"`
  365. PromptTitle *string `xml:"promptTitle,attr"`
  366. ShowDropDown bool `xml:"showDropDown,attr,omitempty"`
  367. ShowErrorMessage bool `xml:"showErrorMessage,attr,omitempty"`
  368. ShowInputMessage bool `xml:"showInputMessage,attr,omitempty"`
  369. Sqref string `xml:"sqref,attr"`
  370. Type string `xml:"type,attr"`
  371. Formula1 string `xml:",innerxml"`
  372. Formula2 string `xml:",innerxml"`
  373. }
  374. // xlsxC directly maps the c element in the namespace
  375. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  376. // not checked it for completeness - it does as much as I need.
  377. //
  378. // This simple type is restricted to the values listed in the following table:
  379. //
  380. // Enumeration Value | Description
  381. // ---------------------------+---------------------------------
  382. // b (Boolean) | Cell containing a boolean.
  383. // d (Date) | Cell contains a date in the ISO 8601 format.
  384. // e (Error) | Cell containing an error.
  385. // 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).
  386. // n (Number) | Cell containing a number.
  387. // s (Shared String) | Cell containing a shared string.
  388. // str (String) | Cell containing a formula string.
  389. //
  390. type xlsxC struct {
  391. R string `xml:"r,attr"` // Cell ID, e.g. A1
  392. S int `xml:"s,attr,omitempty"` // Style reference.
  393. // Str string `xml:"str,attr,omitempty"` // Style reference.
  394. T string `xml:"t,attr,omitempty"` // Type.
  395. F *xlsxF `xml:"f,omitempty"` // Formula
  396. V string `xml:"v,omitempty"` // Value
  397. IS *xlsxSI `xml:"is"`
  398. XMLSpace xml.Attr `xml:"space,attr,omitempty"`
  399. }
  400. // xlsxF directly maps the f element in the namespace
  401. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  402. // not checked it for completeness - it does as much as I need.
  403. type xlsxF struct {
  404. Content string `xml:",chardata"`
  405. T string `xml:"t,attr,omitempty"` // Formula type
  406. Ref string `xml:"ref,attr,omitempty"` // Shared formula ref
  407. Si string `xml:"si,attr,omitempty"` // Shared formula index
  408. }
  409. // xlsxSheetProtection collection expresses the sheet protection options to
  410. // enforce when the sheet is protected.
  411. type xlsxSheetProtection struct {
  412. AlgorithmName string `xml:"algorithmName,attr,omitempty"`
  413. Password string `xml:"password,attr,omitempty"`
  414. HashValue string `xml:"hashValue,attr,omitempty"`
  415. SaltValue string `xml:"saltValue,attr,omitempty"`
  416. SpinCount int `xml:"spinCount,attr,omitempty"`
  417. Sheet bool `xml:"sheet,attr"`
  418. Objects bool `xml:"objects,attr"`
  419. Scenarios bool `xml:"scenarios,attr"`
  420. FormatCells bool `xml:"formatCells,attr"`
  421. FormatColumns bool `xml:"formatColumns,attr"`
  422. FormatRows bool `xml:"formatRows,attr"`
  423. InsertColumns bool `xml:"insertColumns,attr"`
  424. InsertRows bool `xml:"insertRows,attr"`
  425. InsertHyperlinks bool `xml:"insertHyperlinks,attr"`
  426. DeleteColumns bool `xml:"deleteColumns,attr"`
  427. DeleteRows bool `xml:"deleteRows,attr"`
  428. SelectLockedCells bool `xml:"selectLockedCells,attr"`
  429. Sort bool `xml:"sort,attr"`
  430. AutoFilter bool `xml:"autoFilter,attr"`
  431. PivotTables bool `xml:"pivotTables,attr"`
  432. SelectUnlockedCells bool `xml:"selectUnlockedCells,attr"`
  433. }
  434. // xlsxPhoneticPr (Phonetic Properties) represents a collection of phonetic
  435. // properties that affect the display of phonetic text for this String Item
  436. // (si). Phonetic text is used to give hints as to the pronunciation of an East
  437. // Asian language, and the hints are displayed as text within the spreadsheet
  438. // cells across the top portion of the cell. Since the phonetic hints are text,
  439. // every phonetic hint is expressed as a phonetic run (rPh), and these
  440. // properties specify how to display that phonetic run.
  441. type xlsxPhoneticPr struct {
  442. Alignment string `xml:"alignment,attr,omitempty"`
  443. FontID *int `xml:"fontId,attr"`
  444. Type string `xml:"type,attr,omitempty"`
  445. }
  446. // A Conditional Format is a format, such as cell shading or font color, that a
  447. // spreadsheet application can automatically apply to cells if a specified
  448. // condition is true. This collection expresses conditional formatting rules
  449. // applied to a particular cell or range.
  450. type xlsxConditionalFormatting struct {
  451. SQRef string `xml:"sqref,attr,omitempty"`
  452. CfRule []*xlsxCfRule `xml:"cfRule"`
  453. }
  454. // xlsxCfRule (Conditional Formatting Rule) represents a description of a
  455. // conditional formatting rule.
  456. type xlsxCfRule struct {
  457. AboveAverage *bool `xml:"aboveAverage,attr"`
  458. Bottom bool `xml:"bottom,attr,omitempty"`
  459. DxfID *int `xml:"dxfId,attr"`
  460. EqualAverage bool `xml:"equalAverage,attr,omitempty"`
  461. Operator string `xml:"operator,attr,omitempty"`
  462. Percent bool `xml:"percent,attr,omitempty"`
  463. Priority int `xml:"priority,attr,omitempty"`
  464. Rank int `xml:"rank,attr,omitempty"`
  465. StdDev int `xml:"stdDev,attr,omitempty"`
  466. StopIfTrue bool `xml:"stopIfTrue,attr,omitempty"`
  467. Text string `xml:"text,attr,omitempty"`
  468. TimePeriod string `xml:"timePeriod,attr,omitempty"`
  469. Type string `xml:"type,attr,omitempty"`
  470. Formula []string `xml:"formula,omitempty"`
  471. ColorScale *xlsxColorScale `xml:"colorScale"`
  472. DataBar *xlsxDataBar `xml:"dataBar"`
  473. IconSet *xlsxIconSet `xml:"iconSet"`
  474. ExtLst *xlsxExtLst `xml:"extLst"`
  475. }
  476. // xlsxColorScale (Color Scale) describes a gradated color scale in this
  477. // conditional formatting rule.
  478. type xlsxColorScale struct {
  479. Cfvo []*xlsxCfvo `xml:"cfvo"`
  480. Color []*xlsxColor `xml:"color"`
  481. }
  482. // dataBar (Data Bar) describes a data bar conditional formatting rule.
  483. type xlsxDataBar struct {
  484. MaxLength int `xml:"maxLength,attr,omitempty"`
  485. MinLength int `xml:"minLength,attr,omitempty"`
  486. ShowValue bool `xml:"showValue,attr,omitempty"`
  487. Cfvo []*xlsxCfvo `xml:"cfvo"`
  488. Color []*xlsxColor `xml:"color"`
  489. }
  490. // xlsxIconSet (Icon Set) describes an icon set conditional formatting rule.
  491. type xlsxIconSet struct {
  492. Cfvo []*xlsxCfvo `xml:"cfvo"`
  493. IconSet string `xml:"iconSet,attr,omitempty"`
  494. ShowValue bool `xml:"showValue,attr,omitempty"`
  495. Percent bool `xml:"percent,attr,omitempty"`
  496. Reverse bool `xml:"reverse,attr,omitempty"`
  497. }
  498. // cfvo (Conditional Format Value Object) describes the values of the
  499. // interpolation points in a gradient scale.
  500. type xlsxCfvo struct {
  501. Gte bool `xml:"gte,attr,omitempty"`
  502. Type string `xml:"type,attr,omitempty"`
  503. Val string `xml:"val,attr,omitempty"`
  504. ExtLst *xlsxExtLst `xml:"extLst"`
  505. }
  506. // xlsxHyperlinks directly maps the hyperlinks element in the namespace
  507. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - A hyperlink can
  508. // be stored in a package as a relationship. Hyperlinks shall be identified by
  509. // containing a target which specifies the destination of the given hyperlink.
  510. type xlsxHyperlinks struct {
  511. Hyperlink []xlsxHyperlink `xml:"hyperlink"`
  512. }
  513. // xlsxHyperlink directly maps the hyperlink element in the namespace
  514. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  515. type xlsxHyperlink struct {
  516. Ref string `xml:"ref,attr"`
  517. Location string `xml:"location,attr,omitempty"`
  518. Display string `xml:"display,attr,omitempty"`
  519. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  520. }
  521. // xlsxTableParts directly maps the tableParts element in the namespace
  522. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - The table element
  523. // has several attributes applied to identify the table and the data range it
  524. // covers. The table id attribute needs to be unique across all table parts, the
  525. // same goes for the name and displayName. The displayName has the further
  526. // restriction that it must be unique across all defined names in the workbook.
  527. // Later on we will see that you can define names for many elements, such as
  528. // cells or formulas. The name value is used for the object model in Microsoft
  529. // Office Excel. The displayName is used for references in formulas. The ref
  530. // attribute is used to identify the cell range that the table covers. This
  531. // includes not only the table data, but also the table header containing column
  532. // names.
  533. // To add columns to your table you add new tableColumn elements to the
  534. // tableColumns container. Similar to the shared string table the collection
  535. // keeps a count attribute identifying the number of columns. Besides the table
  536. // definition in the table part there is also the need to identify which tables
  537. // are displayed in the worksheet. The worksheet part has a separate element
  538. // tableParts to store this information. Each table part is referenced through
  539. // the relationship ID and again a count of the number of table parts is
  540. // maintained. The following markup sample is taken from the documents
  541. // accompanying this book. The sheet data element has been removed to reduce the
  542. // size of the sample. To reference the table, just add the tableParts element,
  543. // of course after having created and stored the table part. For example:
  544. //
  545. // <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  546. // ...
  547. // <tableParts count="1">
  548. // <tablePart r:id="rId1" />
  549. // </tableParts>
  550. // </worksheet>
  551. //
  552. type xlsxTableParts struct {
  553. Count int `xml:"count,attr,omitempty"`
  554. TableParts []*xlsxTablePart `xml:"tablePart"`
  555. }
  556. // xlsxTablePart directly maps the tablePart element in the namespace
  557. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  558. type xlsxTablePart struct {
  559. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  560. }
  561. // xlsxPicture directly maps the picture element in the namespace
  562. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Background sheet
  563. // image. For example:
  564. //
  565. // <picture r:id="rId1"/>
  566. //
  567. type xlsxPicture struct {
  568. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  569. }
  570. // xlsxLegacyDrawing directly maps the legacyDrawing element in the namespace
  571. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - A comment is a
  572. // rich text note that is attached to, and associated with, a cell, separate
  573. // from other cell content. Comment content is stored separate from the cell,
  574. // and is displayed in a drawing object (like a text box) that is separate from,
  575. // but associated with, a cell. Comments are used as reminders, such as noting
  576. // how a complex formula works, or to provide feedback to other users. Comments
  577. // can also be used to explain assumptions made in a formula or to call out
  578. // something special about the cell.
  579. type xlsxLegacyDrawing struct {
  580. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  581. }
  582. // xlsxWorksheetExt directly maps the ext element in the worksheet.
  583. type xlsxWorksheetExt struct {
  584. XMLName xml.Name `xml:"ext"`
  585. URI string `xml:"uri,attr"`
  586. Content string `xml:",innerxml"`
  587. }
  588. // decodeWorksheetExt directly maps the ext element.
  589. type decodeWorksheetExt struct {
  590. XMLName xml.Name `xml:"extLst"`
  591. Ext []*xlsxWorksheetExt `xml:"ext"`
  592. }
  593. // decodeX14SparklineGroups directly maps the sparklineGroups element.
  594. type decodeX14SparklineGroups struct {
  595. XMLName xml.Name `xml:"sparklineGroups"`
  596. XMLNSXM string `xml:"xmlns:xm,attr"`
  597. Content string `xml:",innerxml"`
  598. }
  599. // xlsxX14SparklineGroups directly maps the sparklineGroups element.
  600. type xlsxX14SparklineGroups struct {
  601. XMLName xml.Name `xml:"x14:sparklineGroups"`
  602. XMLNSXM string `xml:"xmlns:xm,attr"`
  603. SparklineGroups []*xlsxX14SparklineGroup `xml:"x14:sparklineGroup"`
  604. Content string `xml:",innerxml"`
  605. }
  606. // xlsxX14SparklineGroup directly maps the sparklineGroup element.
  607. type xlsxX14SparklineGroup struct {
  608. XMLName xml.Name `xml:"x14:sparklineGroup"`
  609. ManualMax int `xml:"manualMax,attr,omitempty"`
  610. ManualMin int `xml:"manualMin,attr,omitempty"`
  611. LineWeight float64 `xml:"lineWeight,attr,omitempty"`
  612. Type string `xml:"type,attr,omitempty"`
  613. DateAxis bool `xml:"dateAxis,attr,omitempty"`
  614. DisplayEmptyCellsAs string `xml:"displayEmptyCellsAs,attr,omitempty"`
  615. Markers bool `xml:"markers,attr,omitempty"`
  616. High bool `xml:"high,attr,omitempty"`
  617. Low bool `xml:"low,attr,omitempty"`
  618. First bool `xml:"first,attr,omitempty"`
  619. Last bool `xml:"last,attr,omitempty"`
  620. Negative bool `xml:"negative,attr,omitempty"`
  621. DisplayXAxis bool `xml:"displayXAxis,attr,omitempty"`
  622. DisplayHidden bool `xml:"displayHidden,attr,omitempty"`
  623. MinAxisType string `xml:"minAxisType,attr,omitempty"`
  624. MaxAxisType string `xml:"maxAxisType,attr,omitempty"`
  625. RightToLeft bool `xml:"rightToLeft,attr,omitempty"`
  626. ColorSeries *xlsxTabColor `xml:"x14:colorSeries"`
  627. ColorNegative *xlsxTabColor `xml:"x14:colorNegative"`
  628. ColorAxis *xlsxColor `xml:"x14:colorAxis"`
  629. ColorMarkers *xlsxTabColor `xml:"x14:colorMarkers"`
  630. ColorFirst *xlsxTabColor `xml:"x14:colorFirst"`
  631. ColorLast *xlsxTabColor `xml:"x14:colorLast"`
  632. ColorHigh *xlsxTabColor `xml:"x14:colorHigh"`
  633. ColorLow *xlsxTabColor `xml:"x14:colorLow"`
  634. Sparklines xlsxX14Sparklines `xml:"x14:sparklines"`
  635. }
  636. // xlsxX14Sparklines directly maps the sparklines element.
  637. type xlsxX14Sparklines struct {
  638. Sparkline []*xlsxX14Sparkline `xml:"x14:sparkline"`
  639. }
  640. // xlsxX14Sparkline directly maps the sparkline element.
  641. type xlsxX14Sparkline struct {
  642. F string `xml:"xm:f"`
  643. Sqref string `xml:"xm:sqref"`
  644. }
  645. // SparklineOption directly maps the settings of the sparkline.
  646. type SparklineOption struct {
  647. Location []string
  648. Range []string
  649. Max int
  650. CustMax int
  651. Min int
  652. CustMin int
  653. Type string
  654. Weight float64
  655. DateAxis bool
  656. Markers bool
  657. High bool
  658. Low bool
  659. First bool
  660. Last bool
  661. Negative bool
  662. Axis bool
  663. Hidden bool
  664. Reverse bool
  665. Style int
  666. SeriesColor string
  667. NegativeColor string
  668. MarkersColor string
  669. FirstColor string
  670. LastColor string
  671. HightColor string
  672. LowColor string
  673. EmptyCells string
  674. }
  675. // formatPanes directly maps the settings of the panes.
  676. type formatPanes struct {
  677. Freeze bool `json:"freeze"`
  678. Split bool `json:"split"`
  679. XSplit int `json:"x_split"`
  680. YSplit int `json:"y_split"`
  681. TopLeftCell string `json:"top_left_cell"`
  682. ActivePane string `json:"active_pane"`
  683. Panes []struct {
  684. SQRef string `json:"sqref"`
  685. ActiveCell string `json:"active_cell"`
  686. Pane string `json:"pane"`
  687. } `json:"panes"`
  688. }
  689. // formatConditional directly maps the conditional format settings of the cells.
  690. type formatConditional struct {
  691. Type string `json:"type"`
  692. AboveAverage bool `json:"above_average"`
  693. Percent bool `json:"percent"`
  694. Format int `json:"format"`
  695. Criteria string `json:"criteria"`
  696. Value string `json:"value,omitempty"`
  697. Minimum string `json:"minimum,omitempty"`
  698. Maximum string `json:"maximum,omitempty"`
  699. MinType string `json:"min_type,omitempty"`
  700. MidType string `json:"mid_type,omitempty"`
  701. MaxType string `json:"max_type,omitempty"`
  702. MinValue string `json:"min_value,omitempty"`
  703. MidValue string `json:"mid_value,omitempty"`
  704. MaxValue string `json:"max_value,omitempty"`
  705. MinColor string `json:"min_color,omitempty"`
  706. MidColor string `json:"mid_color,omitempty"`
  707. MaxColor string `json:"max_color,omitempty"`
  708. MinLength string `json:"min_length,omitempty"`
  709. MaxLength string `json:"max_length,omitempty"`
  710. MultiRange string `json:"multi_range,omitempty"`
  711. BarColor string `json:"bar_color,omitempty"`
  712. }
  713. // FormatSheetProtection directly maps the settings of worksheet protection.
  714. type FormatSheetProtection struct {
  715. AutoFilter bool
  716. DeleteColumns bool
  717. DeleteRows bool
  718. EditObjects bool
  719. EditScenarios bool
  720. FormatCells bool
  721. FormatColumns bool
  722. FormatRows bool
  723. InsertColumns bool
  724. InsertHyperlinks bool
  725. InsertRows bool
  726. Password string
  727. PivotTables bool
  728. SelectLockedCells bool
  729. SelectUnlockedCells bool
  730. Sort bool
  731. }
  732. // FormatHeaderFooter directly maps the settings of header and footer.
  733. type FormatHeaderFooter struct {
  734. AlignWithMargins bool
  735. DifferentFirst bool
  736. DifferentOddEven bool
  737. ScaleWithDoc bool
  738. OddHeader string
  739. OddFooter string
  740. EvenHeader string
  741. EvenFooter string
  742. FirstFooter string
  743. FirstHeader string
  744. }
  745. // FormatPageMargins directly maps the settings of page margins
  746. type FormatPageMargins struct {
  747. Bottom string
  748. Footer string
  749. Header string
  750. Left string
  751. Right string
  752. Top string
  753. }