View Single Post
  #1 (permalink)  
Old August 1st, 2007, 04:07 AM
deb_kareng deb_kareng is offline
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in exporting data from datagrid to Excel

Hi
   All,

   facing a problem in exporting datagrid to excel.I need some specific column of the grid(not the whole grid)to be exported to excel.have been able to export the whole grid with the following code

Response.Clear();
            Response.Buffer= true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.Charset = "";
            this.EnableViewState = false;
            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
            this.ClearControls(DataGrid1);
            DataGrid1.RenderControl(oHtmlTextWriter);
            Response.Write(oStringWriter.ToString());
            Response.End();

So, can anybody tell what should i do?