Code: Select all
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = String.Empty;
Response.ContentType = "application/vnd.xls";
var sw = new System.IO.StringWriter();
var hw = new HtmlTextWriter(sw);
GridView1.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();