Back to Devexpress

PivotTable.Filters Property

officefileapi-devexpress-dot-spreadsheet-dot-pivottable-de61d926.md

latest3.8 KB
Original Source

PivotTable.Filters Property

Provides access to the collection of filters applied to the current pivot table.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
PivotFilterCollection Filters { get; }
vb
ReadOnly Property Filters As PivotFilterCollection

Property Value

TypeDescription
PivotFilterCollection

A PivotFilterCollection object that is a collection of pivot filters.

|

Remarks

Use the Filters property to access the collection of filters applied to the specified PivotTable report. To add a new filter to a specific row or column field in the pivot table, use the PivotFilterCollection.Add method overloads. Different types of filters are available: you can construct the filter expression to display only items that meet the specified condition ( Label Filters and Date Filters ), or filter report data based on calculated values ( Value Filters ).

To remove a filter from a PivotTable field, use the PivotFilter.Delete method or remove the filter from the PivotFilterCollection collection by using the PivotFilterCollection.Remove or PivotFilterCollection.RemoveAt method. Note that you can also use the PivotField.ShowAllItems method to redisplay all items in a filtered field.

To clear all filters applied to the PivotTable fields, call the PivotFilterCollection.Clear method.

Example

View Example

vb
Dim worksheet As Worksheet = workbook.Worksheets("Report4")
workbook.Worksheets.ActiveWorksheet = worksheet

' Access the pivot table by its name in the collection.
Dim pivotTable As PivotTable = worksheet.PivotTables("PivotTable1")
' Access the "Region" field.
Dim field As PivotField = pivotTable.Fields(0)
' Filter the "Region" field by text to display sales data for the "South" region.  
pivotTable.Filters.Add(field, PivotFilterType.CaptionEqual, "South")
csharp
Worksheet worksheet = workbook.Worksheets["Report4"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Access the pivot table by its name in the collection.
PivotTable pivotTable = worksheet.PivotTables["PivotTable1"];
// Access the "Region" field.
PivotField field = pivotTable.Fields[0];
// Filter the "Region" field by text to display sales data for the "South" region.  
pivotTable.Filters.Add(field, PivotFilterType.CaptionEqual, "South");

See Also

PivotTable Interface

PivotTable Members

DevExpress.Spreadsheet Namespace