Skip to content

Custom Filters

Jan Havlíček edited this page Jan 4, 2024 · 3 revisions

Important

This page is obsolete and no longer being actively maintained. Please refer to page AutoFilter at docs.closedxml.io for the latest information.

CustomAutoFilter1.jpg

CustomAutoFilter2.jpg

CustomAutoFilter3.jpg

CustomAutoFilter4.jpg

var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("AutoFilter");

// Add a bunch of strings to filter
ws.Cell("A1").SetValue("Strings")
  .CellBelow().SetValue("B")
  .CellBelow().SetValue("C")
  .CellBelow().SetValue("C")
  .CellBelow().SetValue("E")
  .CellBelow().SetValue("A")
  .CellBelow().SetValue("D");

// Add filters
ws.RangeUsed().SetAutoFilter().Column(1).Between("B", "D");

// Sort the filtered list
ws.AutoFilter.Sort(1, XLSortOrder.Descending);

wb.SaveAs("AutoFilter.xlsx");

FAQ

Examples

Real world scenarios

Time Savers

Performance and Memory

Misc

Inserting Data/Tables

Styles

Ranges

Rows

Columns

Page Setup (Print Options)

AutoFilters

Comments

Dev docs

Clone this wiki locally