Edit this page

Grid Async Export

You can use RadGridView`s ExportAsync method in order to export data asynchronously. The method was introduced in Q3 2013. As in the synchronous Export functionality, the method expects two parameters:

  1. Stream - usually the file stream which you are exporting data to.

  2. GridViewExportOptions or GridViewCsvExportOptions object - you can use it to set exporting options. You can check the Export method documentation for more information on how to configure the export options.

As of version 2015 Q1 SP we have introduced an overload of the ExportAsync method that exposes "finished callback": Action exportFinishedCallback.

The ExportAsync method can be used similar to the Export method:

[C#]Example 1: Save RadGridView`s conteint in a Excel file

string extension = "xls";
SaveFileDialog dialog = new SaveFileDialog()
{
    DefaultExt = extension,
    Filter = String.Format("{1} files (*.{0})|*.{0}|All files (*.*)|*.*", extension, "Excel"),
    FilterIndex = 1
};
if (dialog.ShowDialog() == true)
{
    Stream stream = dialog.OpenFile();
    clubsGrid.ExportAsync(stream,
    new GridViewExportOptions()
    {
        Format = ExportFormat.ExcelML,
        ShowColumnHeaders = true,
        ShowColumnFooters = true,
        ShowGroupFooters = false,
    }, true);
}
        }

Please note that you should specify a True value for the shouldDisposeStream parameter. That way the used resources will be disposed. Prior to version 2015 Q1 SP, the parameter is called shouldDisposeString.

You can read more about the export events here.

See Also