Response.ContentType = "application/ms-Excel";
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.AddHeader("Content-Disposition", "inline;filename="
+ HttpUtility.UrlEncode("OutPut.xls", System.Text.Encoding.UTF8));
this.EnableViewState = false;
GongSi gongSi = new GongSi();
GridView1.DataSource = gongSi.ListRecord(select);
GridView1.DataBind();
用这段代码导出的Excel文件,如果没有加红色代码,只有Excel2007,WPS Et2007能打开;加了后Excel2003也能打开了。