-
Notifications
You must be signed in to change notification settings - Fork 293
Expanding and collapsing Pivot Table items
Mats Alm edited this page Nov 6, 2023
·
3 revisions
After generating a pivot table, you sometimes want to collapse or expand all or individual items in a row- or column field.
You can do this with EPPlus using the ExcelPivotTableFieldItemsCollection.ShowDetails
method or the ExcelPivotTableFieldItem.ShowDetails
Property.
First however you must refresh the pivot table cache, so the cache items are generated.
Here is an example of how to collapse all items for a column field.
//First you need to refresh the items, the you can set the ShowDetails flag for all items or on an individual item.
pivotTable.ColumnFields[0].Items.Refresh();
pivotTable.ColumnFields[0].Items.ShowDetails(false);
You can also collapse or expand individual items after the items cache has been refreshed.
pivotTable.ColumnFields[0].Items[0].ShowDetails = false;
EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles