|
| 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.10 or later. |
| 9 | + |
| 10 | +package excelize |
| 11 | + |
| 12 | +import "encoding/xml" |
| 13 | + |
| 14 | +// xlsxPivotTableDefinition represents the PivotTable root element for |
| 15 | +// non-null PivotTables. There exists one pivotTableDefinition for each |
| 16 | +// PivotTableDefinition part |
| 17 | +type xlsxPivotTableDefinition struct { |
| 18 | + XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main pivotTableDefinition"` |
| 19 | + Name string `xml:"name,attr"` |
| 20 | + CacheID int `xml:"cacheId,attr"` |
| 21 | + DataOnRows bool `xml:"dataOnRows,attr"` |
| 22 | + DataPosition int `xml:"dataPosition,attr"` |
| 23 | + DataCaption string `xml:"dataCaption,attr"` |
| 24 | + GrandTotalCaption string `xml:"grandTotalCaption,attr"` |
| 25 | + ErrorCaption string `xml:"errorCaption,attr"` |
| 26 | + ShowError bool `xml:"showError,attr"` |
| 27 | + MissingCaption string `xml:"missingCaption,attr"` |
| 28 | + ShowMissing bool `xml:"showMissing,attr"` |
| 29 | + PageStyle string `xml:"pageStyle,attr"` |
| 30 | + PivotTableStyle string `xml:"pivotTableStyle,attr"` |
| 31 | + VacatedStyle string `xml:"vacatedStyle,attr"` |
| 32 | + Tag string `xml:"tag,attr"` |
| 33 | + UpdatedVersion int `xml:"updatedVersion,attr"` |
| 34 | + MinRefreshableVersion int `xml:"minRefreshableVersion,attr"` |
| 35 | + AsteriskTotals bool `xml:"asteriskTotals,attr"` |
| 36 | + ShowItems bool `xml:"showItems,attr"` |
| 37 | + EditData bool `xml:"editData,attr"` |
| 38 | + DisableFieldList bool `xml:"disableFieldList,attr"` |
| 39 | + ShowCalcMbrs bool `xml:"showCalcMbrs,attr"` |
| 40 | + VisualTotals bool `xml:"visualTotals,attr"` |
| 41 | + ShowMultipleLabel bool `xml:"showMultipleLabel,attr"` |
| 42 | + ShowDataDropDown bool `xml:"showDataDropDown,attr"` |
| 43 | + ShowDrill bool `xml:"showDrill,attr"` |
| 44 | + PrintDrill bool `xml:"printDrill,attr"` |
| 45 | + ShowMemberPropertyTips bool `xml:"showMemberPropertyTips,attr"` |
| 46 | + ShowDataTips bool `xml:"showDataTips,attr"` |
| 47 | + EnableWizard bool `xml:"enableWizard,attr"` |
| 48 | + EnableDrill bool `xml:"enableDrill,attr"` |
| 49 | + EnableFieldProperties bool `xml:"enableFieldProperties,attr"` |
| 50 | + PreserveFormatting bool `xml:"preserveFormatting,attr"` |
| 51 | + UseAutoFormatting bool `xml:"useAutoFormatting,attr"` |
| 52 | + PageWrap int `xml:"pageWrap,attr"` |
| 53 | + PageOverThenDown bool `xml:"pageOverThenDown,attr"` |
| 54 | + SubtotalHiddenItems bool `xml:"subtotalHiddenItems,attr"` |
| 55 | + RowGrandTotals bool `xml:"rowGrandTotals,attr"` |
| 56 | + ColGrandTotals bool `xml:"colGrandTotals,attr"` |
| 57 | + FieldPrintTitles bool `xml:"fieldPrintTitles,attr"` |
| 58 | + ItemPrintTitles bool `xml:"itemPrintTitles,attr"` |
| 59 | + MergeItem bool `xml:"mergeItem,attr"` |
| 60 | + ShowDropZones bool `xml:"showDropZones,attr"` |
| 61 | + CreatedVersion int `xml:"createdVersion,attr"` |
| 62 | + Indent int `xml:"indent,attr"` |
| 63 | + ShowEmptyRow bool `xml:"showEmptyRow,attr"` |
| 64 | + ShowEmptyCol bool `xml:"showEmptyCol,attr"` |
| 65 | + ShowHeaders bool `xml:"showHeaders,attr"` |
| 66 | + Compact bool `xml:"compact,attr"` |
| 67 | + Outline bool `xml:"outline,attr"` |
| 68 | + OutlineData bool `xml:"outlineData,attr"` |
| 69 | + CompactData bool `xml:"compactData,attr"` |
| 70 | + Published bool `xml:"published,attr"` |
| 71 | + GridDropZones bool `xml:"gridDropZones,attr"` |
| 72 | + Immersive bool `xml:"immersive,attr"` |
| 73 | + MultipleFieldFilters bool `xml:"multipleFieldFilters,attr"` |
| 74 | + ChartFormat int `xml:"chartFormat,attr"` |
| 75 | + RowHeaderCaption string `xml:"rowHeaderCaption,attr"` |
| 76 | + ColHeaderCaption string `xml:"colHeaderCaption,attr"` |
| 77 | + FieldListSortAscending bool `xml:"fieldListSortAscending,attr"` |
| 78 | + MdxSubqueries bool `xml:"mdxSubqueries,attr"` |
| 79 | + CustomListSort bool `xml:"customListSort,attr"` |
| 80 | + Location *xlsxLocation `xml:"location"` |
| 81 | + PivotFields *xlsxPivotFields `xml:"pivotFields"` |
| 82 | + RowFields *xlsxRowFields `xml:"rowFields"` |
| 83 | + RowItems *xlsxRowItems `xml:"rowItems"` |
| 84 | + ColFields *xlsxColFields `xml:"colFields"` |
| 85 | + ColItems *xlsxColItems `xml:"colItems"` |
| 86 | + PageFields *xlsxPageFields `xml:"pageFields"` |
| 87 | + DataFields *xlsxDataFields `xml:"dataFields"` |
| 88 | + ConditionalFormats *xlsxConditionalFormats `xml:"conditionalFormats"` |
| 89 | + PivotTableStyleInfo *xlsxPivotTableStyleInfo `xml:"pivotTableStyleInfo"` |
| 90 | +} |
| 91 | + |
| 92 | +// xlsxLocation represents location information for the PivotTable. |
| 93 | +type xlsxLocation struct { |
| 94 | + Ref string `xml:"ref,attr"` |
| 95 | + FirstHeaderRow int `xml:"firstHeaderRow,attr"` |
| 96 | + FirstDataRow int `xml:"firstDataRow,attr"` |
| 97 | + FirstDataCol int `xml:"firstDataCol,attr"` |
| 98 | + RowPageCount int `xml:"rowPageCount,attr"` |
| 99 | + ColPageCount int `xml:"colPageCount,attr"` |
| 100 | +} |
| 101 | + |
| 102 | +// xlsxPivotFields represents the collection of fields that appear on the |
| 103 | +// PivotTable. |
| 104 | +type xlsxPivotFields struct { |
| 105 | + Count int `xml:"count,attr"` |
| 106 | + PivotField []*xlsxPivotField `xml:"pivotField"` |
| 107 | +} |
| 108 | + |
| 109 | +// xlsxPivotField represents a single field in the PivotTable. This element |
| 110 | +// contains information about the field, including the collection of items in |
| 111 | +// the field. |
| 112 | +type xlsxPivotField struct { |
| 113 | + Name string `xml:"name,attr"` |
| 114 | + Axis string `xml:"axis,attr,omitempty"` |
| 115 | + DataField bool `xml:"dataField,attr"` |
| 116 | + SubtotalCaption string `xml:"subtotalCaption,attr"` |
| 117 | + ShowDropDowns bool `xml:"showDropDowns,attr"` |
| 118 | + HiddenLevel bool `xml:"hiddenLevel,attr"` |
| 119 | + UniqueMemberProperty string `xml:"uniqueMemberProperty,attr"` |
| 120 | + Compact bool `xml:"compact,attr"` |
| 121 | + AllDrilled bool `xml:"allDrilled,attr"` |
| 122 | + NumFmtId string `xml:"numFmtId,attr,omitempty"` |
| 123 | + Outline bool `xml:"outline,attr"` |
| 124 | + SubtotalTop bool `xml:"subtotalTop,attr"` |
| 125 | + DragToRow bool `xml:"dragToRow,attr"` |
| 126 | + DragToCol bool `xml:"dragToCol,attr"` |
| 127 | + MultipleItemSelectionAllowed bool `xml:"multipleItemSelectionAllowed,attr"` |
| 128 | + DragToPage bool `xml:"dragToPage,attr"` |
| 129 | + DragToData bool `xml:"dragToData,attr"` |
| 130 | + DragOff bool `xml:"dragOff,attr"` |
| 131 | + ShowAll bool `xml:"showAll,attr"` |
| 132 | + InsertBlankRow bool `xml:"insertBlankRow,attr"` |
| 133 | + ServerField bool `xml:"serverField,attr"` |
| 134 | + InsertPageBreak bool `xml:"insertPageBreak,attr"` |
| 135 | + AutoShow bool `xml:"autoShow,attr"` |
| 136 | + TopAutoShow bool `xml:"topAutoShow,attr"` |
| 137 | + HideNewItems bool `xml:"hideNewItems,attr"` |
| 138 | + MeasureFilter bool `xml:"measureFilter,attr"` |
| 139 | + IncludeNewItemsInFilter bool `xml:"includeNewItemsInFilter,attr"` |
| 140 | + ItemPageCount int `xml:"itemPageCount,attr"` |
| 141 | + SortType string `xml:"sortType,attr"` |
| 142 | + DataSourceSort bool `xml:"dataSourceSort,attr,omitempty"` |
| 143 | + NonAutoSortDefault bool `xml:"nonAutoSortDefault,attr"` |
| 144 | + RankBy int `xml:"rankBy,attr,omitempty"` |
| 145 | + DefaultSubtotal bool `xml:"defaultSubtotal,attr"` |
| 146 | + SumSubtotal bool `xml:"sumSubtotal,attr"` |
| 147 | + CountASubtotal bool `xml:"countASubtotal,attr"` |
| 148 | + AvgSubtotal bool `xml:"avgSubtotal,attr"` |
| 149 | + MaxSubtotal bool `xml:"maxSubtotal,attr"` |
| 150 | + MinSubtotal bool `xml:"minSubtotal,attr"` |
| 151 | + ProductSubtotal bool `xml:"productSubtotal,attr"` |
| 152 | + CountSubtotal bool `xml:"countSubtotal,attr"` |
| 153 | + StdDevSubtotal bool `xml:"stdDevSubtotal,attr"` |
| 154 | + StdDevPSubtotal bool `xml:"stdDevPSubtotal,attr"` |
| 155 | + VarSubtotal bool `xml:"varSubtotal,attr"` |
| 156 | + VarPSubtotal bool `xml:"varPSubtotal,attr"` |
| 157 | + ShowPropCell bool `xml:"showPropCell,attr,omitempty"` |
| 158 | + ShowPropTip bool `xml:"showPropTip,attr,omitempty"` |
| 159 | + ShowPropAsCaption bool `xml:"showPropAsCaption,attr,omitempty"` |
| 160 | + DefaultAttributeDrillState bool `xml:"defaultAttributeDrillState,attr,omitempty"` |
| 161 | + Items *xlsxItems `xml:"items"` |
| 162 | + AutoSortScope *xlsxAutoSortScope `xml:"autoSortScope"` |
| 163 | + ExtLst *xlsxExtLst `xml:"extLst"` |
| 164 | +} |
| 165 | + |
| 166 | +// xlsxItems represents the collection of items in a PivotTable field. The |
| 167 | +// items in the collection are ordered by index. Items represent the unique |
| 168 | +// entries from the field in the source data. |
| 169 | +type xlsxItems struct { |
| 170 | + Count int `xml:"count,attr"` |
| 171 | + Item []*xlsxItem `xml:"item"` |
| 172 | +} |
| 173 | + |
| 174 | +// xlsxItem represents a single item in PivotTable field. |
| 175 | +type xlsxItem struct { |
| 176 | + N string `xml:"n,attr"` |
| 177 | + T string `xml:"t,attr"` |
| 178 | + H bool `xml:"h,attr"` |
| 179 | + S bool `xml:"s,attr"` |
| 180 | + SD bool `xml:"sd,attr"` |
| 181 | + F bool `xml:"f,attr"` |
| 182 | + M bool `xml:"m,attr"` |
| 183 | + C bool `xml:"c,attr"` |
| 184 | + X int `xml:"x,attr,omitempty"` |
| 185 | + D bool `xml:"d,attr"` |
| 186 | + E bool `xml:"e,attr"` |
| 187 | +} |
| 188 | + |
| 189 | +// xlsxAutoSortScope represents the sorting scope for the PivotTable. |
| 190 | +type xlsxAutoSortScope struct { |
| 191 | +} |
| 192 | + |
| 193 | +// xlsxRowFields represents the collection of row fields for the PivotTable. |
| 194 | +type xlsxRowFields struct { |
| 195 | + Count int `xml:"count,attr"` |
| 196 | + Fields []*xlsxField `xml:"fields"` |
| 197 | +} |
| 198 | + |
| 199 | +// xlsxField represents a generic field that can appear either on the column |
| 200 | +// or the row region of the PivotTable. There areas many <x> elements as there |
| 201 | +// are item values in any particular column or row. |
| 202 | +type xlsxField struct { |
| 203 | + X int `xml:"x,attr"` |
| 204 | +} |
| 205 | + |
| 206 | +// xlsxRowItems represents the collection of items in row axis of the |
| 207 | +// PivotTable. |
| 208 | +type xlsxRowItems struct { |
| 209 | + Count int `xml:"count,attr"` |
| 210 | + I []*xlsxI `xml:"i"` |
| 211 | +} |
| 212 | + |
| 213 | +// xlsxI represents the collection of items in the row region of the |
| 214 | +// PivotTable. |
| 215 | +type xlsxI struct { |
| 216 | + X []*xlsxX `xml:"x"` |
| 217 | +} |
| 218 | + |
| 219 | +// xlsxX represents an array of indexes to cached shared item values. |
| 220 | +type xlsxX struct { |
| 221 | + XMLName xml.Name `xml:"x"` |
| 222 | +} |
| 223 | + |
| 224 | +// xlsxColFields represents the collection of fields that are on the column |
| 225 | +// axis of the PivotTable. |
| 226 | +type xlsxColFields struct { |
| 227 | + Count int `xml:"count,attr"` |
| 228 | + Fields []*xlsxField `xml:"fields"` |
| 229 | +} |
| 230 | + |
| 231 | +// xlsxColItems represents the collection of column items of the PivotTable. |
| 232 | +type xlsxColItems struct { |
| 233 | + Count int `xml:"count,attr"` |
| 234 | + I []*xlsxI `xml:"i"` |
| 235 | +} |
| 236 | + |
| 237 | +// xlsxPageFields represents the collection of items in the page or report |
| 238 | +// filter region of the PivotTable. |
| 239 | +type xlsxPageFields struct { |
| 240 | + Count int `xml:"count,attr"` |
| 241 | + PageField []*xlsxPageField `xml:"pageField"` |
| 242 | +} |
| 243 | + |
| 244 | +// xlsxPageField represents a field on the page or report filter of the |
| 245 | +// PivotTable. |
| 246 | +type xlsxPageField struct { |
| 247 | + Fld int `xml:"fld,attr"` |
| 248 | + Item int `xml:"item,attr,omitempty"` |
| 249 | + Hier int `xml:"hier,attr"` |
| 250 | + Name string `xml:"name,attr"` |
| 251 | + Cap string `xml:"cap,attr"` |
| 252 | + ExtLst *xlsxExtLst `xml:"extLst"` |
| 253 | +} |
| 254 | + |
| 255 | +// xlsxDataFields represents the collection of items in the data region of the |
| 256 | +// PivotTable. |
| 257 | +type xlsxDataFields struct { |
| 258 | + Count int `xml:"count,attr"` |
| 259 | + DataField *xlsxDataField `xml:"dataField"` |
| 260 | +} |
| 261 | + |
| 262 | +// xlsxDataField represents a field from a source list, table, or database |
| 263 | +// that contains data that is summarized in a PivotTable. |
| 264 | +type xlsxDataField struct { |
| 265 | + Name string `xml:"name,attr,omitempty"` |
| 266 | + Fld int `xml:"fld,attr"` |
| 267 | + Subtotal string `xml:"subtotal,attr"` |
| 268 | + ShowDataAs string `xml:"showDataAs,attr"` |
| 269 | + BaseField int `xml:"baseField,attr"` |
| 270 | + BaseItem int64 `xml:"baseItem,attr"` |
| 271 | + NumFmtId string `xml:"numFmtId,attr,omitempty"` |
| 272 | + ExtLst *xlsxExtLst `xml:"extLst"` |
| 273 | +} |
| 274 | + |
| 275 | +// xlsxConditionalFormats represents the collection of conditional formats |
| 276 | +// applied to a PivotTable. |
| 277 | +type xlsxConditionalFormats struct { |
| 278 | +} |
| 279 | + |
| 280 | +// xlsxPivotTableStyleInfo represent information on style applied to the |
| 281 | +// PivotTable. |
| 282 | +type xlsxPivotTableStyleInfo struct { |
| 283 | + Name string `xml:"name,attr"` |
| 284 | + ShowRowHeaders bool `xml:"showRowHeaders,attr"` |
| 285 | + ShowColHeaders bool `xml:"showColHeaders,attr"` |
| 286 | + ShowRowStripes bool `xml:"showRowStripes,attr"` |
| 287 | + ShowColStripes bool `xml:"showColStripes,attr"` |
| 288 | + ShowLastColumn bool `xml:"showLastColumn,attr,omitempty"` |
| 289 | +} |
0 commit comments