Skip to main content

XlsxExportOptionsEx.DocumentColumnFiltering Event

Allows you to apply filters to the exported document’s columns.Only available in data-aware export mode.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v24.1.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public event DocumentColumnFilteringEventHandler DocumentColumnFiltering

Remarks

The DocumentColumnFiltering event fires repeatedly for each exported column, allowing you to specify a filter for this column. To specify a filter for a column, create one of the following objects and assign it to the event’s Filter parameter:

  • XlDynamicFilter - A smart filter whose results may depend on the data to which it is applied or the current date (AboveAverage, LastMonth, LastYear, NextMonth, ThisQuarter, ThisWeek, Today, etc.).
  • XlCustomFilters - A filter that consists of one or two expressions.
  • XlTop10Filter - A filter that selects the top N or bottom N items.
  • XlValuesFilter - A filter that selects items with certain values.
  • XlColorFilter - A filter that selects items with a certain fill or font color.

Example

The XlsxExportOptionsEx.DocumentColumnFiltering event allows you to apply filter criteria to columns in the exported XLSX document. This example shows how to apply filters to two columns when exporting data from a Data Grid’s GridView.

using DevExpress.Export.Xl;
using DevExpress.XtraPrinting;
using System.Diagnostics;

private void btnExport_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
    string path = "grid-export.xlsx";
    XlsxExportOptionsEx op = new XlsxExportOptionsEx();
    op.DocumentColumnFiltering += Op_DocumentColumnFiltering;
    gridView1.ExportToXlsx(path, op);
    Process.Start(path);
}

private void Op_DocumentColumnFiltering(DevExpress.Export.DocumentColumnFilteringEventArgs e) {
    if (e.ColumnFieldName == "OrderDate") {
        e.Filter = new XlDynamicFilter(XlDynamicFilterType.LastMonth);
    }
    if (e.ColumnFieldName == "Quantity") {
        e.Filter = new XlCustomFilters(new XlCustomFilterCriteria(XlFilterOperator.GreaterThanOrEqual, 10));
    }
}
See Also