PivotTable.Filters Property
Provides access to the collection of filters applied to the current pivot table.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v17.2.Core.dll
Declaration
Property Value
Type | Description |
---|---|
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
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheet-pivot-table-api-t298650
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");
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Filters property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.