Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Issue: How to Filter on a Table? [7732]

$
0
0
The following works (but if I use "SetAutoFilter()" then the workbook is corrupt, I'll fix that). In the meantime just use "table.AutoFilter" instead: var wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Sheet1");

ws.FirstCell().SetValue("Categories")
.CellBelow().SetValue("A")
.CellBelow().SetValue("B")
.CellBelow().SetValue("A")
.CellBelow().SetValue("B");
 
var table = ws.RangeUsed().CreateTable();
table.AutoFilter.Column(1).AddFilter("A");
Comments: ** Comment from web user: vlash **

Can you filter on more than one column?

table.AutoFilter.Column(6).AddFilter<string>("xxx");
table.AutoFilter.Column(1).AddFilter<string>("ccc");

The example above will only filter on the last row, even though the filtervalues are set for column 6.


Viewing all articles
Browse latest Browse all 1877

Trending Articles