Xceed Grid for WinForms v4.3 Documentation
Exporting

Welcome to Xceed Grid for WinForms v4.3 > Basic Concepts > Exporting spreadsheets to Excel > Exporting

Xceed Grid for WinForms lets you export the data of Xceed's data grid to an XML spreadsheet compatible with Microsoft Excel and the Office XP Spreadsheet Component. Doing so can take as little as three lines of code in an application that has a properly configured GridControl.

Basic exportation

To export the data to a spreadsheet, use the ExcelExporter class. The following code demonstrates how to easily export a GridControl to a spreadsheet using the default settings of the ExcelExporter class. Another version of the Export method exports a DetailGrid instead of a GridControl

VB.NET Copy Code
Imports Xceed.Grid.Exporting 

Dim excelExporter1 As New ExcelExporter()
excelExporter1.Export(Me.gridControl1, "d:\test\spreadsheet1.xml")
C# Copy Code
using Xceed.Grid.Exporting; 

ExcelExporter excelExporter1 = new ExcelExporter();
excelExporter1.Export(this.gridControl1, @"d:\test\spreadsheet1.xml");

The code above will export the data contained in gridControl1 to an XML file called "spreadsheet1.xml", which can be opened in Microsoft Excel. By default, among others, the IncludeGridStyles, IncludeDetailGrids, IncludeColumnHeaders, and RepeatParentData properties are set to true; the ColumnHeaderStyle property is set to null (Nothing in VB.NET); and the DetailGridsMode property is set to Joined. See ExcelExporter Properties for more on these and other ExcelExporter properties. 

In addition to these versions of the Export method, which export to a filename represented by a string, versions that export to System.IO.Stream objects are also available. 

For details on some of the events that can be used with ExcelExporter, see ExcelExporter events.