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.

```csharp
//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);
```

```vbnet
'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.

```csharp
pivotTable.ColumnFields[0].Items[0].ShowDetails = false;
```

```vbnet
pivotTable.ColumnFields(0).Items(0).ShowDetails = False
```

### See also

- [Pivot tables](<https://epplussoftware.com/docs/tables-and-pivot-tables/pivot-tables/index.md>)
