string style =
"<style>" +
".title{font-weight:bold;font-size:30px;color:red;text-align:center;}" +
".BH_ListHD{font-family:宋体;font-size:12pt;font-weight:bold;height:30px;}" +
".BH_ListTD{font-family:宋体;font-size:12pt;height:30px;}" +
"</style>" +
"<table><tr><td colspan='13' class='title'>" + excel + "</td></tr></table>";
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.msnumberformat:@";
this.EnableViewState = false;
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(excel + ".xls", System.Text.Encoding.UTF8));
Response.Write("<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=gb2312\"/>" + style + HtmlCode);
//Response.Write(style + HtmlCode);
Response.End();
解决方法:
在Write添加<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=gb2312\"/>一起输出