We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Essential grid 5.2.0.25 - Export grid columns to Excel - C# - .NET 2.0

Hello

Sorry about the second post but I wanted to make the subject clearer.

I have a grid with several columns.
I want to export this grid to Excel and every column has to come in a seperate sheet.
I must also keep the layout of the grid in the Excel file.

How can I do this in a very efficient way?

Thanks in advance.


1 Reply

AD Administrator Syncfusion Team May 8, 2008 02:59 PM UTC


Hi Alain,

There is no built-in support for this behavior. If you want to export the selected Column to excel, you need to derive the GridExcelConverterControl class and implement the SelectedRowExport method. Please refer the following code snippet.


private void button2_Click(object sender, System.EventArgs e)
{
Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl();

SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Files(*.xls)|*.xls";
saveFileDialog.DefaultExt = ".xls";

if(saveFileDialog.ShowDialog() == DialogResult.OK)
{
gecc.GridToExcel(this.gridDataBoundGrid1.Model, saveFileDialog.FileName,
Syncfusion.GridExcelConverter.ConverterOptions.RowHeaders);

if(MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
Process proc = new Process();
proc.StartInfo.FileName = saveFileDialog.FileName;
proc.Start();
}
}
}


Please refer the sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/F73439/main.htm

Regards,
asem.


Loader.
Live Chat Icon For mobile
Up arrow icon