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?
|