Export tabe Excel in Asp.net
using System.IO;
using System.Web.UI;
using System.Web;
protected void Lnk_Excel_Click(object sender, EventArgs e)
{
//imgSchool.Visible = false;
StringWriter sw = new StringWriter();
HtmlTextWriter h = new HtmlTextWriter(sw);
prntDiv.RenderControl(h);
string str = sw.GetStringBuilder().ToString();
Response.AppendHeader("content-disposition", "attachment;filename=Student strength report.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
Response.Write(str);
Response.End();
}
using System.IO;
using System.Web.UI;
using System.Web;
protected void Lnk_Excel_Click(object sender, EventArgs e)
{
//imgSchool.Visible = false;
StringWriter sw = new StringWriter();
HtmlTextWriter h = new HtmlTextWriter(sw);
prntDiv.RenderControl(h);
string str = sw.GetStringBuilder().ToString();
Response.AppendHeader("content-disposition", "attachment;filename=Student strength report.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";
this.EnableViewState = false;
Response.Write(str);
Response.End();
}
No comments:
Post a Comment