string fileName = DateTime.Now.ToString("yyyyMMddhhmmss");//设置导出文件的名称
workbook.SaveCopyAs(Server.MapPath("~") + fileName + ".xlsx");
string path = Server.MapPath("~") + fileName + ".xlsx";
System.IO.FileInfo file = new System.IO.FileInfo(path); Response.Clear();
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-disposition", "attachment; filename=" + file.Name);
Response.ContentType = "application/ms-excel";
Response.WriteFile(file.FullName);这是MVC3控制器中的一个方法中的代码,页面上有一个按钮,能够调用这个方法,我要的效果是下载式的导出Excel,但是我这样写,根本没弹出下载框,求指教,是哪里没设置还是代码错了或者漏写了什么……
workbook.SaveCopyAs(Server.MapPath("~") + fileName + ".xlsx");
string path = Server.MapPath("~") + fileName + ".xlsx";
System.IO.FileInfo file = new System.IO.FileInfo(path); Response.Clear();
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-disposition", "attachment; filename=" + file.Name);
Response.ContentType = "application/ms-excel";
Response.WriteFile(file.FullName);这是MVC3控制器中的一个方法中的代码,页面上有一个按钮,能够调用这个方法,我要的效果是下载式的导出Excel,但是我这样写,根本没弹出下载框,求指教,是哪里没设置还是代码错了或者漏写了什么……
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货