52,797
社区成员
发帖
与我相关
我的任务
分享
//判断下是不是ff,如果不是则编码,不是则不需要
string UserAgent = Request.ServerVariables["http_user_agent"].ToLower();
string FileName = "销售日报(" + DateTime.Today.ToShortDateString() + ").xls";
if(UserAgent.IndexOf("firefox") == -1)//不是ff时
FileName = HttpUtility.UrlEncode(FileName, Encoding.UTF8);//utf8编码中文
Response.AppendHeader("content-type", "application/vnd.ms-excel");
Response.AppendHeader("Content-Disposition", "attachment;filename="+FileName);
Response.Flush();
Response.WriteFile(Server.MapPath("xx.xls"));