Response.Clear(); Response.Buffer = true; string filename = "GridViewExport_" + DateTime.Now.ToString() + ".xls"; Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.Charset = ""; Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); gvwReport.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)