zoukankan      html  css  js  c++  java
  • ashx

    前端调用

          window.location.href = "192.168.100.18/OutExcel/YJZHStatistics.ashx?code=" + code + "&Token=" + token + "&filename=" + filename + "&browserType=" + browserType;
     public void ProcessRequest(HttpContext context)
            {    
                string guid = HttpContext.Current.Request.Params["guid"];
                string browserType = HttpContext.Current.Request.Params["browserType"];
                string filename = "";
                byte[] bytes;   //将excel转成byte        
                context.Response.Clear();
                context.Response.ContentType = "application-excel";
                if (browserType == "fireFox")
                {
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlDecode(filename, System.Text.Encoding.UTF8) + ".xlsx");
                }
                else
                {
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".xlsx");
                }
                HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
                HttpContext.Current.Response.Charset = "UTF-8";
                context.Response.BinaryWrite(bytes);
                context.Response.Flush();
                context.Response.Close();
            }
  • 相关阅读:
    luogu 3388 【模板】割点(割顶)
    bzoj 3624 免费道路
    bzoj 1179 Atm
    bzoj 2428 均分数据
    luogu 4429 染色
    luogu 4427 求和
    luogu 1121 环状最大两段子段和
    hdu 4777 Queue
    hdu 5492 Find a path
    hdu 5441 Travel
  • 原文地址:https://www.cnblogs.com/macT/p/12068660.html
Copyright © 2011-2022 走看看