zoukankan      html  css  js  c++  java
  • ASP.NET 导出excel文件出现乱码的解决办法

    string html =TABLE ;//<table>标签,可以是多张表
    string modified = Regex.Replace(html, "<table >", "<table cellspacing="0"  rules="all" border="1" style="border-collapse:collapse;">");//用正则表达式进行规范
    Response.Clear();
    Response.Buffer = true;
    Response.Charset = "GB2312";
    Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("文件名称.xls"));
    Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
    Response.ContentType = "application/vnd.ms-excel";
    Response.Cache.SetCacheability(HttpCacheability.NoCache); // not necessarily required
    Response.Output.Write(modified);
    Response.Flush();
    Response.End();
  • 相关阅读:
    十个MySQL常用函数
    写给三十岁的自己
    EJS 模板引擎
    发送HTTP请求(GET,POST)
    路由模块化
    原生NodeJS封装Express路由
    Hook简介
    State Hook (useState)
    Effect hooks
    useContext
  • 原文地址:https://www.cnblogs.com/yh2015/p/5988350.html
Copyright © 2011-2022 走看看