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

How to export a RadDataGrid to Excel using data virtualization

3 Answers 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mechthild
Top achievements
Rank 1
Mechthild asked on 21 Oct 2011, 11:20 AM
Hi,

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
Mechthild

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 21 Oct 2011, 11:55 AM
Hello,

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

Regards,
Vlad
the Telerik team

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

0
Jacob
Top achievements
Rank 1
answered on 07 Dec 2016, 01:25 PM

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

0
Martin
Telerik team
answered on 12 Dec 2016, 06:58 AM
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.

Regards,
Martin Vatev
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
GridView
Asked by
Mechthild
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Jacob
Top achievements
Rank 1
Martin
Telerik team
Share this question
or