I have some default functionality in a C# asp.net web application that will export a gridview to an excel file. This code is working great in Excel 2007, however it will not open in 2010. I need to upgrade this code to work in both, or find a new solution. Any help would be great.
Current code:
gvReport.Style.Add("font-size", "1em");
Response.Clear();
string attachment = "attachment; filename=FileName.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvReport.GridLines = GridLines.Horizontal;
gvReport.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();