NPOI的excel导出2

           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();

本文来自博客园,作者:.net&new,转载请注明原文链接:https://www.cnblogs.com/wugh8726254/p/8302024.html

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