Hi all,
I would like to generate reports of a gridview in excel format using asp.net and c#.net
Please help me,,,
Thanks and regards,
Mathew.
Hi all.
I got the answer for the topic..
The code is:
protected void Button1_Click(object sender, EventArgs e)
{
try
{
Response.Clear();
Response.AddHeader("Content-Disposition", "inline;filename=test.xls");
Response.Charset = "iso-8859-1, windows-1252 ";
Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.ContentType = "application/vnd";
this.EnableViewState = false;
StringWriter StringWriter = new StringWriter();
System.Web.UI.HtmlTextWriter htmltextwriter = new System.Web.UI.HtmlTextWriter(StringWriter);
GridView1.RenderControl(htmltextwriter);
Response.Write(StringWriter.ToString());
Response.End();
}
catch
{
}
}
Thanks and regards,
Mathew