博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ASP.NET输出CSV文件乱码-解决方法
阅读量:6982 次
发布时间:2019-06-27

本文共 562 字,大约阅读时间需要 1 分钟。

平台  ASP.NET

this.Response.Clear();this.Response.Charset = "GB2312";this.Response.ContentEncoding = Encoding.GetEncoding("GB2312");this.Response.AddHeader("Content-Disposition",String.Format("attachment; filename=file-{0}.csv",DateTime.Now.ToShortDateString()));this.Response.ContentType = "application/vnd.ms-excel";string[] columns = { "序号", "姓名", "手机号码", "电子邮箱", "省份", "城市", "地区" };const string csv = "1,2,3";var builder = new StringBuilder();builder.AppendLine(String.Join(",",columns));builder.AppendLine(csv);this.Response.Write(builder);this.Response.End();

 

转载地址:http://tftpl.baihongyu.com/

你可能感兴趣的文章
Windows与Linux系统拷贝文件之pscp的使用
查看>>
_xmlXPathNewContext", referenced from
查看>>
Netty3之ServerBootstrap分析
查看>>
小木木的Python学习笔记
查看>>
用SQL语句添加删除修改字段
查看>>
查md5或者sha1值
查看>>
spring MVC(2)--注解Hello World
查看>>
httpclient 小例子编写
查看>>
我的友情链接
查看>>
修改了系统时间后,myeclipse 和tomcat下的代码不同步了
查看>>
IDEA 一直不停的scanning files to index解决办法
查看>>
运维少年系列 python and cisco (1)
查看>>
c#时间转换
查看>>
调度器Quartz的简述与使用总结
查看>>
smokeping 安装
查看>>
Linux下安装oracle数据库步骤
查看>>
yum 不小心删除后安装
查看>>
vim 使用
查看>>
为敏感信息设置安全屏障
查看>>
进程与线程
查看>>