Version

BeginExport Event

Occurs before grid export starts.
Syntax
'Declaration
 
Public Event BeginExport As BeginExportEventHandler
public event BeginExportEventHandler BeginExport
Event Data

The event handler receives an argument of type BeginExportEventArgs containing data related to this event. The following BeginExportEventArgs 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.
Layout Grid layout.
Rows Top band rows collection.
Workbook (Inherited from Infragistics.Win.UltraWinGrid.ExcelExport.ExcelExportEventArgs)Exporting workbook.
Remarks

The Layout argument returns a reference to a cloned UltraGridLayout used for excel exporting. Any changes you make to this layout will be reflected in exported file and not in the original grid layout.

The Rows argument returns a reference to a original rows collection in top band.

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

This event is fired before all other events. You can use it to do any preprocessing before exporting process starts. For example, you can set properties on cloned layout or write some custom header to Excel workbook.

Example
Following code uses BeginExport and EndExport events to write additional information to workbook. Additional data is entered in separate worksheet, which is created in BeginExport event handler.

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_BeginExport(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs) Handles MyGridExporter.BeginExport
    Dim ws As Worksheet
    ws = e.CurrentWorksheet.Workbook.Worksheets.Add("InfoSheet")

    ws.Columns(1).Width = 20 * 256
    ws.Columns(2).Width = 20 * 256

    ws.Rows(1).Cells(1).Value = "Export started at:"
    ws.Rows(1).Cells(2).Value = DateTime.Now

    e.CurrentWorksheet.Workbook.ActiveWorksheet = ws
End Sub

Private Sub MyGridExporter_EndExport(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.EndExportEventArgs) Handles MyGridExporter.EndExport
    Dim ws As Worksheet
    ws = e.CurrentWorksheet.Workbook.Worksheets("InfoSheet")

    ws.Rows(2).Cells(1).Value = "Export successful!"
End Sub
public void BeginExportEH(object sender, BeginExportEventArgs e)
{
	Worksheet ws = e.CurrentWorksheet.Workbook.Worksheets.Add("InfoSheet");

	ws.Columns[1].Width = 20*256;
	ws.Columns[2].Width = 20*256;

	ws.Rows[1].Cells[1].Value = "Export started at:";
	ws.Rows[1].Cells[2].Value = DateTime.Now;

	e.CurrentWorksheet.Workbook.ActiveWorksheet = ws;

}

public void EndExportEH(object sender, EndExportEventArgs e)
{
	Worksheet ws = e.CurrentWorksheet.Workbook.Worksheets["InfoSheet"];
	
	ws.Rows[2].Cells[1].Value = "Export successful!";
}
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