ASP.Net中導出Excel 2007

最近刚刚装了Office 2007遇到一个小问题
以前从Asp.net页面导出到Excel 2003只需要Response.ContentType = "application/vnd.ms-excel";......
但是现在生成的却还是Asp.net的页面。               

 

                Response.Clear();
                Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
                Response.Charset = "gb2312";
                Response.ContentType = "application/vnd.xls";
                System.IO.StringWriter stringWrite = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

                GridView1.AllowPaging = false;
                GridView1.RenderControl(htmlWrite);

                Response.Write(stringWrite.ToString());
                Response.End();
                GridView1.AllowPaging = true;

你可能感兴趣的:(ASP.Net中導出Excel 2007)