RadGridView ExportToWorkbook very slow

1 Answer 35 Views
GridView
Deltaohm
Top achievements
Rank 2
Iron
Iron
Iron
Deltaohm asked on 04 Aug 2022, 12:33 PM

Hi,

I use RadGridView.ExportToWorkbook on a grid with over 600 000 rows: the operation take much than 5' to end. Can I speed up it?

Thank you

Luigi

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 05 Aug 2022, 11:57 AM

Hello Gianluca,

Exporting such big amount of data takes some time. To improve this, you can delegate the part that saves the Workbook into a stream (like a file stream) to another thread. For example:

        private BackgroundWorker worker;
	private Workbook documentToExport;
	private XlsxFormatProvider provider = new XlsxFormatProvider();

	private void InitializeExportWorker()
	{
		worker = new BackgroundWorker();
		worker.DoWork += Worker_DoWork;
		worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
	}

	private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
	{
		// report export completed if needed
		this.documentToExport = null;
	}

	private void Worker_DoWork(object sender, DoWorkEventArgs e)
	{   
		using (var output = File.Open("sampleDocument.xlsx", FileMode.OpenOrCreate))
		{
			provider.Export(this.documentToExport, output);
		}
	}

	public MainWindow()
	{
		InitializeExportWorker();
		InitializeComponent(); 		
	}

	private void RadButton_Click(object sender, RoutedEventArgs e)
	{
		this.documentToExport = this.gridView.ExportToWorkbook();
		this.worker.RunWorkerAsync();
	}

Or alternatively, you can use the SpreadStreaming exporting: https://docs.telerik.com/devtools/wpf/controls/radgridview/export/excel/export-with-spreadsheetstreamingexport

I hope this information helps.

Regards,
Martin Ivanov
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Tags
GridView
Asked by
Deltaohm
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or