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

Hello,
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?
Regards,
Julien



2 Replies

JU Julien September 23, 2011 05:27 PM UTC

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



RB Ragamathulla B Syncfusion Team September 27, 2011 04:48 AM UTC

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.

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GCExportWithHeader1984405269.zip

Let me know if you have any other concerns.

Regards,
Ragamathullah B.



Loader.
Up arrow icon