Back to Devexpress

XlsExportOptionsEx.BeforeExportRow Event

corelibraries-devexpress-dot-xtraprinting-dot-xlsexportoptionsex-139e2006.md

latest2.0 KB
Original Source

XlsExportOptionsEx.BeforeExportRow Event

Fires consecutively for each control row when this row is about to be exported. Allows you to skip specific rows if they do not meet your custom criteria.

Namespace : DevExpress.XtraPrinting

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

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public event BeforeExportRowEventHandler BeforeExportRow
vb
Public Event BeforeExportRow As BeforeExportRowEventHandler

Remarks

The code below illustrates how to ignore blank rows when exporting Data Grid records.

csharp
void Options_BeforeExportRow(DevExpress.Export.ExportRowEventArgs ea) {
    if(ea.DataSourceOwner is GridViewImplementer<ColumnImplementer, DataRowImplementer> viewImplementer) {
        var data = viewImplementer.View.GetRow(ea.Row.LogicalPosition); // Row object in the data source.
        if (data == null)
            ea.Cancel = true;
    }
}
vb
Private Sub Options_BeforeExportRow(ByVal ea As DevExpress.Export.ExportRowEventArgs)
    If TypeOf ea.DataSourceOwner Is GridViewImplementer(Of ColumnImplementer, DataRowImplementer) viewImplementer Then
        Dim data = viewImplementer.View.GetRow(ea.Row.LogicalPosition) ' Row object in the data source.
        If data Is Nothing Then
            ea.Cancel = True
        End If
    End If
End Sub

See Also

XlsExportOptionsEx Class

XlsExportOptionsEx Members

DevExpress.XtraPrinting Namespace