XlDynamicFilter(XlDynamicFilterType, XlVariantValue) Constructor
Initializes a new instance of the XlDynamicFilter class with the specified settings.
Namespace: DevExpress.Export.Xl
Assembly: DevExpress.Printing.v23.2.Core.dll
NuGet Package: DevExpress.Printing.Core
Declaration
Parameters
Name | Type | Description |
---|---|---|
dynamicFilterType | XlDynamicFilterType | An XlDynamicFilterType enumeration member that specifies the dynamic filter type. This value is assigned to the XlDynamicFilter.DynamicFilterType property. |
value | XlVariantValue | An XlVariantValue object that specifies a filter value. This value is assigned to the XlDynamicFilter.Value property. |
Remarks
Use this constructor to create a dynamic filter of the XlDynamicFilterType.AboveAverage or XlDynamicFilterType.BelowAverage type. In this case, the value parameter specifies the mean of values in the filtered column.
Example
// Generate the header row.
using (IXlRow row = sheet.CreateRow())
row.BulkCells(new string[] { "Region", "Product", "Sales" }, headerRowFormatting);
// Apply a dynamic filter to the "Sales" column to display only values that are above the average.
XlDynamicFilter filter = new XlDynamicFilter(XlDynamicFilterType.AboveAverage, 5045);
sheet.AutoFilterColumns.Add(new XlFilterColumn(2, filter));
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