XlFilterColumn Class

A column in the filter range to which filtering is applied.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.2.Core.dll

Declaration

public class XlFilterColumn

The following members accept/return XlFilterColumn objects:

Remarks

To specify the filter criteria for a particular column in the cell range you wish to filter, create an XlFilterColumn instance and add it to the worksheet’s filter collection accessible from the IXlSheet.AutoFilterColumns property. The XlFilterColumn.ColumnId property specifies the column’s zero-based index in the cell range being filtered, and the XlFilterColumn.FilterCriteria property defines the column’s filter criteria.

Use the IXlSheet.BeginFiltering - IXlSheet.EndFiltering method pair to filter data using the specified filter expression(s). If the generated row contains cells that do not meet the filter criteria, the row is hidden.

Refer to the Filtering topic to learn more about data filtering in the Excel Export Library.

Example

// Generate the header row.
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new string[] { "Region", "Product", "Sales" }, headerRowFormatting);

// Create a custom filter to display values in the "Sales" column that are greater than $4500.
XlCustomFilters filter = new XlCustomFilters(new XlCustomFilterCriteria(XlFilterOperator.GreaterThanOrEqual, 4500));
sheet.AutoFilterColumns.Add(new XlFilterColumn(2, filter));
// Start filtering data.
sheet.BeginFiltering(sheet.DataRange);

// Generate data for the document.
string[] products = new string[] { "Camembert Pierrot", "Gorgonzola Telino", "Mascarpone Fabioli", "Mozzarella di Giovanni" };
int[] amount = new int[] { 6750, 4500, 3550, 4250, 5500, 6250, 5325, 4235 };
for (int i = 0; i < 8; i++)
{
    using (IXlRow row = sheet.CreateRow())
    {
        using (IXlCell cell = row.CreateCell())
        {
            cell.Value = (i < 4) ? "East" : "West";
            cell.ApplyFormatting(rowFormatting);
        }
        using (IXlCell cell = row.CreateCell())
        {
            cell.Value = products[i % 4];
            cell.ApplyFormatting(rowFormatting);
        }
        using (IXlCell cell = row.CreateCell())
        {
            cell.Value = amount[i];
            cell.ApplyFormatting(rowFormatting);
        }
    }
}

// Finish filtering.
sheet.EndFiltering();

Inheritance

Object
XlFilterColumn
See Also