-
Notifications
You must be signed in to change notification settings - Fork 284
Working with filters
Mats Alm edited this page Nov 2, 2023
·
6 revisions
EPPlus 5 supports creating and applying filters, either as an autofilter on the worksheet or as a filter in a table. EPPlus supports the following filters:
- Value filters
- Date group filters
- Custom filters
- Top 10 filters
- Dynamic filters
Here is an example of how to add filters to a range ('p' in the code below is an instance of the ExcelPackage class).
var ws = p.Workbook.Worksheets.Add("ValueFilter");
ExcelRangeBase range = await LoadFromDatabase(connectionString, ws);
range.AutoFilter = true;
var colCompany = ws.AutoFilter.Columns.AddValueFilterColumn(0);
colCompany.Filters.Add("Walsh LLC");
colCompany.Filters.Add("Harber-Goldner");
// ApplyFilter() will set the rows that don't match the filters to hidden.
ws.AutoFilter.ApplyFilter();
See Sample 4.2-C# or Sample 4.2-VB
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
- 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
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles