zoukankan      html  css  js  c++  java
  • C# 导出 excel 模板

    <asp:Button ID="Button1" runat="server" Text="导出PWHT模板" OnClick="btnExport_PWHT_Click" >
    </asp:Button>

    protected void btnExport_PWHT_Click(object sender, EventArgs e)
    {

    string path = Server.MapPath("../z_imes_weldlist/导入热处理报告号模板.xlsx");
    FileInfo fi = new FileInfo(path);//excelFile为文件在服务器上的地址
    if (File.Exists(path))
    {
    Response.Clear();
    Response.Buffer = true; //设置<span style="color: rgb(51, 51, 51); line-height: 24px; white-space: pre-wrap;">输出页面是否被缓冲</span>
    Response.Charset = "GB2312"; //设置了类型为中文防止乱码的出现
    Response.AppendHeader("Content-Disposition", String.Format("attachment;filename={0}", HttpUtility.UrlEncode("导入热处理报告号模板.xls"))); //定义输出文件和文件名
    Response.AppendHeader("Content-Length", fi.Length.ToString());
    Response.ContentEncoding = Encoding.Default;
    Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
    Response.WriteFile(fi.FullName);
    Response.Flush();
    Response.End();
    }
    else
    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "<script>alert('此模板不存在!');</script>", false);
    }

    源地址:https://blog.csdn.net/qq_34496400/article/details/51353267

  • 相关阅读:
    解析时间parse time
    php一些高级函数方法
    PHP定界符<<<EOF
    linux crontab(定时任务)
    svn提交按钮灰选
    centos官网下载地址
    centos7 yum安装LAMP
    saprfc
    RSA加解密工具类RSAUtils.java,实现公钥加密私钥解密和私钥解密公钥解密
    接入HTTPS协议的CAS登录配置
  • 原文地址:https://www.cnblogs.com/codejimmygao/p/14857878.html
Copyright © 2011-2022 走看看