Enum FilterType

FilterType enumeration

The filter type.

public enum FilterType

Values

NameValueDescription
ColorFilter0Filter by fill color of the cell.
CustomFilters1Custom filter type.
DynamicFilter2Dynamic filter type.
MultipleFilters3When multiple values are chosen to filter by, or when a group of date values are chosen to filter by, this element groups those criteria together.
IconFilter4Filter by icon of conditional formatting.
Top105Top 10 filter.
None6No filter.

Examples

using System;
using System.Drawing;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsClassFilterTypeDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            
            // Add sample data
            worksheet.Cells["A1"].PutValue("Color");
            worksheet.Cells["A2"].PutValue("Red");
            worksheet.Cells["A3"].PutValue("Green");
            worksheet.Cells["A4"].PutValue("Blue");
            
            // Create auto filter
            worksheet.AutoFilter.Range = "A1:A4";
            AutoFilter filter = worksheet.AutoFilter;
            
            // Create color filter
            CellsColor color = workbook.CreateCellsColor();
            color.Color = Color.Red;
            
            // Add color filter to column
            filter.AddFillColorFilter(0, BackgroundType.Solid, color, color);
            filter.Refresh();
            
            // Check filter type
            FilterColumn filterColumn = filter.FilterColumns[0];
            Console.WriteLine("Filter Type: " + filterColumn.FilterType);
            
            // Verify the color filter properties
            if (filterColumn.FilterType == FilterType.ColorFilter)
            {
                ColorFilter colorFilter = filterColumn.Filter as ColorFilter;
                Console.WriteLine("Filter by fill color: " + colorFilter.FilterByFillColor);
                Console.WriteLine("Filter color: " + colorFilter.GetColor(workbook.Worksheets));
            }
        }
    }
}

See Also