Back to Devexpress

XlsxExportOptionsEx.AfterAddRow Event

corelibraries-devexpress-dot-xtraprinting-dot-xlsxexportoptionsex-77237947.md

latest4.5 KB
Original Source

XlsxExportOptionsEx.AfterAddRow Event

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

Declaration

csharp
public event AfterAddRowEventHandler AfterAddRow
vb
Public Event AfterAddRow As AfterAddRowEventHandler

Remarks

To learn more about the functionality provided by this event, see XlsExportOptionsEx.AfterAddRow.

Note

The AfterAddRow event is not currently supported when exporting data from Advanced Banded Grid Views.

Example

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

csharp
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)));
    }
}
vb
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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AfterAddRow event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-customize-data-aware-export-output/CS/GridDataAwareExportCustomization/Form1.cs#L51

csharp
options.CustomizeSheetFooter += options_CustomizeSheetFooter;
options.AfterAddRow += options_AfterAddRow;

winforms-grid-customize-data-aware-export-output/VB/GridDataAwareExportCustomization/Form1.vb#L54

vb
AddHandler options.CustomizeSheetFooter, AddressOf options_CustomizeSheetFooter
AddHandler options.AfterAddRow, AddressOf options_AfterAddRow

See Also

CustomizeSheetHeader

CustomizeSheetFooter

CustomizeCell

CustomizeSheetSettings

XlsxExportOptionsEx Class

XlsxExportOptionsEx Members

DevExpress.XtraPrinting Namespace