Version

CellExporting Event

Occurs before grid cell is exported to excel.
Syntax
'Declaration
 
Public Event CellExporting As CellExportingEventHandler
public event CellExportingEventHandler CellExporting
Event Data

The event handler receives an argument of type CellExportingEventArgs containing data related to this event. The following CellExportingEventArgs 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.
ExportValue The value which will be exported to the Excel worksheet.
GridColumn Associated grid column.
GridRow Grid row containing the cell.
GridValue Returns the value of the object in the grid which is being exported.
Value Grid cell value.
Workbook (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportCancelEventArgs)Exporting workbook.
Remarks

The GridRow argument returns a reference to a grid row containing the cell.

The GridColumn argument returns a reference to associated grid column.

The Value argument returns a grid cell value.

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

This event is fired before excel cell with grid data is processed. Use Cancel argument to cancel cell exporting.

Example
Following code uses CellExporting event to apply custom formatting to grid cell appearance (before grid cell export has started) and CellExported event to apply custom formatting to excel cell (after grid cell 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_CellExporting(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.CellExportingEventArgs) Handles MyGridExporter.CellExporting
    If e.CurrentColumnIndex Mod 2 = 0 Then
        e.GridRow.Cells(e.GridColumn).Appearance.BackColor = Color.AliceBlue
    End If
End Sub

Private Sub MyGridExporter_CellExported(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.CellExportedEventArgs) Handles MyGridExporter.CellExported
    If e.CurrentColumnIndex Mod 2 = 0 Then
        Dim tmCF As IWorksheetCellFormat = e.CurrentWorksheet.Rows(e.CurrentRowIndex).Cells(e.CurrentColumnIndex).CellFormat
        tmCF.BottomBorderStyle = CellBorderLineStyle.SlantedDashDot
        tmCF.TopBorderStyle = CellBorderLineStyle.SlantedDashDot
        tmCF.LeftBorderStyle = CellBorderLineStyle.SlantedDashDot
        tmCF.RightBorderStyle = CellBorderLineStyle.SlantedDashDot
    End If
End Sub
private void CellExportingEH(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.CellExportingEventArgs e)
{
	if(e.CurrentColumnIndex%2==0)
		e.GridRow.Cells[e.GridColumn].Appearance.BackColor = Color.AliceBlue;
}

private void CellExportedEH(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.CellExportedEventArgs e)
{
	if(e.CurrentColumnIndex%2==0)
	{
		IWorksheetCellFormat tmCF = e.CurrentWorksheet.Rows[e.CurrentRowIndex].Cells[e.CurrentColumnIndex].CellFormat;
		tmCF.BottomBorderStyle = tmCF.TopBorderStyle = tmCF.LeftBorderStyle = tmCF.RightBorderStyle = CellBorderLineStyle.SlantedDashDot;
	}
}
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