I am facing a weird problem in closedXML library.
I am exporting a datatable to .xlsx (excel file) using closedXML library. By default, autofilter is enabled in the library.
I want to disable or remove the autofilter and export only the datatable.
Here is the code I tried but its not working
XLWorkbook wb = new XLWorkbook();
var ws = wb.Worksheets.Add("Test");
ws.Cell(1, 1).InsertTable(dataTable);
ws.AutoFilter.Enabled = false;
ws.Columns().AdjustToContents();
wb.SaveAs("Report.xlsx");
and I also tried
ws.AutoFilter.Clear();
Even the column wise clear filter is not working
ws.AutoFilter.Column(1).Clear();
Try to use below code and it should work fine
ws.Tables.FirstOrDefault().ShowAutoFilter = false;