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

  • 相关阅读:
    A
    MongoDB小结17
    MongoDB小结16
    金蝶无法生成下推发票
    MongoDB小结15
    MongoDB小结14
    MongoDB小结13
    MongoDB小结12
    MongoDB小结11
    MongoDB小结10
  • 原文地址:https://www.cnblogs.com/Chinarain/p/5553250.html
Copyright © 2011-2022 走看看