ListObject.RemoveAutoFilter
ListObject.RemoveAutoFilter method
Removes auto filter which is applied to this table.
public void RemoveAutoFilter()
Examples
using System;
using Aspose.Cells;
using Aspose.Cells.Tables;
namespace AsposeCellsExamples
{
public class ListObjectMethodRemoveAutoFilterDemo
{
public static void Run()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
// Populate sample data (with header row)
sheet.Cells["A1"].PutValue("ID");
sheet.Cells["B1"].PutValue("Name");
sheet.Cells["A2"].PutValue(1);
sheet.Cells["B2"].PutValue("Alice");
sheet.Cells["A3"].PutValue(2);
sheet.Cells["B3"].PutValue("Bob");
sheet.Cells["A4"].PutValue(3);
sheet.Cells["B4"].PutValue("Charlie");
try
{
// Add a ListObject (table) that includes an auto‑filter by default
int listIndex = sheet.ListObjects.Add("A1", "B4", true);
ListObject listObj = sheet.ListObjects[listIndex];
// Optional: apply a filter to demonstrate that a filter exists
listObj.Filter();
// Remove the auto‑filter from the ListObject
listObj.RemoveAutoFilter();
Console.WriteLine("RemoveAutoFilter called successfully.");
// Save the workbook to verify the changes
workbook.Save("RemoveAutoFilterDemo.xlsx");
}
catch (Exception ex)
{
Console.WriteLine($"Error during RemoveAutoFilter operation: {ex.Message}");
}
}
}
}
See Also
- class ListObject
- namespace Aspose.Cells.Tables
- assembly Aspose.Cells