protected void Export_Click(object sender, EventArgs e) { Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Export_ClientName_Pending.xls")); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); Grd_ClientName_Invoice.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["client_Id"] != "" && Session["subProcess_id"] != "") { client_Id = int.Parse(Session["client_Id"].ToString()); Subprocess_id = int.Parse(Session["subProcess_id"].ToString()); } LoadGrid(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Export_Orders.xls")); Response.ContentType = "application/ms-excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); Grd_ClientName_Invoice.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); }