string fileName = id + ".xlsx";
string path = Path.Combine(ExportPath, fileName);
NPOIExcelHelper.DataTable2Excel(table, path, "sheet1");
HttpContext.Response.ClearContent();
HttpContext.Response.Clear();
HttpContext.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, Encoding.UTF8));
HttpContext.Response.ContentType = "application/ms-excel";
HttpContext.Response.Charset = "UTF-8";
HttpContext.Response.ContentEncoding = Encoding.UTF8;
HttpContext.Response.TransmitFile(path);
HttpContext.Response.Flush();
HttpContext.Response.End();
ASP.NET 弹出保存对话框
最新推荐文章于 2024-07-29 18:09:51 发布