Editing Excel Export

2 posts, 0 answers
  1. Minh
    Minh avatar
    43 posts
    Member since:
    May 2014

    Posted 29 Apr 2016 Link to this post

    Hi, I used some excel export code previous posted on a thread. It works great, but I'm wondering if we can intercept midway. I'm looking to add a value on the top row then followed by the chart.

    public static void Export(RadGridView grid)
        const string extension = "xls";
        var dialog = new SaveFileDialog
            DefaultExt = extension,
            Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel"),
            FilterIndex = 1
        if (dialog.ShowDialog() != true)
        using (var stream = dialog.OpenFile())
            var exportOptions = new GridViewExportOptions
                Format = ExportFormat.ExcelML,
                ShowColumnHeaders = true,
                ShowColumnFooters = true,
                ShowGroupFooters = false,
            exportOptions.Items = (IEnumerable)grid.ItemsSource;
            grid.Export(stream, exportOptions);
  2. Dilyan Traykov
    Dilyan Traykov avatar
    1073 posts

    Posted 03 May 2016 Link to this post

    Hello Minh,

    RadGridView provides two events which fire when you export data from RadGridView in the ExcelML format - ElementExporting and ElementExported. You can handle them in order to format the cell values to be exported or if you want to write additional data to the stream.

    I hope you find this information helpful.

    Dilyan Traykov
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top