This project has moved and is read-only. For the latest updates, please go here.

Remove autofilter in Table

Feb 14, 2013 at 8:43 AM
I set a range as a Table "Test". But, when I set it, the table header shows autofilter. Can I remove autofilter from a table header? Or, can I disable it when adding a new table?
Feb 14, 2013 at 11:28 PM
Edited Feb 14, 2013 at 11:28 PM
This code will create a table and remove the autofilter:
      ExcelRange range1 = excel_worksheet_1.Cells["A1:B20"]; 
      ExcelTable table1 = excel_worksheet_1.Tables.Add(range1, "table1"); 
      table1.TableStyle = OfficeOpenXml.Table.TableStyles.Light1; 
      table1.ShowFilter = false;
Feb 15, 2013 at 12:44 AM
I have tried but fail to remove the autofilter.

My coding is the following:
            ws.Tables.Add(range, "Data");
            ws.Tables[0].TableStyle= OfficeOpenXml.Table.TableStyles.None;
            ws.Tables[0].ShowHeader = true;
            ws.Tables[0].ShowTotal = false;
            ws.Tables[0].ShowFilter = false;
Is there any other settings are required for remove table autofilter?
Feb 15, 2013 at 4:04 AM
Edited Feb 15, 2013 at 4:47 AM
I did this code which does give a table with a given color scheme and autofilters are off:
      excel_worksheet_1.Tables.Add(range_2, "table1");
      excel_worksheet_1.Tables[0].TableStyle = OfficeOpenXml.Table.TableStyles.Medium1;
      excel_worksheet_1.Tables[0].ShowHeader = true;
      excel_worksheet_1.Tables[0].ShowTotal = false;
      excel_worksheet_1.Tables[0].ShowFilter = false;
Btw TableStyles.None visibly at least produces no visual table.
Feb 15, 2013 at 5:32 AM
After some checking, I find this work. However, when I add TotalRowFunctions, the autofilter will appear. How can I stop it?
Mar 2, 2015 at 8:24 PM
Try this extension method. Works with v4.0.3
        public static void SetStyle(this ExcelWorksheet sheet, OfficeOpenXml.Table.TableStyles style)
            var range = sheet.Cells[1, 1, sheet.Dimension.Rows + 1, sheet.Dimension.Columns];
            var table = sheet.Tables.Add(range, sheet.Name);
            table.TableStyle = style;
            table.ShowFilter = false;