zoukankan      html  css  js  c++  java
  • 导出Excel中文名乱码解决办法

            /// <summary>
            /// 文本流送到客户端,关显示为另存为
            /// </summary>
            /// <param name="response">页面response类</param>
            /// <param name="fileName">另存为的文件名</param>
            public void FileWebSaveAs(HttpResponseBase response, string fileName)
            {
                response.Clear();
                response.ClearHeaders();
                response.Buffer = false;
                response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8) + ".xls");
                response.ContentType = "application/ms-excel";
                response.ContentEncoding = System.Text.Encoding.UTF8;

                //response.Write(DataTableToExcelStr(_dt));
                System.IO.MemoryStream ms;
                string strExcel = ListToExcelStr(_listItem);
                int Step = 1024000;
                int startIndex = 0;
                int excelLength = strExcel.Length - Step;
                while (startIndex < excelLength)
                {
                    ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(strExcel.Substring(startIndex, Step)));
                    response.BinaryWrite(ms.ToArray());
                    startIndex += Step;
                }
                response.BinaryWrite(System.Text.Encoding.UTF8.GetBytes(strExcel.Substring(startIndex, strExcel.Length - startIndex)));
                response.Flush();
                response.End();
            }

  • 相关阅读:
    生成一个签章(用java.awt画一个签章) 并添加到pdf 公章处
    数字转字符串的处理
    Mybatis .xml编译常识
    聚合查询|F查询Q查询
    表查询
    FBV与CBV
    伪静态|虚拟环境|form表单
    数据增删改查|路由层
    django基础 链接数据库|静态文件配置
    WEB框架初学
  • 原文地址:https://www.cnblogs.com/guanjie20/p/2050272.html
Copyright © 2011-2022 走看看