protected void lnkbtnExport_Click(object sender, EventArgs e) { ExcelHead.Visible = true; string fileName = "attachment;filename= UserProdReport_" + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + ".xls"; Response.Clear(); Response.AddHeader("content-disposition", fileName); Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); ExcelHead.RenderControl(htmlWrite); gvUserProd.RenderControl(htmlWrite); Response.Write(stringWrite); Response.End(); ExcelHead.Visible = false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)