Hello,
I'm trying to use RadGridView to export a datatable to Excel. I've created a method that takes a datatable as a parameter, creates a RadGridView, sets the dataSource to the datatable, and then exports. Problem is that the RadGridview doesn't seem to be getting populated with the contents of the dataTable. I feel like I'm missing something like 'gridView.DataBind();' but I can't find anything like that in the documentation. Code is below:
public static void ExportToExcel(DataTable myDT)
{
using (Telerik.WinControls.UI.RadGridView grid = new Telerik.WinControls.UI.RadGridView())
{
grid.AutoGenerateColumns = true;
grid.DataSource = myDT;
//grid.LoadElementTree();
//grid.Refresh();
GridViewSpreadExport spreadExporter = new GridViewSpreadExport(grid);
SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
spreadExporter.RunExport("c:\\exportedFile.xlsx", exportRenderer);
}
}