corelibraries-devexpress-dot-xtraprinting-dot-xlsexportoptionsex-6fb7d211.md
Fires immediately after a row is added to the output document.Only available in data-aware export mode.
Namespace : DevExpress.XtraPrinting
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public event AfterAddRowEventHandler AfterAddRow
Public Event AfterAddRow As AfterAddRowEventHandler
The AfterAddRow event is raised each time a row from a source control is added to the output document. The event’s DocumentRow parameter returns the index of the current row in the export output.
This event enables you to do the following:
Note
The AfterAddRow event is not currently supported when exporting data from Advanced Banded Grid Views.
This example uses the XlsxExportOptionsEx.AfterAddRow event to merge cells in rows in an XLSX document (a result of data exporting from a Grid Control). Rows that correspond to the grid control’s group rows are merged using the ExportContext.MergeCells method.
For group rows, the DataSourceRowIndex event parameter returns negative values. The current row in the export output is specified by the DocumentRow parameter.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-grid-customize-data-aware-export-output
void options_AfterAddRow(AfterAddRowEventArgs e) {
// Merge cells in rows that correspond to the grid's group rows.
if (e.DataSourceRowIndex < 0) {
e.ExportContext.MergeCells(new XlCellRange(new XlCellPosition(0, e.DocumentRow-1), new XlCellPosition(5, e.DocumentRow-1)));
}
}
Private Sub options_AfterAddRow(ByVal e As AfterAddRowEventArgs)
' Merge cells in rows that correspond to the grid's group rows.
If e.DataSourceRowIndex < 0 Then
e.ExportContext.MergeCells(New XlCellRange(New XlCellPosition(0, e.DocumentRow-1), New XlCellPosition(5, e.DocumentRow-1)))
End If
End Sub
See Also