xmlWorksheet.go 29 KB

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