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

  • 相关阅读:
    使用Visual Studio自带工具dumpbin解析PE文件
    Python内置函数—bytearray
    .gitignore
    Git本地仓库基本操作
    推荐一款编辑神器UltraEdit
    APK文件结构
    在QQ浏览器中使用微信读书辅助工具“小悦记”插件
    Vue动画
    自定义指令的学习
    Vue过滤器的基本使用
  • 原文地址:https://www.cnblogs.com/codejimmygao/p/14857878.html
Copyright © 2011-2022 走看看