xmlWorksheet.go 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*
  2. Package excelize providing a set of functions that allow you to write to
  3. and read from XLSX files. Support reads and writes XLSX file generated by
  4. Microsoft Excel™ 2007 and later. Support save file without losing original
  5. charts of XLSX. This library needs Go version 1.8 or later.
  6. Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of
  7. this source code is governed by a BSD-style license that can be found in
  8. the LICENSE file.
  9. */
  10. package excelize
  11. import "encoding/xml"
  12. // xlsxWorksheet directly maps the worksheet element in the namespace
  13. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  14. // not checked it for completeness - it does as much as I need.
  15. type xlsxWorksheet struct {
  16. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main worksheet"`
  17. SheetPr *xlsxSheetPr `xml:"sheetPr"`
  18. Dimension xlsxDimension `xml:"dimension"`
  19. SheetViews xlsxSheetViews `xml:"sheetViews,omitempty"`
  20. SheetFormatPr *xlsxSheetFormatPr `xml:"sheetFormatPr"`
  21. Cols *xlsxCols `xml:"cols,omitempty"`
  22. SheetData xlsxSheetData `xml:"sheetData"`
  23. SheetProtection *xlsxSheetProtection `xml:"sheetProtection"`
  24. AutoFilter *xlsxAutoFilter `xml:"autoFilter"`
  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. Drawing *xlsxDrawing `xml:"drawing"`
  35. LegacyDrawing *xlsxLegacyDrawing `xml:"legacyDrawing"`
  36. Picture *xlsxPicture `xml:"picture"`
  37. TableParts *xlsxTableParts `xml:"tableParts"`
  38. ExtLst *xlsxExtLst `xml:"extLst"`
  39. }
  40. // xlsxDrawing change r:id to rid in the namespace.
  41. type xlsxDrawing struct {
  42. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  43. }
  44. // xlsxHeaderFooter directly maps the headerFooter element in the namespace
  45. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - When printed or
  46. // viewed in page layout view (§18.18.69), each page of a worksheet can have a
  47. // page header, a page footer, or both. The headers and footers on odd-numbered
  48. // pages can differ from those on even-numbered pages, and the headers and
  49. // footers on the first page can differ from those on odd- and even-numbered
  50. // pages. In the latter case, the first page is not considered an odd page.
  51. type xlsxHeaderFooter struct {
  52. DifferentFirst bool `xml:"differentFirst,attr,omitempty"`
  53. DifferentOddEven bool `xml:"differentOddEven,attr,omitempty"`
  54. OddHeader []*xlsxOddHeader `xml:"oddHeader"`
  55. OddFooter []*xlsxOddFooter `xml:"oddFooter"`
  56. }
  57. // xlsxOddHeader directly maps the oddHeader element in the namespace
  58. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  59. // not checked it for completeness - it does as much as I need.
  60. type xlsxOddHeader struct {
  61. Content string `xml:",chardata"`
  62. }
  63. // xlsxOddFooter directly maps the oddFooter element in the namespace
  64. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  65. // not checked it for completeness - it does as much as I need.
  66. type xlsxOddFooter struct {
  67. Content string `xml:",chardata"`
  68. }
  69. // xlsxPageSetUp directly maps the pageSetup element in the namespace
  70. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page setup
  71. // settings for the worksheet.
  72. type xlsxPageSetUp struct {
  73. BlackAndWhite bool `xml:"blackAndWhite,attr,omitempty"`
  74. CellComments string `xml:"cellComments,attr,omitempty"`
  75. Copies int `xml:"copies,attr,omitempty"`
  76. Draft bool `xml:"draft,attr,omitempty"`
  77. Errors string `xml:"errors,attr,omitempty"`
  78. FirstPageNumber int `xml:"firstPageNumber,attr,omitempty"`
  79. FitToHeight *int `xml:"fitToHeight,attr"`
  80. FitToWidth int `xml:"fitToWidth,attr,omitempty"`
  81. HorizontalDPI float32 `xml:"horizontalDpi,attr,omitempty"`
  82. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  83. Orientation string `xml:"orientation,attr,omitempty"`
  84. PageOrder string `xml:"pageOrder,attr,omitempty"`
  85. PaperHeight string `xml:"paperHeight,attr,omitempty"`
  86. PaperSize string `xml:"paperSize,attr,omitempty"`
  87. PaperWidth string `xml:"paperWidth,attr,omitempty"`
  88. Scale int `xml:"scale,attr,omitempty"`
  89. UseFirstPageNumber bool `xml:"useFirstPageNumber,attr,omitempty"`
  90. UsePrinterDefaults bool `xml:"usePrinterDefaults,attr,omitempty"`
  91. VerticalDPI float32 `xml:"verticalDpi,attr,omitempty"`
  92. }
  93. // xlsxPrintOptions directly maps the printOptions element in the namespace
  94. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Print options for
  95. // the sheet. Printer-specific settings are stored separately in the Printer
  96. // Settings part.
  97. type xlsxPrintOptions struct {
  98. GridLines bool `xml:"gridLines,attr,omitempty"`
  99. GridLinesSet bool `xml:"gridLinesSet,attr,omitempty"`
  100. Headings bool `xml:"headings,attr,omitempty"`
  101. HorizontalCentered bool `xml:"horizontalCentered,attr,omitempty"`
  102. VerticalCentered bool `xml:"verticalCentered,attr,omitempty"`
  103. }
  104. // xlsxPageMargins directly maps the pageMargins element in the namespace
  105. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page margins for
  106. // a sheet or a custom sheet view.
  107. type xlsxPageMargins struct {
  108. Bottom float64 `xml:"bottom,attr"`
  109. Footer float64 `xml:"footer,attr"`
  110. Header float64 `xml:"header,attr"`
  111. Left float64 `xml:"left,attr"`
  112. Right float64 `xml:"right,attr"`
  113. Top float64 `xml:"top,attr"`
  114. }
  115. // xlsxSheetFormatPr directly maps the sheetFormatPr element in the namespace
  116. // http://schemas.openxmlformats.org/spreadsheetml/2006/main. This element
  117. // specifies the sheet formatting properties.
  118. type xlsxSheetFormatPr struct {
  119. BaseColWidth uint8 `xml:"baseColWidth,attr,omitempty"`
  120. DefaultColWidth float64 `xml:"defaultColWidth,attr,omitempty"`
  121. DefaultRowHeight float64 `xml:"defaultRowHeight,attr"`
  122. CustomHeight bool `xml:"customHeight,attr,omitempty"`
  123. ZeroHeight bool `xml:"zeroHeight,attr,omitempty"`
  124. ThickTop bool `xml:"thickTop,attr,omitempty"`
  125. ThickBottom bool `xml:"thickBottom,attr,omitempty"`
  126. OutlineLevelRow uint8 `xml:"outlineLevelRow,attr,omitempty"`
  127. OutlineLevelCol uint8 `xml:"outlineLevelCol,attr,omitempty"`
  128. }
  129. // xlsxSheetViews directly maps the sheetViews element in the namespace
  130. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Worksheet views
  131. // collection.
  132. type xlsxSheetViews struct {
  133. SheetView []xlsxSheetView `xml:"sheetView"`
  134. }
  135. // xlsxSheetView directly maps the sheetView element in the namespace
  136. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  137. // not checked it for completeness - it does as much as I need. A single sheet
  138. // view definition. When more than one sheet view is defined in the file, it
  139. // means that when opening the workbook, each sheet view corresponds to a
  140. // separate window within the spreadsheet application, where each window is
  141. // showing the particular sheet containing the same workbookViewId value, the
  142. // last sheetView definition is loaded, and the others are discarded. When
  143. // multiple windows are viewing the same sheet, multiple sheetView elements
  144. // (with corresponding workbookView entries) are saved.
  145. // See https://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.sheetview.aspx
  146. type xlsxSheetView struct {
  147. WindowProtection bool `xml:"windowProtection,attr,omitempty"`
  148. ShowFormulas bool `xml:"showFormulas,attr,omitempty"`
  149. ShowGridLines *bool `xml:"showGridLines,attr"`
  150. ShowRowColHeaders *bool `xml:"showRowColHeaders,attr"`
  151. ShowZeros bool `xml:"showZeros,attr,omitempty"`
  152. RightToLeft bool `xml:"rightToLeft,attr,omitempty"`
  153. TabSelected bool `xml:"tabSelected,attr,omitempty"`
  154. ShowWhiteSpace *bool `xml:"showWhiteSpace,attr"`
  155. ShowOutlineSymbols bool `xml:"showOutlineSymbols,attr,omitempty"`
  156. DefaultGridColor *bool `xml:"defaultGridColor,attr"`
  157. View string `xml:"view,attr,omitempty"`
  158. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  159. ColorID int `xml:"colorId,attr,omitempty"`
  160. ZoomScale float64 `xml:"zoomScale,attr,omitempty"`
  161. ZoomScaleNormal float64 `xml:"zoomScaleNormal,attr,omitempty"`
  162. ZoomScalePageLayoutView float64 `xml:"zoomScalePageLayoutView,attr,omitempty"`
  163. ZoomScaleSheetLayoutView float64 `xml:"zoomScaleSheetLayoutView,attr,omitempty"`
  164. WorkbookViewID int `xml:"workbookViewId,attr"`
  165. Pane *xlsxPane `xml:"pane,omitempty"`
  166. Selection []*xlsxSelection `xml:"selection"`
  167. }
  168. // xlsxSelection directly maps the selection element in the namespace
  169. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Worksheet view
  170. // selection.
  171. type xlsxSelection struct {
  172. ActiveCell string `xml:"activeCell,attr,omitempty"`
  173. ActiveCellID *int `xml:"activeCellId,attr"`
  174. Pane string `xml:"pane,attr,omitempty"`
  175. SQRef string `xml:"sqref,attr,omitempty"`
  176. }
  177. // xlsxSelection directly maps the selection element. Worksheet view pane.
  178. type xlsxPane struct {
  179. ActivePane string `xml:"activePane,attr,omitempty"`
  180. State string `xml:"state,attr,omitempty"` // Either "split" or "frozen"
  181. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  182. XSplit float64 `xml:"xSplit,attr,omitempty"`
  183. YSplit float64 `xml:"ySplit,attr,omitempty"`
  184. }
  185. // xlsxSheetPr directly maps the sheetPr element in the namespace
  186. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Sheet-level
  187. // properties.
  188. type xlsxSheetPr struct {
  189. XMLName xml.Name `xml:"sheetPr"`
  190. CodeName string `xml:"codeName,attr,omitempty"`
  191. EnableFormatConditionsCalculation *bool `xml:"enableFormatConditionsCalculation,attr"`
  192. FilterMode bool `xml:"filterMode,attr,omitempty"`
  193. Published *bool `xml:"published,attr"`
  194. SyncHorizontal bool `xml:"syncHorizontal,attr,omitempty"`
  195. SyncVertical bool `xml:"syncVertical,attr,omitempty"`
  196. TransitionEntry bool `xml:"transitionEntry,attr,omitempty"`
  197. TabColor *xlsxTabColor `xml:"tabColor,omitempty"`
  198. PageSetUpPr *xlsxPageSetUpPr `xml:"pageSetUpPr,omitempty"`
  199. }
  200. // xlsxPageSetUpPr directly maps the pageSetupPr element in the namespace
  201. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Page setup
  202. // properties of the worksheet.
  203. type xlsxPageSetUpPr struct {
  204. AutoPageBreaks bool `xml:"autoPageBreaks,attr,omitempty"`
  205. FitToPage bool `xml:"fitToPage,attr,omitempty"` // Flag indicating whether the Fit to Page print option is enabled.
  206. }
  207. // xlsxTabColor directly maps the tabColor element in the namespace currently I
  208. // have not checked it for completeness - it does as much as I need.
  209. type xlsxTabColor struct {
  210. Theme int `xml:"theme,attr,omitempty"`
  211. Tint float64 `xml:"tint,attr,omitempty"`
  212. }
  213. // xlsxCols directly maps the cols element in the namespace
  214. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  215. // not checked it for completeness - it does as much as I need.
  216. type xlsxCols struct {
  217. Col []xlsxCol `xml:"col"`
  218. }
  219. // xlsxCol directly maps the col (Column Width & Formatting). Defines column
  220. // width and column formatting for one or more columns of the worksheet.
  221. type xlsxCol struct {
  222. BestFit bool `xml:"bestFit,attr,omitempty"`
  223. Collapsed bool `xml:"collapsed,attr"`
  224. CustomWidth bool `xml:"customWidth,attr,omitempty"`
  225. Hidden bool `xml:"hidden,attr"`
  226. Max int `xml:"max,attr"`
  227. Min int `xml:"min,attr"`
  228. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  229. Phonetic bool `xml:"phonetic,attr,omitempty"`
  230. Style int `xml:"style,attr"`
  231. Width float64 `xml:"width,attr"`
  232. }
  233. // xlsxDimension directly maps the dimension element in the namespace
  234. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - This element
  235. // specifies the used range of the worksheet. It specifies the row and column
  236. // bounds of used cells in the worksheet. This is optional and is not required.
  237. // Used cells include cells with formulas, text content, and cell formatting.
  238. // When an entire column is formatted, only the first cell in that column is
  239. // considered used.
  240. type xlsxDimension struct {
  241. Ref string `xml:"ref,attr"`
  242. }
  243. // xlsxSheetData directly maps the sheetData element in the namespace
  244. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  245. // not checked it for completeness - it does as much as I need.
  246. type xlsxSheetData struct {
  247. XMLName xml.Name `xml:"sheetData"`
  248. Row []xlsxRow `xml:"row"`
  249. }
  250. // xlsxRow directly maps the row element. The element expresses information
  251. // about an entire row of a worksheet, and contains all cell definitions for a
  252. // particular row in the worksheet.
  253. type xlsxRow struct {
  254. Collapsed bool `xml:"collapsed,attr,omitempty"`
  255. CustomFormat bool `xml:"customFormat,attr,omitempty"`
  256. CustomHeight bool `xml:"customHeight,attr,omitempty"`
  257. Hidden bool `xml:"hidden,attr,omitempty"`
  258. Ht float64 `xml:"ht,attr,omitempty"`
  259. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  260. Ph bool `xml:"ph,attr,omitempty"`
  261. R int `xml:"r,attr,omitempty"`
  262. S int `xml:"s,attr,omitempty"`
  263. Spans string `xml:"spans,attr,omitempty"`
  264. ThickBot bool `xml:"thickBot,attr,omitempty"`
  265. ThickTop bool `xml:"thickTop,attr,omitempty"`
  266. C []xlsxC `xml:"c"`
  267. }
  268. // xlsxMergeCell directly maps the mergeCell element. A single merged cell.
  269. type xlsxMergeCell struct {
  270. Ref string `xml:"ref,attr,omitempty"`
  271. }
  272. // xlsxMergeCells directly maps the mergeCells element. This collection
  273. // expresses all the merged cells in the sheet.
  274. type xlsxMergeCells struct {
  275. Count int `xml:"count,attr,omitempty"`
  276. Cells []*xlsxMergeCell `xml:"mergeCell,omitempty"`
  277. }
  278. // xlsxDataValidations expresses all data validation information for cells in a
  279. // sheet which have data validation features applied.
  280. type xlsxDataValidations struct {
  281. Count int `xml:"count,attr,omitempty"`
  282. DisablePrompts bool `xml:"disablePrompts,attr,omitempty"`
  283. XWindow int `xml:"xWindow,attr,omitempty"`
  284. YWindow int `xml:"yWindow,attr,omitempty"`
  285. DataValidation []*DataValidation `xml:"dataValidation"`
  286. }
  287. // DataValidation directly maps the a single item of data validation defined
  288. // on a range of the worksheet.
  289. type DataValidation struct {
  290. AllowBlank bool `xml:"allowBlank,attr"`
  291. Error *string `xml:"error,attr"`
  292. ErrorStyle *string `xml:"errorStyle,attr"`
  293. ErrorTitle *string `xml:"errorTitle,attr"`
  294. Operator string `xml:"operator,attr"`
  295. Prompt *string `xml:"prompt,attr"`
  296. PromptTitle *string `xml:"promptTitle"`
  297. ShowDropDown bool `xml:"showDropDown,attr"`
  298. ShowErrorMessage bool `xml:"showErrorMessage,attr"`
  299. ShowInputMessage bool `xml:"showInputMessage,attr"`
  300. Sqref string `xml:"sqref,attr"`
  301. Type string `xml:"type,attr"`
  302. Formula1 string `xml:"formula1"`
  303. Formula2 string `xml:"formula2"`
  304. }
  305. // xlsxC directly maps the c element in the namespace
  306. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  307. // not checked it for completeness - it does as much as I need.
  308. //
  309. // This simple type is restricted to the values listed in the following table:
  310. //
  311. // Enumeration Value | Description
  312. // ---------------------------+---------------------------------
  313. // b (Boolean) | Cell containing a boolean.
  314. // d (Date) | Cell contains a date in the ISO 8601 format.
  315. // e (Error) | Cell containing an error.
  316. // 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).
  317. // n (Number) | Cell containing a number.
  318. // s (Shared String) | Cell containing a shared string.
  319. // str (String) | Cell containing a formula string.
  320. //
  321. type xlsxC struct {
  322. R string `xml:"r,attr"` // Cell ID, e.g. A1
  323. S int `xml:"s,attr,omitempty"` // Style reference.
  324. // Str string `xml:"str,attr,omitempty"` // Style reference.
  325. T string `xml:"t,attr,omitempty"` // Type.
  326. F *xlsxF `xml:"f,omitempty"` // Formula
  327. V string `xml:"v,omitempty"` // Value
  328. IS *xlsxIS `xml:"is"`
  329. XMLSpace xml.Attr `xml:"space,attr,omitempty"`
  330. }
  331. // xlsxIS directly maps the t element. Cell containing an (inline) rich
  332. // string, i.e., one not in the shared string table. If this cell type is
  333. // used, then the cell value is in the is element rather than the v element in
  334. // the cell (c element).
  335. type xlsxIS struct {
  336. T string `xml:"t"`
  337. }
  338. // xlsxF directly maps the f element in the namespace
  339. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
  340. // not checked it for completeness - it does as much as I need.
  341. type xlsxF struct {
  342. Content string `xml:",chardata"`
  343. T string `xml:"t,attr,omitempty"` // Formula type
  344. Ref string `xml:"ref,attr,omitempty"` // Shared formula ref
  345. Si string `xml:"si,attr,omitempty"` // Shared formula index
  346. }
  347. // xlsxSheetProtection collection expresses the sheet protection options to
  348. // enforce when the sheet is protected.
  349. type xlsxSheetProtection struct {
  350. AlgorithmName string `xml:"algorithmName,attr,omitempty"`
  351. AutoFilter int `xml:"autoFilter,attr,omitempty"`
  352. DeleteColumns int `xml:"deleteColumns,attr,omitempty"`
  353. DeleteRows int `xml:"deleteRows,attr,omitempty"`
  354. FormatCells int `xml:"formatCells,attr,omitempty"`
  355. FormatColumns int `xml:"formatColumns,attr,omitempty"`
  356. FormatRows int `xml:"formatRows,attr,omitempty"`
  357. HashValue string `xml:"hashValue,attr,omitempty"`
  358. InsertColumns int `xml:"insertColumns,attr,omitempty"`
  359. InsertHyperlinks int `xml:"insertHyperlinks,attr,omitempty"`
  360. InsertRows int `xml:"insertRows,attr,omitempty"`
  361. Objects int `xml:"objects,attr,omitempty"`
  362. PivotTables int `xml:"pivotTables,attr,omitempty"`
  363. SaltValue string `xml:"saltValue,attr,omitempty"`
  364. Scenarios int `xml:"scenarios,attr,omitempty"`
  365. SelectLockedCells int `xml:"selectLockedCells,attr,omitempty"`
  366. SelectUnlockedCell int `xml:"selectUnlockedCell,attr,omitempty"`
  367. Sheet int `xml:"sheet,attr,omitempty"`
  368. Sort int `xml:"sort,attr,omitempty"`
  369. SpinCount int `xml:"spinCount,attr,omitempty"`
  370. }
  371. // xlsxPhoneticPr (Phonetic Properties) represents a collection of phonetic
  372. // properties that affect the display of phonetic text for this String Item
  373. // (si). Phonetic text is used to give hints as to the pronunciation of an East
  374. // Asian language, and the hints are displayed as text within the spreadsheet
  375. // cells across the top portion of the cell. Since the phonetic hints are text,
  376. // every phonetic hint is expressed as a phonetic run (rPh), and these
  377. // properties specify how to display that phonetic run.
  378. type xlsxPhoneticPr struct {
  379. Alignment string `xml:"alignment,attr,omitempty"`
  380. FontID *int `xml:"fontId,attr"`
  381. Type string `xml:"type,attr,omitempty"`
  382. }
  383. // A Conditional Format is a format, such as cell shading or font color, that a
  384. // spreadsheet application can automatically apply to cells if a specified
  385. // condition is true. This collection expresses conditional formatting rules
  386. // applied to a particular cell or range.
  387. type xlsxConditionalFormatting struct {
  388. SQRef string `xml:"sqref,attr,omitempty"`
  389. CfRule []*xlsxCfRule `xml:"cfRule"`
  390. }
  391. // xlsxCfRule (Conditional Formatting Rule) represents a description of a
  392. // conditional formatting rule.
  393. type xlsxCfRule struct {
  394. AboveAverage *bool `xml:"aboveAverage,attr"`
  395. Bottom bool `xml:"bottom,attr,omitempty"`
  396. DxfID *int `xml:"dxfId,attr"`
  397. EqualAverage bool `xml:"equalAverage,attr,omitempty"`
  398. Operator string `xml:"operator,attr,omitempty"`
  399. Percent bool `xml:"percent,attr,omitempty"`
  400. Priority int `xml:"priority,attr,omitempty"`
  401. Rank int `xml:"rank,attr,omitempty"`
  402. StdDev int `xml:"stdDev,attr,omitempty"`
  403. StopIfTrue bool `xml:"stopIfTrue,attr,omitempty"`
  404. Text string `xml:"text,attr,omitempty"`
  405. TimePeriod string `xml:"timePeriod,attr,omitempty"`
  406. Type string `xml:"type,attr,omitempty"`
  407. Formula []string `xml:"formula,omitempty"`
  408. ColorScale *xlsxColorScale `xml:"colorScale"`
  409. DataBar *xlsxDataBar `xml:"dataBar"`
  410. IconSet *xlsxIconSet `xml:"iconSet"`
  411. ExtLst *xlsxExtLst `xml:"extLst"`
  412. }
  413. // xlsxColorScale (Color Scale) describes a gradated color scale in this
  414. // conditional formatting rule.
  415. type xlsxColorScale struct {
  416. Cfvo []*xlsxCfvo `xml:"cfvo"`
  417. Color []*xlsxColor `xml:"color"`
  418. }
  419. // dataBar (Data Bar) describes a data bar conditional formatting rule.
  420. type xlsxDataBar struct {
  421. MaxLength int `xml:"maxLength,attr,omitempty"`
  422. MinLength int `xml:"minLength,attr,omitempty"`
  423. ShowValue bool `xml:"showValue,attr,omitempty"`
  424. Cfvo []*xlsxCfvo `xml:"cfvo"`
  425. Color []*xlsxColor `xml:"color"`
  426. }
  427. // xlsxIconSet (Icon Set) describes an icon set conditional formatting rule.
  428. type xlsxIconSet struct {
  429. Cfvo []*xlsxCfvo `xml:"cfvo"`
  430. IconSet string `xml:"iconSet,attr,omitempty"`
  431. ShowValue bool `xml:"showValue,attr,omitempty"`
  432. Percent bool `xml:"percent,attr,omitempty"`
  433. Reverse bool `xml:"reverse,attr,omitempty"`
  434. }
  435. // cfvo (Conditional Format Value Object) describes the values of the
  436. // interpolation points in a gradient scale.
  437. type xlsxCfvo struct {
  438. Gte bool `xml:"gte,attr,omitempty"`
  439. Type string `xml:"type,attr,omitempty"`
  440. Val string `xml:"val,attr"`
  441. ExtLst *xlsxExtLst `xml:"extLst"`
  442. }
  443. // xlsxHyperlinks directly maps the hyperlinks element in the namespace
  444. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - A hyperlink can
  445. // be stored in a package as a relationship. Hyperlinks shall be identified by
  446. // containing a target which specifies the destination of the given hyperlink.
  447. type xlsxHyperlinks struct {
  448. Hyperlink []xlsxHyperlink `xml:"hyperlink"`
  449. }
  450. // xlsxHyperlink directly maps the hyperlink element in the namespace
  451. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  452. type xlsxHyperlink struct {
  453. Ref string `xml:"ref,attr"`
  454. Location string `xml:"location,attr,omitempty"`
  455. Display string `xml:"display,attr,omitempty"`
  456. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  457. }
  458. // xlsxTableParts directly maps the tableParts element in the namespace
  459. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - The table element
  460. // has several attributes applied to identify the table and the data range it
  461. // covers. The table id attribute needs to be unique across all table parts, the
  462. // same goes for the name and displayName. The displayName has the further
  463. // restriction that it must be unique across all defined names in the workbook.
  464. // Later on we will see that you can define names for many elements, such as
  465. // cells or formulas. The name value is used for the object model in Microsoft
  466. // Office Excel. The displayName is used for references in formulas. The ref
  467. // attribute is used to identify the cell range that the table covers. This
  468. // includes not only the table data, but also the table header containing column
  469. // names.
  470. // To add columns to your table you add new tableColumn elements to the
  471. // tableColumns container. Similar to the shared string table the collection
  472. // keeps a count attribute identifying the number of columns. Besides the table
  473. // definition in the table part there is also the need to identify which tables
  474. // are displayed in the worksheet. The worksheet part has a separate element
  475. // tableParts to store this information. Each table part is referenced through
  476. // the relationship ID and again a count of the number of table parts is
  477. // maintained. The following markup sample is taken from the documents
  478. // accompanying this book. The sheet data element has been removed to reduce the
  479. // size of the sample. To reference the table, just add the tableParts element,
  480. // of course after having created and stored the table part. For example:
  481. //
  482. // <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  483. // ...
  484. // <tableParts count="1">
  485. // <tablePart r:id="rId1" />
  486. // </tableParts>
  487. // </worksheet>
  488. //
  489. type xlsxTableParts struct {
  490. Count int `xml:"count,attr,omitempty"`
  491. TableParts []*xlsxTablePart `xml:"tablePart"`
  492. }
  493. // xlsxTablePart directly maps the tablePart element in the namespace
  494. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  495. type xlsxTablePart struct {
  496. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  497. }
  498. // xlsxPicture directly maps the picture element in the namespace
  499. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - Background sheet
  500. // image. For example:
  501. //
  502. // <picture r:id="rId1"/>
  503. //
  504. type xlsxPicture struct {
  505. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  506. }
  507. // xlsxLegacyDrawing directly maps the legacyDrawing element in the namespace
  508. // http://schemas.openxmlformats.org/spreadsheetml/2006/main - A comment is a
  509. // rich text note that is attached to, and associated with, a cell, separate
  510. // from other cell content. Comment content is stored separate from the cell,
  511. // and is displayed in a drawing object (like a text box) that is separate from,
  512. // but associated with, a cell. Comments are used as reminders, such as noting
  513. // how a complex formula works, or to provide feedback to other users. Comments
  514. // can also be used to explain assumptions made in a formula or to call out
  515. // something special about the cell.
  516. type xlsxLegacyDrawing struct {
  517. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  518. }
  519. // formatPanes directly maps the settings of the panes.
  520. type formatPanes struct {
  521. Freeze bool `json:"freeze"`
  522. Split bool `json:"split"`
  523. XSplit int `json:"x_split"`
  524. YSplit int `json:"y_split"`
  525. TopLeftCell string `json:"top_left_cell"`
  526. ActivePane string `json:"active_pane"`
  527. Panes []struct {
  528. SQRef string `json:"sqref"`
  529. ActiveCell string `json:"active_cell"`
  530. Pane string `json:"pane"`
  531. } `json:"panes"`
  532. }
  533. // formatConditional directly maps the conditional format settings of the cells.
  534. type formatConditional struct {
  535. Type string `json:"type"`
  536. AboveAverage bool `json:"above_average"`
  537. Percent bool `json:"percent"`
  538. Format int `json:"format"`
  539. Criteria string `json:"criteria"`
  540. Value string `json:"value,omitempty"`
  541. Minimum string `json:"minimum,omitempty"`
  542. Maximum string `json:"maximum,omitempty"`
  543. MinType string `json:"min_type,omitempty"`
  544. MidType string `json:"mid_type,omitempty"`
  545. MaxType string `json:"max_type,omitempty"`
  546. MinValue string `json:"min_value,omitempty"`
  547. MidValue string `json:"mid_value,omitempty"`
  548. MaxValue string `json:"max_value,omitempty"`
  549. MinColor string `json:"min_color,omitempty"`
  550. MidColor string `json:"mid_color,omitempty"`
  551. MaxColor string `json:"max_color,omitempty"`
  552. MinLength string `json:"min_length,omitempty"`
  553. MaxLength string `json:"max_length,omitempty"`
  554. MultiRange string `json:"multi_range,omitempty"`
  555. BarColor string `json:"bar_color,omitempty"`
  556. }