gridview转Excel时 ,文件名为乱码的解决方法
来源:互联网 发布:js怎么隐藏span 编辑:程序博客网 时间:2024/05/21 21:43
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" +HttpUtility.UrlEncode("考勤")+ path + ".xls");
彻底解决的方法:
string FileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("考勤" + path + ".xls"));
//HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + System.Convert.ToChar(34) + FileName + System.Convert.ToChar(34));
HttpContext.Current.Response.AppendHeader("Content-Disposition", "inline;filename=" + System.Convert.ToChar(34) + FileName + System.Convert.ToChar(34));
注意:其中inline是在线,attachment是(下载)
public static string UrlEncode(string str, System.Text.Encoding e)
Member of System.Web.HttpUtility
Summary:
Encodes a URL string using the specified encoding object.
Parameters:
e: The System.Text.Encoding object that specifies the encoding scheme.
str: The text to encode.
Returns:
An encoded string.
public sealed class HttpUtility
Member of System.Web
Summary:
Provides methods for encoding and decoding URLs when processing Web requests. This class cannot be inherited.
彻底解决的方法:
string FileName = System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes("考勤" + path + ".xls"));
//HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + System.Convert.ToChar(34) + FileName + System.Convert.ToChar(34));
HttpContext.Current.Response.AppendHeader("Content-Disposition", "inline;filename=" + System.Convert.ToChar(34) + FileName + System.Convert.ToChar(34));
注意:其中inline是在线,attachment是(下载)
public static string UrlEncode(string str, System.Text.Encoding e)
Member of System.Web.HttpUtility
Summary:
Encodes a URL string using the specified encoding object.
Parameters:
e: The System.Text.Encoding object that specifies the encoding scheme.
str: The text to encode.
Returns:
An encoded string.
public sealed class HttpUtility
Member of System.Web
Summary:
Provides methods for encoding and decoding URLs when processing Web requests. This class cannot be inherited.
- gridview转Excel时 ,文件名为乱码的解决方法
- 下载文件时文件名为乱码解决方法
- CAS单点登录,用户名为中文时,乱码的解决方法
- Gridview导出为Excel的时候,中文文件名乱码,解决方法
- Excel打开CSV文件乱码的解决方法
- EXCEL打开CSV文件乱码的解决方法
- 解决火狐/IE导出Excel文件名为中文时乱码问题
- java下载excel文件在firefox中文件名为乱码
- Ubuntu 下 Eclipse DDMS 显示设备名为乱码 “?????? “的解决方法
- GridView导出Excel文件(无乱码)
- 解决用ASP.NET下载文件时,文件名为乱码的问题
- 解决从数据库下载文件时,中文文件名为乱码的问题!
- 巧用find命令管理文件名为乱码的文件
- 巧用find命令管理文件名为乱码的文件
- linux 删除文件名为乱码的文件方法
- 解决下载文件等文件名为中文,乱码的方法。
- Linux下删除文件名为乱码的文件
- extremecomponents extremetable的导出时中文文件名为乱码的问题解决
- 漂亮图骗新闻
- 防止页面刷新重复提交的方法
- ASP.NET配置文件Web.config 详细解释
- Tomcat 6 通过 JDBC 连接池连接 SQL Server 2000 和 MySQL 5 的设置
- WINDOWSXP主题风格美化教程
- gridview转Excel时 ,文件名为乱码的解决方法
- fileUpload选图片image中显示
- 设置自动关机
- 一位软件工程师的6年总结
- flex 优化
- 配置Tomcat使用SSL
- 软件资料总结
- 模仿口碑网个人管理左侧的效果IE和ff都可用
- 让ubuntu/debian系统xmms播放器支持wma和ape格式