We are exporting data from rad grid view to excel in one of our applications. Would like to know if there is any limitation on the number of records exported to excel.
If the number of records are above 55 K then export to excel functionality is not working. Please find the sample code below. Appreciate your help.
Sample Code:
private void ExportExcel()
{
BusyIndicator1.IsBusy = true;
try
{
// open file dialog to select an export
file.
SaveFileDialog sDialog
= new SaveFileDialog();
radDataPagerMain.PageSize = 0;
sDialog.DefaultExt = "*.xlsx";
sDialog.Filter = "Excel Workbook
(*.xlsx)|*.xlsx";
if
(sDialog.ShowDialog() == true)
{
var workbook =
CreateWorkBook(radGridView1);
if (workbook != null)
{
var provider = new XlsxFormatProvider();
using (var output = sDialog.OpenFile())
{
provider.Export(workbook, output);
}
}
}
radDataPagerMain.PageSize = 16;
BusyIndicator1.IsBusy = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private static Workbook CreateWorkBook(RadGridView grid)
{
try
{
// return workbook;
Workbook
book = null;
using (var stream = new MemoryStream())
{
grid.Export(stream, new GridViewExportOptions()
{
Format = ExportFormat.Csv,
ShowColumnFooters = grid.ShowColumnFooters,
ShowColumnHeaders = grid.ShowColumnHeaders,
ShowGroupFooters = grid.ShowGroupFooters
});
stream.Position = 0;
book = new CsvFormatProvider().Import(stream);
}
return book;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return null;
}
}