Version

RowExporting Event

Occurs before grid row is exported to excel.
Syntax
'Declaration
 
Public Event RowExporting As RowExportingEventHandler
public event RowExportingEventHandler RowExporting
Event Data

The event handler receives an argument of type RowExportingEventArgs containing data related to this event. The following RowExportingEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
CurrentColumnIndex (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportCancelEventArgs)Zero-based index of current exporting column in excel worksheet..
CurrentOutlineLevel (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportCancelEventArgs)Current outline level used for grouping.
CurrentRowIndex (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportCancelEventArgs)Zero-based index of current exporting row in excel worksheet.
CurrentWorksheet (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportCancelEventArgs)Current exporting worksheet.
GridRow Reference to row being exported.
Workbook (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportCancelEventArgs)Exporting workbook.
Remarks

The GridRow argument returns a reference to row being exported.

Additionaly this event has Cancel, Workbook, CurrentWorksheet, CurrentRowIndex, CurrentColumnIndex, CurrentOutlineLevel arguments inherited from ExcelExportCancelEventArgs.

This event is fired before excel row with grid data is processed. Use Cancel argument to cancel row exporting. If grid rows spans multiple Excel rows (like in row layout mode), this event is fired only for first row.

Example
Following code uses RowExporting event to apply custom formatting to grid row appearance (before grid row export has started) and RowExported event to apply custom formatting to excel row (after grid row was exported).

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Private Sub MyGridExporter_RowExporting(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.RowExportingEventArgs) Handles MyGridExporter.RowExporting
    If e.CurrentRowIndex Mod 2 = 0 Then
        e.GridRow.Appearance.BackColor = Color.LightSalmon
    End If
End Sub

Private Sub MyGridExporter_RowExported(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.RowExportedEventArgs) Handles MyGridExporter.RowExported
    ' CurrentRowIndex is incremented after the row is exported
    e.CurrentWorksheet.Rows(e.CurrentRowIndex - 1).CellFormat.TopBorderStyle = CellBorderLineStyle.Thick
End Sub
private void RowExportingEH(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.RowExportingEventArgs e)
{
	if(e.CurrentRowIndex%2==0)
		e.GridRow.Appearance.BackColor = Color.LightSalmon;
}

private void RowExportedEH(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.RowExportedEventArgs e)
{
	// CurrentRowIndex is incremented after the row is exported
	e.CurrentWorksheet.Rows[e.CurrentRowIndex-1].CellFormat.TopBorderStyle = CellBorderLineStyle.Thick;
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also