This is a migrated thread and some comments may be shown as answers.

Export to Excel

1 Answer 192 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bilal
Top achievements
Rank 1
Bilal asked on 24 Sep 2013, 01:35 PM
Hello,

How can I export the data shown in RadGridView.
GridView.CellFormatting event is used to format and transformed the data (e.g., convert hours to seconds, change the format of the date, etc)

After exporting the data to excel using ExportToExcelIML I get the RAW data and NOT the transformed data shown in the gridview

Regards,
Bilal

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Sep 2013, 01:32 PM
Hello Bilal,

Thank you for contacting Telerik Support.

In order to achieve date formatting for example, you should set ExcelExportFormatString property of the desired grid column. Also you can subscribe to ExcelCellFormatting of the ExportToExcelML exporter where to customize the style:
ExportToExcelML exporter = new ExportToExcelML(this.radGridView1);
exporter.ExportVisualSettings = true;
exporter.SummariesExportOption = SummariesOption.DoNotExport;
 
this.radGridView1.Columns["Date"].ExcelExportType = DisplayFormatType.Custom;
this.radGridView1.Columns["Date"].ExcelExportFormatString = "yyyy.MMMM.dd";
 
exporter.ExcelCellFormatting += exporter_ExcelCellFormatting;
 
string fileName = @"C:\Projects\740200 GridExcel\ExportedData123.xls";
exporter.RunExport(fileName);

private void exporter_ExcelCellFormatting(object sender, Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventArgs e)
{
    if (e.GridCellInfo.Value is DateTime)
    {
        DateTime dt = (DateTime)e.GridCellInfo.Value;
 
        e.ExcelStyleElement.FontStyle.Bold = true;
    }
}

More information about excel exporting you can find in Export to Excel via ExcelML Format help article.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Bilal
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or