Class FilterColumnCollection

FilterColumnCollection class

A collection of Filter objects that represents all the filters in an autofiltered range.

public class FilterColumnCollection : CollectionBase<FilterColumn>

Properties

NameDescription
Capacity { get; set; }
Count { get; }
Item { get; }Gets FilterColumn object at the special field.
Item { get; set; }

Methods

NameDescription
BinarySearch(FilterColumn)
BinarySearch(FilterColumn, IComparer<FilterColumn>)
BinarySearch(int, int, FilterColumn, IComparer<FilterColumn>)
Clear()
Contains(FilterColumn)
CopyTo(FilterColumn[])
CopyTo(FilterColumn[], int)
CopyTo(int, FilterColumn[], int, int)
Exists(Predicate<FilterColumn>)
Find(Predicate<FilterColumn>)
FindAll(Predicate<FilterColumn>)
FindIndex(Predicate<FilterColumn>)
FindIndex(int, Predicate<FilterColumn>)
FindIndex(int, int, Predicate<FilterColumn>)
FindLast(Predicate<FilterColumn>)
FindLastIndex(Predicate<FilterColumn>)
FindLastIndex(int, Predicate<FilterColumn>)
FindLastIndex(int, int, Predicate<FilterColumn>)
GetByIndex(int)Returns a single Filter object from a collection.
GetEnumerator()
IndexOf(FilterColumn)
IndexOf(FilterColumn, int)
IndexOf(FilterColumn, int, int)
LastIndexOf(FilterColumn)
LastIndexOf(FilterColumn, int)
LastIndexOf(FilterColumn, int, int)
RemoveAt(int)(2 methods)

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class FilterColumnCollectionDemo
    {
        public static void FilterColumnCollectionExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add some data to filter
            worksheet.Cells["A1"].PutValue("Name");
            worksheet.Cells["B1"].PutValue("Age");
            worksheet.Cells["A2"].PutValue("John");
            worksheet.Cells["B2"].PutValue(25);
            worksheet.Cells["A3"].PutValue("Jane");
            worksheet.Cells["B3"].PutValue(30);
            worksheet.Cells["A4"].PutValue("Doe");
            worksheet.Cells["B4"].PutValue(22);

            // Create an AutoFilter
            worksheet.AutoFilter.Range = "A1:B4";

            // Get the FilterColumnCollection
            FilterColumnCollection filterColumns = worksheet.AutoFilter.FilterColumns;

            // Add a filter to the second column (Age)
            worksheet.AutoFilter.AddFilter(1, "25");

            // Apply the filter
            worksheet.AutoFilter.Refresh();

            // Access and manipulate the FilterColumnCollection
            Console.WriteLine("Number of filters applied: " + filterColumns.Count);

            // Get the first filter column
            FilterColumn filterColumn = filterColumns.GetByIndex(0);
            Console.WriteLine("Filter applied on column index: " + filterColumn.FieldIndex);

            // Remove the filter
            filterColumns.RemoveAt(0);
            worksheet.AutoFilter.Refresh();

            // Save the workbook
            workbook.Save("FilterColumnCollectionExample.xlsx");
            workbook.Save("FilterColumnCollectionExample.pdf");
        }
    }
}

See Also