Monday, August 20, 2012

How to Export the Gridview Data to Excel Sheet Using C#.NET


            Response.Clear();

            Response.AddHeader("content-disposition", "attachment; filename=voting.xls");

            Response.Charset = "";

            Response.ContentType = "application/vnd.xls";

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

            System.Web.UI.HtmlTextWriter htmlWrite =
            new HtmlTextWriter(stringWrite);

            GVRestaurantList.RenderControl(htmlWrite);

            Response.Write(stringWrite.ToString());

            Response.End();

No comments:

Post a Comment


Blog Widgets