码迷,mamicode.com
首页 > 其他好文 > 详细

NPOI的excel导出2

时间:2018-01-17 12:30:49      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:filename   .text   new   exce   文件   system   utf-8   query   tac   

           downExcel.aspx,以下代码放在页面的page_load里面

            string filePath = Request.QueryString["filePath"];
            string fileName = Request.QueryString["fileName"];
            FileInfo fileInfo = new FileInfo(filePath);
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
            Response.AddHeader("Content-Length", fileInfo.Length.ToString());
            Response.AddHeader("Content-Transfer-Encoding", "utf-8");
            Response.ContentType = "application/octet-stream";
            Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
            Response.ContentEncoding = System.Text.Encoding.Default;
            Response.WriteFile(fileInfo.FullName);
            Response.Flush();
            Response.End();

NPOI的excel导出2

标签:filename   .text   new   exce   文件   system   utf-8   query   tac   

原文地址:https://www.cnblogs.com/wugh8726254/p/8302024.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!