xmlWorksheet.go 29 KB

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