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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

73439 May 7,2008 03:07 AM May 8,2008 10:59 AM Windows Forms 1
loading
Tags: GridControl
Alain Nagels
Asked On May 7, 2008 03:07 AM

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.


Administrator [Syncfusion]
Replied On May 8, 2008 10:59 AM


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.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;