recently started to code in vs2010 from vs2005. need a code to export to excel from a datagrid. in vs2005 the following code was used.
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=dgd.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
dgd.Visible = true;
dgd.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
this does not yield the same result in vs2005. the header is not aligned to the column. the pictures in the datagrid is not fetched in excel and the links in the datagrid does not appear properly. please suggest a better code.