I want to export RadGridview data in excel for this purpose I wrote the following code.
it is showing me an error. screenshoot is attached.
https://imgur.com/kmVLuyM
private void tbExcel_Click(object sender, EventArgs e)
{
/*var excelML = new ExportToExcelML();
excelML.RunExport(dGVClass,"C:\\Reports\\sample.xls",ExportToExcelML.ExcelMaxRows._65536, false);*/
string exportFile = @"C:\\Reports\\Data.xlsx";
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
Telerik.WinControls.Export.GridViewSpreadExport exporter = new Telerik.WinControls.Export.GridViewSpreadExport(this.dGVClass);
Telerik.WinControls.Export.SpreadExportRenderer renderer = new Telerik.WinControls.Export.SpreadExportRenderer();
exporter.RunExport(ms, renderer);
using (System.IO.FileStream fileStream = new System.IO.FileStream(exportFile, FileMode.Create, FileAccess.Write))
{
ms.WriteTo(fileStream);
}
}
/*GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.dGVClass);
SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
spreadExporter.RunExport(@"C:\\exportedFile.xlsx", exportRenderer);*/
}
how to get solution?