xmlWorksheet.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. // Some code of this file reference tealeg/xlsx.
  2. package excelize
  3. import "encoding/xml"
  4. // xlsxWorksheet directly maps the worksheet element in the namespace
  5. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  6. // currently I have not checked it for completeness - it does as much
  7. // as I need.
  8. type xlsxWorksheet struct {
  9. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main worksheet"`
  10. SheetPr xlsxSheetPr `xml:"sheetPr"`
  11. Dimension xlsxDimension `xml:"dimension"`
  12. SheetViews xlsxSheetViews `xml:"sheetViews"`
  13. SheetFormatPr xlsxSheetFormatPr `xml:"sheetFormatPr"`
  14. Cols *xlsxCols `xml:"cols,omitempty"`
  15. SheetData xlsxSheetData `xml:"sheetData"`
  16. Hyperlinks xlsxHyperlinks `xml:"hyperlinks"`
  17. MergeCells *xlsxMergeCells `xml:"mergeCells,omitempty"`
  18. PrintOptions xlsxPrintOptions `xml:"printOptions"`
  19. PageMargins xlsxPageMargins `xml:"pageMargins"`
  20. PageSetUp xlsxPageSetUp `xml:"pageSetup"`
  21. HeaderFooter xlsxHeaderFooter `xml:"headerFooter"`
  22. Drawing xlsxDrawing `xml:"drawing"`
  23. }
  24. // xlsxDrawing change r:id to rid in the namespace.
  25. type xlsxDrawing struct {
  26. RID string `xml:"rid,attr"`
  27. }
  28. // xlsxHeaderFooter directly maps the headerFooter element in the namespace
  29. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  30. // currently I have not checked it for completeness - it does as much
  31. // as I need.
  32. type xlsxHeaderFooter struct {
  33. DifferentFirst bool `xml:"differentFirst,attr"`
  34. DifferentOddEven bool `xml:"differentOddEven,attr"`
  35. OddHeader []xlsxOddHeader `xml:"oddHeader"`
  36. OddFooter []xlsxOddFooter `xml:"oddFooter"`
  37. }
  38. // xlsxOddHeader directly maps the oddHeader element in the namespace
  39. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  40. // currently I have not checked it for completeness - it does as much
  41. // as I need.
  42. type xlsxOddHeader struct {
  43. Content string `xml:",chardata"`
  44. }
  45. // xlsxOddFooter directly maps the oddFooter element in the namespace
  46. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  47. // currently I have not checked it for completeness - it does as much
  48. // as I need.
  49. type xlsxOddFooter struct {
  50. Content string `xml:",chardata"`
  51. }
  52. // xlsxPageSetUp directly maps the pageSetup element in the namespace
  53. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  54. // currently I have not checked it for completeness - it does as much
  55. // as I need.
  56. type xlsxPageSetUp struct {
  57. PaperSize string `xml:"paperSize,attr,omitempty"`
  58. Scale int `xml:"scale,attr"`
  59. FirstPageNumber int `xml:"firstPageNumber,attr"`
  60. FitToWidth int `xml:"fitToWidth,attr"`
  61. FitToHeight int `xml:"fitToHeight,attr"`
  62. PageOrder string `xml:"pageOrder,attr,omitempty"`
  63. Orientation string `xml:"orientation,attr,omitempty"`
  64. UsePrinterDefaults bool `xml:"usePrinterDefaults,attr"`
  65. BlackAndWhite bool `xml:"blackAndWhite,attr"`
  66. Draft bool `xml:"draft,attr"`
  67. CellComments string `xml:"cellComments,attr,omitempty"`
  68. UseFirstPageNumber bool `xml:"useFirstPageNumber,attr"`
  69. HorizontalDPI float32 `xml:"horizontalDpi,attr"`
  70. VerticalDPI float32 `xml:"verticalDpi,attr"`
  71. Copies int `xml:"copies,attr"`
  72. }
  73. // xlsxPrintOptions directly maps the printOptions element in the namespace
  74. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  75. // currently I have not checked it for completeness - it does as much
  76. // as I need.
  77. type xlsxPrintOptions struct {
  78. Headings bool `xml:"headings,attr"`
  79. GridLines bool `xml:"gridLines,attr"`
  80. GridLinesSet bool `xml:"gridLinesSet,attr"`
  81. HorizontalCentered bool `xml:"horizontalCentered,attr"`
  82. VerticalCentered bool `xml:"verticalCentered,attr"`
  83. }
  84. // xlsxPageMargins directly maps the pageMargins element in the namespace
  85. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  86. // currently I have not checked it for completeness - it does as much
  87. // as I need.
  88. type xlsxPageMargins struct {
  89. Left float64 `xml:"left,attr"`
  90. Right float64 `xml:"right,attr"`
  91. Top float64 `xml:"top,attr"`
  92. Bottom float64 `xml:"bottom,attr"`
  93. Header float64 `xml:"header,attr"`
  94. Footer float64 `xml:"footer,attr"`
  95. }
  96. // xlsxSheetFormatPr directly maps the sheetFormatPr element in the namespace
  97. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  98. // currently I have not checked it for completeness - it does as much
  99. // as I need.
  100. type xlsxSheetFormatPr struct {
  101. DefaultColWidth float64 `xml:"defaultColWidth,attr,omitempty"`
  102. DefaultRowHeight float64 `xml:"defaultRowHeight,attr"`
  103. CustomHeight float64 `xml:"customHeight,attr,omitempty"`
  104. ZeroHeight float64 `xml:"zeroHeight,attr,omitempty"`
  105. OutlineLevelCol uint8 `xml:"outlineLevelCol,attr,omitempty"`
  106. OutlineLevelRow uint8 `xml:"outlineLevelRow,attr,omitempty"`
  107. }
  108. // xlsxSheetViews directly maps the sheetViews element in the namespace
  109. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  110. // currently I have not checked it for completeness - it does as much
  111. // as I need.
  112. type xlsxSheetViews struct {
  113. SheetView []xlsxSheetView `xml:"sheetView"`
  114. }
  115. // xlsxSheetView directly maps the sheetView element in the namespace
  116. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  117. // currently I have not checked it for completeness - it does as much
  118. // as I need.
  119. type xlsxSheetView struct {
  120. // WindowProtection bool `xml:"windowProtection,attr"`
  121. // ShowFormulas bool `xml:"showFormulas,attr"`
  122. ShowGridLines string `xml:"showGridLines,attr,omitempty"`
  123. // ShowRowColHeaders bool `xml:"showRowColHeaders,attr"`
  124. // ShowZeros bool `xml:"showZeros,attr"`
  125. // RightToLeft bool `xml:"rightToLeft,attr"`
  126. TabSelected bool `xml:"tabSelected,attr"`
  127. // ShowOutlineSymbols bool `xml:"showOutlineSymbols,attr"`
  128. // DefaultGridColor bool `xml:"defaultGridColor,attr"`
  129. // View string `xml:"view,attr"`
  130. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  131. // ColorId int `xml:"colorId,attr"`
  132. ZoomScale float64 `xml:"zoomScale,attr,omitempty"`
  133. ZoomScaleNormal float64 `xml:"zoomScaleNormal,attr,omitempty"`
  134. ZoomScalePageLayoutView float64 `xml:"zoomScalePageLayoutView,attr,omitempty"`
  135. WorkbookViewID int `xml:"workbookViewId,attr"`
  136. Selection []xlsxSelection `xml:"selection"`
  137. Pane *xlsxPane `xml:"pane,omitempty"`
  138. }
  139. // xlsxSelection directly maps the selection element in the namespace
  140. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  141. // currently I have not checked it for completeness - it does as much
  142. // as I need.
  143. type xlsxSelection struct {
  144. Pane string `xml:"pane,attr,omitempty"`
  145. ActiveCell string `xml:"activeCell,attr,omitempty"`
  146. ActiveCellID int `xml:"activeCellId,attr"`
  147. SQRef string `xml:"sqref,attr"`
  148. }
  149. // xlsxSelection directly maps the selection element in the namespace
  150. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  151. // currently I have not checked it for completeness - it does as much
  152. // as I need.
  153. type xlsxPane struct {
  154. XSplit float64 `xml:"xSplit,attr"`
  155. YSplit float64 `xml:"ySplit,attr"`
  156. TopLeftCell string `xml:"topLeftCell,attr,omitempty"`
  157. ActivePane string `xml:"activePane,attr,omitempty"`
  158. State string `xml:"state,attr,omitempty"` // Either "split" or "frozen"
  159. }
  160. // xlsxSheetPr directly maps the sheetPr element in the namespace
  161. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  162. // currently I have not checked it for completeness - it does as much
  163. // as I need.
  164. type xlsxSheetPr struct {
  165. FilterMode bool `xml:"filterMode,attr"`
  166. PageSetUpPr []xlsxPageSetUpPr `xml:"pageSetUpPr"`
  167. }
  168. // xlsxPageSetUpPr directly maps the pageSetupPr element in the namespace
  169. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  170. // currently I have not checked it for completeness - it does as much
  171. // as I need.
  172. type xlsxPageSetUpPr struct {
  173. FitToPage bool `xml:"fitToPage,attr"`
  174. }
  175. // xlsxCols directly maps the cols element in the namespace
  176. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  177. // currently I have not checked it for completeness - it does as much
  178. // as I need.
  179. type xlsxCols struct {
  180. Col []xlsxCol `xml:"col"`
  181. }
  182. // xlsxCol directly maps the col element in the namespace
  183. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  184. // currently I have not checked it for completeness - it does as much
  185. // as I need.
  186. type xlsxCol struct {
  187. Collapsed bool `xml:"collapsed,attr"`
  188. Hidden bool `xml:"hidden,attr"`
  189. Max int `xml:"max,attr"`
  190. Min int `xml:"min,attr"`
  191. Style int `xml:"style,attr"`
  192. Width float64 `xml:"width,attr"`
  193. CustomWidth int `xml:"customWidth,attr,omitempty"`
  194. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  195. }
  196. // xlsxDimension directly maps the dimension element in the namespace
  197. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  198. // currently I have not checked it for completeness - it does as much
  199. // as I need.
  200. type xlsxDimension struct {
  201. Ref string `xml:"ref,attr"`
  202. }
  203. // xlsxSheetData directly maps the sheetData element in the namespace
  204. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  205. // currently I have not checked it for completeness - it does as much
  206. // as I need.
  207. type xlsxSheetData struct {
  208. XMLName xml.Name `xml:"sheetData"`
  209. Row []xlsxRow `xml:"row"`
  210. }
  211. // xlsxRow directly maps the row element in the namespace
  212. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  213. // currently I have not checked it for completeness - it does as much
  214. // as I need.
  215. type xlsxRow struct {
  216. R int `xml:"r,attr"`
  217. Spans string `xml:"spans,attr,omitempty"`
  218. Hidden bool `xml:"hidden,attr,omitempty"`
  219. C []xlsxC `xml:"c"`
  220. Ht string `xml:"ht,attr,omitempty"`
  221. CustomHeight bool `xml:"customHeight,attr,omitempty"`
  222. OutlineLevel uint8 `xml:"outlineLevel,attr,omitempty"`
  223. }
  224. type xlsxMergeCell struct {
  225. Ref string `xml:"ref,attr"` // ref: horiz "A1:C1", vert "B3:B6", both "D3:G4"
  226. }
  227. type xlsxMergeCells struct {
  228. XMLName xml.Name //`xml:"mergeCells,omitempty"`
  229. Count int `xml:"count,attr,omitempty"`
  230. Cells []xlsxMergeCell `xml:"mergeCell,omitempty"`
  231. }
  232. // xlsxC directly maps the c element in the namespace
  233. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  234. // currently I have not checked it for completeness - it does as much
  235. // as I need.
  236. type xlsxC struct {
  237. R string `xml:"r,attr"` // Cell ID, e.g. A1
  238. S int `xml:"s,attr,omitempty"` // Style reference.
  239. // Str string `xml:"str,attr,omitempty"` // Style reference.
  240. T string `xml:"t,attr,omitempty"` // Type.
  241. F *xlsxF `xml:"f,omitempty"` // Formula
  242. V string `xml:"v,omitempty"` // Value
  243. }
  244. // xlsxF directly maps the f element in the namespace
  245. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  246. // currently I have not checked it for completeness - it does as much
  247. // as I need.
  248. type xlsxF struct {
  249. Content string `xml:",chardata"`
  250. T string `xml:"t,attr,omitempty"` // Formula type
  251. Ref string `xml:"ref,attr,omitempty"` // Shared formula ref
  252. Si int `xml:"si,attr,omitempty"` // Shared formula index
  253. }
  254. // xlsxHyperlinks directly maps the hyperlinks element in the namespace
  255. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  256. type xlsxHyperlinks struct {
  257. Hyperlink []xlsxHyperlink `xml:"hyperlink"`
  258. }
  259. // xlsxHyperlink directly maps the hyperlink element in the namespace
  260. // http://schemas.openxmlformats.org/spreadsheetml/2006/main
  261. type xlsxHyperlink struct {
  262. Ref string `xml:"ref,attr"`
  263. Location string `xml:"location,attr,omitempty"`
  264. Display string `xml:"display,attr,omitempty"`
  265. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  266. }