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.

how to export a grid to an excel file with the header names?

Thread ID:





101077 Sep 23,2011 01:05 PM Sep 27,2011 12:48 AM ASP.NET Web Forms (Classic) 2
Tags: GridGroupingControl
Asked On September 23, 2011 01:05 PM

I want to export the content of a grid made of 2 datatables linked together (one is the child of the other) to an excel file. In order to do that I use the following code:
GroupingGridExcelConverterControl converter = new GroupingGridExcelConverterControl();
converter.GroupingGridToExcel(grid, "test.xls", ConverterOptions.ColumnHeaders);
The problem with that is that it uses the names of the datatable fields when I actually want to see in my excel file the header names. I thought that putting ConverterOptions.ColumnHeaders would make the trick but it doesn't. I have something like this:
client_name, client_id
when I actually want to see the headers name that I have set:
Name, Id
Can you tell me how to achieve this please?

Replied On September 23, 2011 01:27 PM

It does the same whenever I try to put ConverterOptions.RowHeaders instead of ConverterOptions.ColumnHeaders

And it also does the same when I try to put ConverterOptions.ColumnHeaders|ConverterOptions.RowHeaders instead of ConverterOptions.ColumnHeaders

Ragamathulla B [Syncfusion]
Replied On September 27, 2011 12:48 AM

Hi Julien,

Thank you for your interest in syncfusion products.

You can handle this operation through ‘QueryImportExportCellInfo’ event along with the following code and also set the ConverterOptions to ‘ColumnHeaders’.

//In buttonAdv1_Click.

gec.GridToExcel(this.gridControl1.Model, workBook.Worksheets[0],ConverterOptions.ColumnHeaders );

Please refer to the following sample which illustrates the same.


Let me know if you have any other concerns.

Ragamathullah B.


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.