Export Label or Panel to excel RRS feed

  • Question

  • User1344924657 posted

    I am trying to export either labels or a whole panel along with a gridview to excel.  I know how to export the gridview by itself but i need to export labels to show criteria of the gridview.  If this is possible any help would be appreciated.

    Friday, November 7, 2008 1:37 PM


  • User-2106054853 posted


    It's just as what you do for GridView:

             Response.Clear();<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>        Response.AddHeader("content-disposition", "attachment; filename=FileName1.xls");<o:p></o:p>        Response.Charset = "";<o:p></o:p>        Response.ContentType = "application/vnd.xls";<o:p></o:p>        System.IO.StringWriter stringWrite = new System.IO.StringWriter();<o:p></o:p>

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



            GridView1.RenderControl(htmlWrite);<o:p></o:p>        Response.Write(stringWrite.ToString());<o:p></o:p>        Response.End();<o:p></o:p>


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 10, 2008 4:13 AM