The ItemsToRetain class represents the number of items a PivotTable cache will retain even changes have been made to the data source.

 public sealed class ItemsToRetain
Public NotInheritable Class ItemsToRetain

          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Open("template.xlsx");
          ItemsToRetain items = wb[0].PivotTables[0].PivotTableSettings.ItemsToRetain;
        

          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Open("template.xlsx")
          Dim items As ItemsToRetain = wb(0).PivotTables(0).PivotTableSettings.ItemsToRetain;
        

Name

Description

Automatic

None

Name

Description

Max

Value

Setting PivotTableSettings.ItemsToRetain is the same as going to PivotTable Options > Data > Retain items deleted from the data source and setting Number of items to retain per field to Automatic, Max, None, or a different integer value.