xmlPivotCache.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. // Copyright 2016 - 2023 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 and
  6. // read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and
  7. // writing spreadsheet documents generated by Microsoft Excel™ 2007 and later.
  8. // Supports complex components by high compatibility, and provided streaming
  9. // API for generating or reading data from a worksheet with huge amounts of
  10. // data. This library needs Go version 1.16 or later.
  11. package excelize
  12. import "encoding/xml"
  13. // xlsxPivotCacheDefinition represents the pivotCacheDefinition part. This part
  14. // defines each field in the source data, including the name, the string
  15. // resources of the instance data (for shared items), and information about
  16. // the type of data that appears in the field.
  17. type xlsxPivotCacheDefinition struct {
  18. XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main pivotCacheDefinition"`
  19. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  20. Invalid bool `xml:"invalid,attr,omitempty"`
  21. SaveData bool `xml:"saveData,attr"`
  22. RefreshOnLoad bool `xml:"refreshOnLoad,attr,omitempty"`
  23. OptimizeMemory bool `xml:"optimizeMemory,attr,omitempty"`
  24. EnableRefresh bool `xml:"enableRefresh,attr,omitempty"`
  25. RefreshedBy string `xml:"refreshedBy,attr,omitempty"`
  26. RefreshedDate float64 `xml:"refreshedDate,attr,omitempty"`
  27. RefreshedDateIso float64 `xml:"refreshedDateIso,attr,omitempty"`
  28. BackgroundQuery bool `xml:"backgroundQuery,attr"`
  29. MissingItemsLimit int `xml:"missingItemsLimit,attr,omitempty"`
  30. CreatedVersion int `xml:"createdVersion,attr,omitempty"`
  31. RefreshedVersion int `xml:"refreshedVersion,attr,omitempty"`
  32. MinRefreshableVersion int `xml:"minRefreshableVersion,attr,omitempty"`
  33. RecordCount int `xml:"recordCount,attr,omitempty"`
  34. UpgradeOnRefresh bool `xml:"upgradeOnRefresh,attr,omitempty"`
  35. TupleCacheAttr bool `xml:"tupleCache,attr,omitempty"`
  36. SupportSubquery bool `xml:"supportSubquery,attr,omitempty"`
  37. SupportAdvancedDrill bool `xml:"supportAdvancedDrill,attr,omitempty"`
  38. CacheSource *xlsxCacheSource `xml:"cacheSource"`
  39. CacheFields *xlsxCacheFields `xml:"cacheFields"`
  40. CacheHierarchies *xlsxCacheHierarchies `xml:"cacheHierarchies"`
  41. Kpis *xlsxKpis `xml:"kpis"`
  42. TupleCache *xlsxTupleCache `xml:"tupleCache"`
  43. CalculatedItems *xlsxCalculatedItems `xml:"calculatedItems"`
  44. CalculatedMembers *xlsxCalculatedMembers `xml:"calculatedMembers"`
  45. Dimensions *xlsxDimensions `xml:"dimensions"`
  46. MeasureGroups *xlsxMeasureGroups `xml:"measureGroups"`
  47. Maps *xlsxMaps `xml:"maps"`
  48. ExtLst *xlsxExtLst `xml:"extLst"`
  49. }
  50. // xlsxCacheSource represents the description of data source whose data is
  51. // stored in the pivot cache. The data source refers to the underlying rows or
  52. // database records that provide the data for a PivotTable. You can create a
  53. // PivotTable report from a SpreadsheetML table, an external database
  54. // (including OLAP cubes), multiple SpreadsheetML worksheets, or another
  55. // PivotTable.
  56. type xlsxCacheSource struct {
  57. Type string `xml:"type,attr"`
  58. ConnectionID int `xml:"connectionId,attr,omitempty"`
  59. WorksheetSource *xlsxWorksheetSource `xml:"worksheetSource"`
  60. Consolidation *xlsxConsolidation `xml:"consolidation"`
  61. ExtLst *xlsxExtLst `xml:"extLst"`
  62. }
  63. // xlsxWorksheetSource represents the location of the source of the data that
  64. // is stored in the cache.
  65. type xlsxWorksheetSource struct {
  66. RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"`
  67. Ref string `xml:"ref,attr,omitempty"`
  68. Name string `xml:"name,attr,omitempty"`
  69. Sheet string `xml:"sheet,attr,omitempty"`
  70. }
  71. // xlsxConsolidation represents the description of the PivotCache source using
  72. // multiple consolidation ranges. This element is used when the source of the
  73. // PivotTable is a collection of ranges in the workbook. The ranges are
  74. // specified in the rangeSets collection. The logic for how the application
  75. // consolidates the data in the ranges is application- defined.
  76. type xlsxConsolidation struct{}
  77. // xlsxCacheFields represents the collection of field definitions in the
  78. // source data.
  79. type xlsxCacheFields struct {
  80. Count int `xml:"count,attr"`
  81. CacheField []*xlsxCacheField `xml:"cacheField"`
  82. }
  83. // xlsxCacheField represent a single field in the PivotCache. This definition
  84. // contains information about the field, such as its source, data type, and
  85. // location within a level or hierarchy. The sharedItems element stores
  86. // additional information about the data in this field. If there are no shared
  87. // items, then values are stored directly in the pivotCacheRecords part.
  88. type xlsxCacheField struct {
  89. Name string `xml:"name,attr"`
  90. Caption string `xml:"caption,attr,omitempty"`
  91. PropertyName string `xml:"propertyName,attr,omitempty"`
  92. ServerField bool `xml:"serverField,attr,omitempty"`
  93. UniqueList bool `xml:"uniqueList,attr,omitempty"`
  94. NumFmtID int `xml:"numFmtId,attr"`
  95. Formula string `xml:"formula,attr,omitempty"`
  96. SQLType int `xml:"sqlType,attr,omitempty"`
  97. Hierarchy int `xml:"hierarchy,attr,omitempty"`
  98. Level int `xml:"level,attr,omitempty"`
  99. DatabaseField bool `xml:"databaseField,attr,omitempty"`
  100. MappingCount int `xml:"mappingCount,attr,omitempty"`
  101. MemberPropertyField bool `xml:"memberPropertyField,attr,omitempty"`
  102. SharedItems *xlsxSharedItems `xml:"sharedItems"`
  103. FieldGroup *xlsxFieldGroup `xml:"fieldGroup"`
  104. MpMap *xlsxX `xml:"mpMap"`
  105. ExtLst *xlsxExtLst `xml:"extLst"`
  106. }
  107. // xlsxSharedItems represents the collection of unique items for a field in
  108. // the PivotCacheDefinition. The sharedItems complex type stores data type and
  109. // formatting information about the data in a field. Items in the
  110. // PivotCacheDefinition can be shared in order to reduce the redundancy of
  111. // those values that are referenced in multiple places across all the
  112. // PivotTable parts.
  113. type xlsxSharedItems struct {
  114. ContainsSemiMixedTypes bool `xml:"containsSemiMixedTypes,attr,omitempty"`
  115. ContainsNonDate bool `xml:"containsNonDate,attr,omitempty"`
  116. ContainsDate bool `xml:"containsDate,attr,omitempty"`
  117. ContainsString bool `xml:"containsString,attr,omitempty"`
  118. ContainsBlank bool `xml:"containsBlank,attr,omitempty"`
  119. ContainsMixedTypes bool `xml:"containsMixedTypes,attr,omitempty"`
  120. ContainsNumber bool `xml:"containsNumber,attr,omitempty"`
  121. ContainsInteger bool `xml:"containsInteger,attr,omitempty"`
  122. MinValue float64 `xml:"minValue,attr,omitempty"`
  123. MaxValue float64 `xml:"maxValue,attr,omitempty"`
  124. MinDate string `xml:"minDate,attr,omitempty"`
  125. MaxDate string `xml:"maxDate,attr,omitempty"`
  126. Count int `xml:"count,attr"`
  127. LongText bool `xml:"longText,attr,omitempty"`
  128. M *xlsxMissing `xml:"m"`
  129. N *xlsxNumber `xml:"n"`
  130. B *xlsxBoolean `xml:"b"`
  131. E *xlsxError `xml:"e"`
  132. S *xlsxString `xml:"s"`
  133. D *xlsxDateTime `xml:"d"`
  134. }
  135. // xlsxMissing represents a value that was not specified.
  136. type xlsxMissing struct{}
  137. // xlsxNumber represents a numeric value in the PivotTable.
  138. type xlsxNumber struct {
  139. V float64 `xml:"v,attr"`
  140. U bool `xml:"u,attr,omitempty"`
  141. F bool `xml:"f,attr,omitempty"`
  142. C string `xml:"c,attr,omitempty"`
  143. Cp int `xml:"cp,attr,omitempty"`
  144. In int `xml:"in,attr,omitempty"`
  145. Bc string `xml:"bc,attr,omitempty"`
  146. Fc string `xml:"fc,attr,omitempty"`
  147. I bool `xml:"i,attr,omitempty"`
  148. Un bool `xml:"un,attr,omitempty"`
  149. St bool `xml:"st,attr,omitempty"`
  150. B bool `xml:"b,attr,omitempty"`
  151. Tpls *xlsxTuples `xml:"tpls"`
  152. X *attrValInt `xml:"x"`
  153. }
  154. // xlsxTuples represents members for the OLAP sheet data entry, also known as
  155. // a tuple.
  156. type xlsxTuples struct{}
  157. // xlsxBoolean represents a boolean value for an item in the PivotTable.
  158. type xlsxBoolean struct{}
  159. // xlsxError represents an error value. The use of this item indicates that an
  160. // error value is present in the PivotTable source. The error is recorded in
  161. // the value attribute.
  162. type xlsxError struct{}
  163. // xlsxString represents a character value in a PivotTable.
  164. type xlsxString struct {
  165. V string `xml:"v,attr"`
  166. U bool `xml:"u,attr,omitempty"`
  167. F bool `xml:"f,attr,omitempty"`
  168. C string `xml:"c,attr,omitempty"`
  169. Cp int `xml:"cp,attr,omitempty"`
  170. In int `xml:"in,attr,omitempty"`
  171. Bc string `xml:"bc,attr,omitempty"`
  172. Fc string `xml:"fc,attr,omitempty"`
  173. I bool `xml:"i,attr,omitempty"`
  174. Un bool `xml:"un,attr,omitempty"`
  175. St bool `xml:"st,attr,omitempty"`
  176. B bool `xml:"b,attr,omitempty"`
  177. Tpls *xlsxTuples `xml:"tpls"`
  178. X *attrValInt `xml:"x"`
  179. }
  180. // xlsxDateTime represents a date-time value in the PivotTable.
  181. type xlsxDateTime struct{}
  182. // xlsxFieldGroup represents the collection of properties for a field group.
  183. type xlsxFieldGroup struct{}
  184. // xlsxCacheHierarchies represents the collection of OLAP hierarchies in the
  185. // PivotCache.
  186. type xlsxCacheHierarchies struct{}
  187. // xlsxKpis represents the collection of Key Performance Indicators (KPIs)
  188. // defined on the OLAP server and stored in the PivotCache.
  189. type xlsxKpis struct{}
  190. // xlsxTupleCache represents the cache of OLAP sheet data members, or tuples.
  191. type xlsxTupleCache struct{}
  192. // xlsxCalculatedItems represents the collection of calculated items.
  193. type xlsxCalculatedItems struct{}
  194. // xlsxCalculatedMembers represents the collection of calculated members in an
  195. // OLAP PivotTable.
  196. type xlsxCalculatedMembers struct{}
  197. // xlsxDimensions represents the collection of PivotTable OLAP dimensions.
  198. type xlsxDimensions struct{}
  199. // xlsxMeasureGroups represents the collection of PivotTable OLAP measure
  200. // groups.
  201. type xlsxMeasureGroups struct{}
  202. // xlsxMaps represents the PivotTable OLAP measure group - Dimension maps.
  203. type xlsxMaps struct{}