Hi,
Here is a simple export to excel code that exports to excel without any problems.
Try this out...
protected void btnExportToExcel_Click(object sender, System.EventArgs e)
{
try
{
string attachment = "attachment; filename=Export.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
gvSurvoyDetail.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(gvSurvoyDetail);
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
catch (Exception ex)
{
}
}
Thanks