This project has moved. For the latest updates, please go here.

How to Filter on a Table?

Feb 14, 2012 at 2:44 PM

Hi,

is it actually possible to do filtering on a table? All the documentation talks about Ranges...

Would it be something like this:


Dim tblData = worksheet.Table("TABLENAME") tblData.SetAutoFilter().Column(1).AddFilter("!tmpl!0")

thx,
Peter
Coordinator
Feb 14, 2012 at 3:19 PM
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");

Coordinator
Feb 14, 2012 at 3:27 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.