Version

HeaderCellExported Event

Occurs after header cell is exported to excel.
Syntax
'Declaration
 
Public Event HeaderCellExported As HeaderCellExportedEventHandler
public event HeaderCellExportedEventHandler HeaderCellExported
Event Data

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

PropertyDescription
CurrentColumnIndex (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportEventArgs)Zero-based index of current exporting column in excel worksheet.
CurrentOutlineLevel (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportEventArgs)Current outline level used for grouping.
CurrentRowIndex (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportEventArgs)Zero-based index of current exporting row in excel worksheet.
CurrentWorksheet (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportEventArgs)Current exporting worksheet.
GridHeader Grid header.
GridRow Associated grid row.
HeaderType Type of header.
Workbook (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportEventArgs)Exporting workbook.
Remarks

The GridHeader argument returns a reference to grid header.

The GridRow argument returns a reference to associated grid row.

The HeaderType argument returns header type.

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

This event is fired after excel cell with header value is processed. Use it to apply any additional formatting to excel cell.

Example
Following code uses HeaderCellExporting event to apply custom formatting to grid header appearance (before grid header export has started) and HeaderCellExported event to apply custom formatting to excel cell (after grid header 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_HeaderCellExporting(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.HeaderCellExportingEventArgs) Handles MyGridExporter.HeaderCellExporting
    If e.CurrentColumnIndex Mod 2 = 0 Then
        e.GridHeader.Appearance.BackColor = Color.Yellow
    End If
End Sub

Private Sub MyGridExporter_HeaderCellExported(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.HeaderCellExportedEventArgs) Handles MyGridExporter.HeaderCellExported
    If e.CurrentColumnIndex Mod 2 = 0 Then
        Dim tmCF As IWorksheetCellFormat = e.CurrentWorksheet.Rows(e.CurrentRowIndex).Cells(e.CurrentColumnIndex).CellFormat
        tmCF.BottomBorderStyle = CellBorderLineStyle.Dotted
        tmCF.TopBorderStyle = CellBorderLineStyle.Dotted
        tmCF.LeftBorderStyle = CellBorderLineStyle.Dotted
        tmCF.RightBorderStyle = CellBorderLineStyle.Dotted
    End If
End Sub
private void HeaderCellExportingEH(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.HeaderCellExportingEventArgs e)
{
	if(e.CurrentColumnIndex%2==0)
		e.GridHeader.Appearance.BackColor = Color.Yellow;
}

private void HeaderCellExportedEH(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.HeaderCellExportedEventArgs 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.Dotted;
	}		
}
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