Skip to content

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

Example

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 also

See Sample 4.2-C# or Sample 4.2-VB

EPPlus wiki

Versions

Worksheet & Ranges

Styling

Import/Export data

Formulas and filters

Charts & Drawing objects

Tables & Pivot Tables

VBA & Protection

Clone this wiki locally