zoukankan      html  css  js  c++  java
  • 下载excel弹出存储路径

    只需要创建一个空页面

    在CS页面添加如下代码

    protected void Page_Load(object sender, EventArgs e)
    {
    string path = Request.QueryString["path"];
    string fileName = Request.QueryString["fileName"];
    System.IO.FileInfo filet = new System.IO.FileInfo(path);
    Response.Clear();
    Response.Charset = "GB2312";
    Response.ContentEncoding = System.Text.Encoding.UTF8;
    // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
    Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fileName));
    // 添加头信息,指定文件大小,让浏览器能够显示下载进度
    Response.AddHeader("Content-Length", filet.Length.ToString());

    // 指定返回的是一个不能被客户端读取的流,必须被下载
    Response.ContentType = "application/ms-excel";

    // 把文件流发送到客户端
    Response.WriteFile(filet.FullName);
    // 停止页面的执行

    Response.End();
    }

  • 相关阅读:
    day31-python之内置函数
    day30-python之socket
    day28-python之property
    day27-python之迭代器协议
    day26-python之封装
    day25-python之继承组合
    初识AJAX
    写博客的心得
    web前端常见面试题
    学习网络安全的网站
  • 原文地址:https://www.cnblogs.com/Chinarain/p/5553250.html
Copyright © 2011-2022 走看看