xmlWorkbook.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. // Some code of this file reference tealeg/xlsx.
  2. package excelize
  3. import "encoding/xml"
  4. const (
  5. // sheet state values as defined by
  6. // http://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.sheetstatevalues.aspx
  7. sheetStateVisible = `visible`
  8. sheetStateHidden = `hidden`
  9. sheetStateVeryHidden = `veryHidden`
  10. )
  11. // xmlxWorkbookRels contains xmlxWorkbookRelations
  12. // which maps sheet id and sheet XML
  13. type xlsxWorkbookRels struct {
  14. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/relationships Relationships"`
  15. Relationships []xlsxWorkbookRelation `xml:"Relationship"`
  16. }
  17. // xmlxWorkbookRelation maps sheet id and xl/worksheets/sheet%d.xml
  18. type xlsxWorkbookRelation struct {
  19. ID string `xml:"Id,attr"`
  20. Target string `xml:",attr"`
  21. Type string `xml:",attr"`
  22. }
  23. // xlsxWorkbook directly maps the workbook element from the namespace
  24. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  25. // currently I have not checked it for completeness - it does as much
  26. // as I need.
  27. type xlsxWorkbook struct {
  28. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main workbook"`
  29. FileVersion xlsxFileVersion `xml:"fileVersion"`
  30. WorkbookPr xlsxWorkbookPr `xml:"workbookPr"`
  31. WorkbookProtection xlsxWorkbookProtection `xml:"workbookProtection"`
  32. BookViews xlsxBookViews `xml:"bookViews"`
  33. Sheets xlsxSheets `xml:"sheets"`
  34. DefinedNames xlsxDefinedNames `xml:"definedNames"`
  35. CalcPr xlsxCalcPr `xml:"calcPr"`
  36. FileRecoveryPr xlsxFileRecoveryPr `xml:"fileRecoveryPr"`
  37. }
  38. // xlsxFileRecoveryPr maps sheet recovery information.
  39. type xlsxFileRecoveryPr struct {
  40. RepairLoad int `xml:"repairLoad,attr"`
  41. }
  42. // xlsxWorkbookProtection directly maps the workbookProtection element from the
  43. // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
  44. // - currently I have not checked it for completeness - it does as
  45. // much as I need.
  46. type xlsxWorkbookProtection struct {
  47. // We don't need this, yet.
  48. }
  49. // xlsxFileVersion directly maps the fileVersion element from the
  50. // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
  51. // - currently I have not checked it for completeness - it does as
  52. // much as I need.
  53. type xlsxFileVersion struct {
  54. AppName string `xml:"appName,attr,omitempty"`
  55. LastEdited string `xml:"lastEdited,attr,omitempty"`
  56. LowestEdited string `xml:"lowestEdited,attr,omitempty"`
  57. RupBuild string `xml:"rupBuild,attr,omitempty"`
  58. }
  59. // xlsxWorkbookPr directly maps the workbookPr element from the
  60. // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
  61. // - currently I have not checked it for completeness - it does as
  62. // much as I need.
  63. type xlsxWorkbookPr struct {
  64. DefaultThemeVersion string `xml:"defaultThemeVersion,attr,omitempty"`
  65. BackupFile bool `xml:"backupFile,attr,omitempty"`
  66. ShowObjects string `xml:"showObjects,attr,omitempty"`
  67. Date1904 bool `xml:"date1904,attr"`
  68. }
  69. // xlsxBookViews directly maps the bookViews element from the
  70. // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
  71. // - currently I have not checked it for completeness - it does as
  72. // much as I need.
  73. type xlsxBookViews struct {
  74. WorkBookView []xlsxWorkBookView `xml:"workbookView"`
  75. }
  76. // xlsxWorkBookView directly maps the workbookView element from the
  77. // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
  78. // - currently I have not checked it for completeness - it does as
  79. // much as I need.
  80. type xlsxWorkBookView struct {
  81. ActiveTab int `xml:"activeTab,attr,omitempty"`
  82. FirstSheet int `xml:"firstSheet,attr,omitempty"`
  83. ShowHorizontalScroll bool `xml:"showHorizontalScroll,attr,omitempty"`
  84. ShowVerticalScroll bool `xml:"showVerticalScroll,attr,omitempty"`
  85. ShowSheetTabs bool `xml:"showSheetTabs,attr,omitempty"`
  86. TabRatio int `xml:"tabRatio,attr,omitempty"`
  87. WindowHeight int `xml:"windowHeight,attr,omitempty"`
  88. WindowWidth int `xml:"windowWidth,attr,omitempty"`
  89. XWindow string `xml:"xWindow,attr,omitempty"`
  90. YWindow string `xml:"yWindow,attr,omitempty"`
  91. }
  92. // xlsxSheets directly maps the sheets element from the namespace
  93. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  94. // currently I have not checked it for completeness - it does as much
  95. // as I need.
  96. type xlsxSheets struct {
  97. Sheet []xlsxSheet `xml:"sheet"`
  98. }
  99. // xlsxSheet directly maps the sheet element from the namespace
  100. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  101. // currently I have not checked it for completeness - it does as much
  102. // as I need.
  103. type xlsxSheet struct {
  104. Name string `xml:"name,attr,omitempty"`
  105. SheetID string `xml:"sheetId,attr,omitempty"`
  106. ID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  107. State string `xml:"state,attr,omitempty"`
  108. }
  109. // xlsxDefinedNames directly maps the definedNames element from the
  110. // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
  111. // - currently I have not checked it for completeness - it does as
  112. // much as I need.
  113. type xlsxDefinedNames struct {
  114. DefinedName []xlsxDefinedName `xml:"definedName"`
  115. }
  116. // xlsxDefinedName directly maps the definedName element from the
  117. // namespace http://schemas.openxmlformats.org/spreadsheetml/2006/main
  118. // - currently I have not checked it for completeness - it does as
  119. // much as I need.
  120. // for a descriptions of the attributes see
  121. // https://msdn.microsoft.com/en-us/library/office/documentformat.openxml.spreadsheet.definedname.aspx
  122. type xlsxDefinedName struct {
  123. Data string `xml:",chardata"`
  124. Name string `xml:"name,attr"`
  125. Comment string `xml:"comment,attr,omitempty"`
  126. CustomMenu string `xml:"customMenu,attr,omitempty"`
  127. Description string `xml:"description,attr,omitempty"`
  128. Help string `xml:"help,attr,omitempty"`
  129. ShortcutKey string `xml:"shortcutKey,attr,omitempty"`
  130. StatusBar string `xml:"statusBar,attr,omitempty"`
  131. LocalSheetID int `xml:"localSheetId,attr,omitempty"`
  132. FunctionGroupID int `xml:"functionGroupId,attr,omitempty"`
  133. Function bool `xml:"function,attr,omitempty"`
  134. Hidden bool `xml:"hidden,attr,omitempty"`
  135. VbProcedure bool `xml:"vbProcedure,attr,omitempty"`
  136. PublishToServer bool `xml:"publishToServer,attr,omitempty"`
  137. WorkbookParameter bool `xml:"workbookParameter,attr,omitempty"`
  138. Xlm bool `xml:"xml,attr,omitempty"`
  139. }
  140. // xlsxCalcPr directly maps the calcPr element from the namespace
  141. // http://schemas.openxmlformats.org/spreadsheetml/2006/main -
  142. // currently I have not checked it for completeness - it does as much
  143. // as I need.
  144. type xlsxCalcPr struct {
  145. CalcID string `xml:"calcId,attr,omitempty"`
  146. IterateCount int `xml:"iterateCount,attr,omitempty"`
  147. RefMode string `xml:"refMode,attr,omitempty"`
  148. Iterate bool `xml:"iterate,attr,omitempty"`
  149. IterateDelta float64 `xml:"iterateDelta,attr,omitempty"`
  150. }