The following article provides an overview of how to filter ListObjects by using the Excel Auto Filter. This example and code below uses the following spreadsheet as the basis

The following C# code will filter "Carrots" and "Potato" using an Array
- private void ExcelFilterExample()
- {
- String[] FilterList = {"Carrots","Potato"};
- Excel.Workbook oWB = Globals.ThisAddIn.Application.Workbooks.Open(@"C:\Users\Documents\NameOfWorkbook.xls");
- Excel.Worksheet oWS = oWB.Worksheets[1];
- oWS.ListObjects.AddEx (Excel.XlListObjectSourceType.xlSrcRange, oWS.UsedRange, System.Type.Missing ,Excel.XlYesNoGuess.xlYes).Name = "VeggieList";
- oWS.ListObjects["VeggieList"].Range.AutoFilter(2, FilterList, Excel.XlAutoFilterOperator.xlFilterValues );
- }
Please note every attempt has been made to get the code 100% accurate. Please pardon any typos or errors.


Sneha ChokannaPosted Aug 9, 2018, 8:35 PM EDT
It is working thanks a lot
Michael GriffithsPosted May 7, 2016, 11:49 PM EDT
Nice
Rajaganapathi DhalapathiPosted Dec 6, 2010, 2:26 AM EST
Hi Dave, I have been trying to generate excel file dynamically, everything works fine except i am not able to prouce Auto filter in excel could you provide some help.