xmlWorksheet.go 31 KB

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