I need to export data from infragistics grid to excel and we are using mvc also.I got the code but what it does is loop through each record and then form the excel, which leads to poor performance.But what i want is it should bind the grid data at once like we do in asp.net.
I went through lots of sites including Infragistics one but everywhere same code. Is there any way to achieve that?
below is the code which am using right now
int i = 1;
foreach (Market item in collection)
{
currentWorksheet.Rows[i].Cells[0].Value = item.gp_name;
currentWorksheet.Rows[i].Cells[1].Value = item.gp_MarketCode;
currentWorksheet.Rows[i].Cells[2].Value = item.gp_CountryName;
currentWorksheet.Rows[i].Cells[3].Value = item.gp_ISOCode;
currentWorksheet.Rows[i].Cells[4].Value = item.gp_EricssonOperationalModelEOM;
currentWorksheet.Rows[i].Cells[5].Value = item.gp_region_name;
i++;
}
Response.Clear();
Response.AppendHeader("content-disposition", "attachement; filename=Market.xlsx");
Response.ContentType = "application/octet-stream";
currentWorkbook.SetCurrentFormat(WorkbookFormat.Excel97To2003);
currentWorkbook.Save(Response.OutputStream);
Response.Flush();
Response.End();
//return RedirectToAction("Index");
}