Skip to main content

XlTop10Filter(Double, Double, Boolean, Boolean) Constructor

Initializes a new instance of the XlTop10Filter class with the specified settings.

Namespace: DevExpress.Export.Xl

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

NuGet Package: DevExpress.Printing.Core

Declaration

public XlTop10Filter(
    double value,
    double filterValue,
    bool top,
    bool percent
)

Parameters

Name Type Description
value Double

A Double value that is a number or percentage of column values to display. This value is assigned to the XlTop10Filter.Value property.

filterValue Double

A Double value that is the actual cell value used by the filter to perform the comparison. This value is assigned to the XlTop10Filter.FilterValue property.

top Boolean

A Boolean value indicating whether to filter column values by top order. This value is assigned to the XlTop10Filter.Top property.

percent Boolean

A Boolean value indicating whether to show values that fall in the top/bottom N percent of column values. This value is assigned to the XlTop10Filter.Percent property.

Example

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

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

// Create a Top 10 filter to display three products with the highest sales.
XlTop10Filter filter = new XlTop10Filter(3, 5500, true, false);
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();
See Also