Export to Excel

2 posts, 0 answers
  1. Bilal
    Bilal avatar
    2 posts
    Member since:
    Sep 2013

    Posted 24 Sep 2013 Link to this post

    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
  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3945 posts

    Posted 27 Sep 2013 Link to this post

    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 >>
Back to Top