62,051
社区成员
发帖
与我相关
我的任务
分享
string timename = DateTime.Now.ToString("yyyyMMddHHmmss");
string filename = "~/Excel/" + timename + ".xls";
excel.ForExcel(0, excel.data(), Server .MapPath (filename )); //生成excel
string filepath = Server.MapPath(filename );
System.IO.FileInfo fileio = new System.IO.FileInfo(filename );
Response.Clear();
Response.Charset = "gb2312";
Response.ContentEncoding = Encoding.UTF8;
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(timename ,System .Text .Encoding.UTF8 ) + ".xls");
Response.ContentType = "application/ms-excel";
Response.Write(fileio );
fileio.Delete();
Response.End();