News Category

How to remove auto filters in Excel

2014-12-16 08:59:19 Written by  support iceblue
Rate this item
(0 votes)

We have already shown you how to use the method ListObjects to filter the data and format it as a table. This article will focus on demonstrate how to remove the auto filters with the method AutoFilters offered by Spire.XLS. Developer can also use the method sheet.AutoFilters.Range to create the auto filters.

Step 1: Create an excel document and load the Excel with auto filers from file.

Workbook workbook = new Workbook();
workbook.LoadFromFile("Filter.xlsx ");

Step 2: Gets the first worksheet in the Excel file.

Worksheet sheet = workbook.Worksheets[0];

Step 3: Remove the auto filters.

sheet.AutoFilters.Clear();

Step 4: Save the document to file.

workbook.SaveToFile("Result.xlsx", ExcelVersion.Version2010);

Screenshot for the Excel files with auto filters:

How to remove auto filters in Excel

The effective screenshot of removing the auto filters:

How to remove auto filters in Excel

Full codes:

using Spire.Xls;
namespace RemoveAutoFilter
{
    class Program
    {

      static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile("Filter.xlsx");

            Worksheet sheet = workbook.Worksheets[0];
            sheet.AutoFilters.Clear();

            workbook.SaveToFile("result.xlsx", ExcelVersion.Version2010);
        }


        }
    }

Additional Info

  • tutorial_title: Remove auto filters in Excel
Last modified on Monday, 06 September 2021 02:23