Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition","attachment;filename=g.xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter ht = new HtmlTextWriter(sw); gvDisplay.AllowPaging = false; gvDisplay.DataBind(); gvDisplay.RenderControl(ht); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End();
Collapse | Copy Code public override void VerifyRenderingInServerForm(Control control) { }
public void export(GridView gvDisplay, fileName) { Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition","attachment;filename="+fileName+".xls"); Response.Charset = ""; Response.ContentType = "application/vnd.ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter ht = new HtmlTextWriter(sw); gvDisplay.AllowPaging = false; gvDisplay.DataBind(); gvDisplay.RenderControl(ht); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); }
public override void VerifyRenderingInServerForm(Control control) { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)