export data in excel in single sheet

Posted on May 12, 2008. Filed under: Asp.net |

protected void exporttoexcel_Click(object sender, EventArgs e)

{Response.Clear();

Response.Buffer = true;

Response.ContentType = “application/vnd.ms-excel”;

Response.ContentEncoding = System.Text.Encoding.UTF7;

Response.AddHeader(“Content-Disposition”, “attachment;filename=report.xls”);

Response.Charset = “”;

this.EnableViewState = false;

System.IO.StringWriter oStringWriter = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);

rpt.RenderControl(oHtmlTextWriter);

Response.Write(oStringWriter.ToString());

Response.End();

}

Make a Comment

Make A Comment: ( 1 so far )

blockquote and a tags work here.

One Response to “export data in excel in single sheet”

RSS Feed for Dream Asp.net Comments RSS Feed

This is not working when i handling large
volume of data.
Would you pls give me any advise.

enam
July 9, 2008

Where's The Comment Form?

    About

    Hi,I am Suresh Sharma(MCP) from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...