Multiple RadGridView export to Excel, save once

2 posts, 0 answers
  1. Arash
    Arash avatar
    6 posts
    Member since:
    Oct 2020

    Posted 24 Nov 2020 Link to this post


    All examples, forums and online docs discuss calling GridViewSpreadExport's RunExport method on every iteration of a loop when exporting multiple RadGridViews.

    This is costly as the Excel document is opened, written to and saved on every iteration.

    Is there a way of avoiding having to call RunExport on every iteration?
    Ideally, you'd want to setup multiple Excel sheets from RadgRidViews in memory and then issue the RunExport command outside of the loop.

    Is there a mechanism to achieve this, either with GridViewSpreadExport  / SpreadExportRenderer or other...?



  2. Nadya
    Nadya avatar
    459 posts

    Posted 26 Nov 2020 Link to this post

    Hello, Arash,

    You can not avoid calling the RunExport method on each iteration when exporting multiple grids. If you want to achieve a better performance, I would suggest you using the GridViewSpreadStreamExport in this case. The GridViewSpreadStreamExport uses the RadSpreadStreamProcessing library which allows you to create big documents (without loading the entire document in the memory) and export them. 

    Spread streaming is a document processing paradigm that allows you to create big spreadsheet documents with great performance and minimal memory footprint. The key for the memory efficiency is that the spread streaming library writes the spreadsheet content directly to a stream without creating and preserving the spreadsheet document model in memory. Each time an exporter object is disposed, the set values are written into the stream. RadSpreadStreamProcessing library to create and export a large amount of data with a low memory footprint which I believe would be suitable if you export multiple grids.

    It offers FileExportMode property. You can set it so that you export multiple grids in a single file each being on a separate sheet:

    private void radButton1_Click(object sender, EventArgs e)
        foreach (Control grd in this.Controls)
            if (grd is RadGridView)
                GridViewSpreadStreamExport spreadStreamExport = new GridViewSpreadStreamExport(grd as RadGridView);
                spreadStreamExport.ExportVisualSettings = true;
                spreadStreamExport.FileExportMode = FileExportMode.NewSheetInExistingFile;
                SpreadStreamExportRenderer exportRenderer = new SpreadStreamExportRenderer();
                spreadStreamExport.RunExport(@"D:\StreamExport.xlsx", exportRenderer);

    An alternative approach is to create a workbook on your own, iterate all the grids and populate the workbook with the data from the grids programmatically. Once all grids are traversed and the workbook is filled with data, you can export it to an Excel file. The following blogs are quite useful on this topic: 

    I hope this information is useful. If you have other questions please let me know.

    Progress Telerik

    Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at

Back to Top