You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spreadsheet/working-with-pivottables.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,17 +11,18 @@ ms.suite: office
11
11
ms.author: o365devx
12
12
author: o365devx
13
13
ms.topic: conceptual
14
-
ms.date: 11/01/2017
14
+
ms.date: 01/14/2025
15
15
ms.localizationpriority: high
16
16
---
17
17
18
18
# Working with PivotTables
19
19
20
-
This topic discusses the Open XML SDK <xref:DocumentFormat.OpenXml.Spreadsheet.PivotTableDefinition> class and how it relates to the Open XML File Format SpreadsheetML schema. For more information about the overall structure of the parts and elements that make up a SpreadsheetML document, see [Structure of a SpreadsheetML document](structure-of-a-spreadsheetml-document.md).
20
+
This topic discusses the Open XML SDK <xref:DocumentFormat.OpenXml.Spreadsheet.PivotTableDefinition> class and how it relates to the Open XML File Format SpreadsheetML schema. For more information about the overall structure of the parts and elements that make up a SpreadsheetML document, see
21
+
[Structure of a SpreadsheetML document](structure-of-a-spreadsheetml-document.md).
21
22
22
23
## PivotTable in SpreadsheetML
23
24
24
-
The following information from the [!include[ISO/IEC 29500 URL](../includes/iso-iec-29500-link.md)] specification introduces the **PivotTableDefinition** (\<**pivotTableDefinition**\>) element.
25
+
The following information from the [!include[ISO/IEC 29500 URL](../includes/iso-iec-29500-link.md)] specification introduces the `PivotTableDefinition` (`<pivotTableDefinition/>`) element.
25
26
26
27
PivotTables display aggregated views of data easily and in an
27
28
understandable layout. Hundreds or thousands of pieces of underlying
@@ -85,18 +86,18 @@ is displayed in the cells of a worksheet and therefore you need to
85
86
construct them as well. You can also have the user update the PivotTable
86
87
cells when opening the document.
87
88
88
-
The following table lists the common Open XML SDK classes used when working with the **PivotTableDefinition** class.
89
+
The following table lists the common Open XML SDK classes used when working with the `PivotTableDefinition` class.
89
90
90
91
|**SpreadsheetML Element**|**Open XML SDK Class**|
class represents the PivotTable definition (\<**pivotTableDefinition**\>) element defined in the Open XML File Format schema for SpreadsheetML documents. Use the **PivotTableDefinition** class to manipulate individual \<**pivotTableDefinition**\> elements in a SpreadsheetML document.
99
+
The Open XML SDK`PivotTableDefinition`
100
+
class represents the PivotTable definition (`<pivotTableDefinition/>`) element defined in the Open XML File Format schema for SpreadsheetML documents. Use the `PivotTableDefinition` class to manipulate individual `<pivotTableDefinition/>` elements in a SpreadsheetML document.
100
101
101
102
The main function of the PivotTable definition is to store information
102
103
about which field is displayed on which axis of the PivotTable and in
@@ -109,30 +110,30 @@ added to the workbook part, and defines the caption label to display
109
110
above the data area of the PivotTable. All of these elements are
110
111
required.
111
112
112
-
The three main pieces of the **pivotTableDefinition** are: the location of the
113
+
The three main pieces of the `PivotTableDefinition` are: the location of the
113
114
table, the display information for the cached fields, and the
114
115
positioning information of the cached fields. For more information about
115
-
these and other additional elements that make up the **pivotTableDefinition**, see the ISO/IEC 29500
116
+
these and other additional elements that make up the `PivotTableDefinition`, see the ISO/IEC 29500
116
117
specification.
117
118
118
119
### PivotField Class
119
120
120
-
The **PivotTableDefinition** element contains the **PivotField** (\<**pivotField**\>) elements. The following information from the ISO/IEC 29500 specification introduces the **PivotField** (\<**pivotField**\>) element.
121
+
The `PivotTableDefinition` element contains the `PivotField` (`<pivotField/>`) elements. The following information from the ISO/IEC 29500 specification introduces the `PivotField` (`<pivotField/>`) element.
121
122
122
123
Represents a single field in the PivotTable. This element contains information about the field, including the collection of items in the field.
123
124
124
125
First, define the collection of fields that appear on the PivotTable
125
-
using the **pivotFields** element. Each field
126
+
using the `pivotFields` element. Each field
126
127
serves as a cache for the data of that field in the data source. You do
127
-
not need to define the cache. Instead, you can set the **item** element equal to **default** and have the user update the table when
128
-
they open the document. The **showAll**
128
+
not need to define the cache. Instead, you can set the `item` element equal to `default` and have the user update the table when
129
+
they open the document. The `showAll`
129
130
attribute is used to hide certain elements for that data dimension.
130
131
After defining which fields are part of the table, the fields are
131
132
applied to the four areas of the PivotTable.
132
133
133
134
### Pivot Cache Definition Class
134
135
135
-
The following information from the ISO/IEC 29500 specification introduces the **PivotCacheDefinition** (\<**pivotCacheDefinition**\>) element.
136
+
The following information from the ISO/IEC 29500 specification introduces the `PivotCacheDefinition` (`<pivotCacheDefinition/>`) element.
136
137
137
138
The pivotCacheDefinition part defines each field in the
138
139
pivotCacheRecords part, including field name and information about the
@@ -155,17 +156,17 @@ when you pivot the table. There are various types of data sources, for
155
156
example: worksheets, database, OLAP cube, and other PivotTables.
156
157
157
158
The last part of the cache definition defines the fields of the data
158
-
source using the **cacheField** element. The
159
-
**cacheField** element is used for two
159
+
source using the `cacheField` element. The
160
+
`cacheField` element is used for two
160
161
purposes: it defines the data type and formatting of the field, and it
161
162
is used as a cache for shared strings. The pivot values are stored in
162
163
the pivot cache records part. When a recurring string is used as a
163
-
value, the cache record uses a reference into the **cacheField** collection of shared items.
164
+
value, the cache record uses a reference into the `cacheField` collection of shared items.
164
165
165
166
### Pivot Cache Records Class
166
167
167
-
The following information from the ISO/IEC 29500 specification introduces the **PivotCacheRecords** (\<**pivotCacheRecords**\>) element.
168
+
The following information from the ISO/IEC 29500 specification introduces the `PivotCacheRecords` (`<pivotCacheRecords/>`) element.
168
169
169
170
The pivotCacheRecords part contains the underlying data to be aggregated. It is a cache of the source data.
170
171
171
-
The cache records part can store any number of cached records. Each record has the same number of values defined as there are fields in the cache definition. Each record is defined with the **r** element. This record contains value items as child elements. You can provide certain typed values, such as Numeric, Boolean, or Date-Time, or you can reference into the shared items.
172
+
The cache records part can store any number of cached records. Each record has the same number of values defined as there are fields in the cache definition. Each record is defined with the `r` element. This record contains value items as child elements. You can provide certain typed values, such as Numeric, Boolean, or Date-Time, or you can reference into the shared items.
0 commit comments