cheat sheet to Export GridView to Excel in ASP.NET
protected void btnExport_Click(object sender, EventArgs e)
{
string attachment = "attachment; filename=Employee.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);
//render gridview control to excel
gvEmployee.RenderControl(htextw);
Response.Write(stw.ToString());
Response.End();
}