tonyedmo
asked on
Export Gridview to Excel, too much info
I am using the following code to export a gridview into Excel:
Response.Clear();
Response.AddHeader("conten t-disposit ion", "attachment;filename=Allda ta.xls");
Response.Charset = "";
Response.Cache.SetCacheabi lity(HttpC acheabilit y.NoCache) ;
Response.ContentType = "application/vnd.ms-excel" ;
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWrit er htmlWrite = new HtmlTextWriter(stringWrite );
GridView1.RenderControl(ht mlWrite);
Response.Write(stringWrite .ToString( ));
Response.End();
On the same form that the gridview control is in there is also a couple of dropdown list with various information. Well when I use the above code to export the Gridview I get all the values from the dropdowns to appear on the spreadsheet too. How do I make it so only the information from the gridview appears in the Excel spreadsheet and nothing else? Thanks.
Response.Clear();
Response.AddHeader("conten
Response.Charset = "";
Response.Cache.SetCacheabi
Response.ContentType = "application/vnd.ms-excel"
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWrit
GridView1.RenderControl(ht
Response.Write(stringWrite
Response.End();
On the same form that the gridview control is in there is also a couple of dropdown list with various information. Well when I use the above code to export the Gridview I get all the values from the dropdowns to appear on the spreadsheet too. How do I make it so only the information from the gridview appears in the Excel spreadsheet and nothing else? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER