How to export a RadDataGrid to Excel using data virtualization

4 posts, 0 answers
  1. Mechthild
    Mechthild avatar
    4 posts
    Member since:
    Sep 2011

    Posted 21 Oct 2011 Link to this post


    I am using a RadGridView and data virtualization. My itemssource is a VirtualQueryableCollectionView and the LoadSize is set to 40. I have implemeted the export to Excel. Now in Excel I only recieved 40 data rows. What can I do to export the whole grid?

    VirtualQueryableCollectionView view = new VirtualQueryableCollectionView(viewModel0.GetQuery());
    view.LoadSize = 40;
    EntityDataGrid.ItemsSource = view;


    using (Stream stream = dialog.OpenFile())
          GridViewExportOptions exportOptions = new GridViewExportOptions();
          exportOptions.Format = format;
          exportOptions.ShowColumnFooters = false;
          exportOptions.ShowColumnHeaders = true;
          exportOptions.ShowGroupFooters = true;
          EntityDataGrid.Export(stream, exportOptions);
    Thanks for help in advance
  2. Vlad
    Vlad avatar
    11100 posts

    Posted 21 Oct 2011 Link to this post


     You need to download all the data in order to export them all - not sure however if virtual collection is applicable in this case. 

    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Jacob
    Jacob  avatar
    49 posts
    Member since:
    Apr 2016

    Posted 07 Dec 2016 in reply to Vlad Link to this post

    Hi Vlad!

    I know this post is 5 years old, but I am facing this same issue. Does it mean that there is no way to export that kind of gridview?

    If it is needed to load all data, i need to know how to do so while maintaining the groups and the filters. is there an answer to that?

    thank you

  4. Martin
    Martin avatar
    160 posts

    Posted 12 Dec 2016 Link to this post

    Hi Jacob,

    If you want to be able to export all items you must ensure that they are loaded. For example, if your ViewModel has a VirtualQueryableCollectionView called View, you can do this in the following way:
    var viewModel = this.RadGridView.DataContext as ViewModel;
    viewModel.View.LoadSize = this.RadGridView.Items.TotalItemCount;

    To better demonstrate this, I'm attaching a sample project for you to have a look at.
    Bear in mind that this will lead to poor performance when dealing with large amounts of data. 

    As for your second question, I will ask you to provide more information in order to better understand, what exactly do you have in mind.

    I hope you find this information helpful.

    Martin Vatev
    Telerik by Progress
    Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Back to Top