惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 热门话题
Stack Overflow Blog
Stack Overflow Blog
B
Blog
WordPress大学
WordPress大学
Project Zero
Project Zero
P
Palo Alto Networks Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
T
Tailwind CSS Blog
Forbes - Security
Forbes - Security
F
Full Disclosure
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hacker News: Ask HN
Hacker News: Ask HN
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Fortinet All Blogs
Cisco Talos Blog
Cisco Talos Blog
G
Google Developers Blog
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
O
OpenAI News
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
IT之家
IT之家
U
Unit 42
腾讯CDC
S
Security Affairs
C
Cisco Blogs
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
宝玉的分享
宝玉的分享
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss

博客园 - zhangsir

.net 项目 调用webservice 出错,异常信息:对操作“xxx”的回复消息正文进行反序列化时出错。解决方案。 手机版web相关meta配置 网页中点击运行执行代码 js 在页面上模拟多选,蚂蚁线线框 C# 检测程序运行时间的方法,Stopwatch类 js获取url参数值 flash as2 简易手写板,带擦除功能 flash as2 BitmapData应用之 ---- 画双线 svn(版本管理) 去掉(清理)版本信息的方法 sql 数据库显示 正在恢复 as3中parent访问属性所牵涉的强制类型的问题 [AS3]URLVariables传入URL编码字符串时的一些官方无文档的原则 sql 日期 、时间相关 100万个不重复的8位的随机数 flash 中实现斜切变型 使用UpdatePanel 局部刷新出现中文乱码的解决方法!! - zhangsir - 博客园 loaded AS2 swf call function in AS3 holder - zhangsir Rewrite the master page form action attribute in asp.net 2.0 sql2000 跨服务器复制表数据
C#导出csv文件 支持中文的解决方案
zhangsir · 2013-12-24 · via 博客园 - zhangsir
        #region 导出CSV下载
        string exportFileName = "Export" + DateTime.Now.ToString("yyyyMMddHHmmss");
        System.Web.HttpContext context = System.Web.HttpContext.Current;
        StringBuilder sb = new StringBuilder();
        sb.Append("FirstName,LastName,PhoneNo.,State,TimeZone,ZipCode\n");
        for (int i = 0; i < result.PhoneList.Count; i++)
        {
            sb.Append(result.PhoneList[i].FirstName + "," + result.PhoneList[i].LastName + "," + result.PhoneList[i].Phone + "," + result.PhoneList[i].State + "," + result.PhoneList[i].TimeZone + "," + result.PhoneList[i].ZipCode + "\n");
        }
        StringWriter sw = new StringWriter(sb);
        sw.Close();
        context.Response.Clear();
        /* 
         * Acme 2012-07-04 edit 
         *  
        context.Response.Charset = "gb2312"; 
        context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); 
        context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; // "application/octet-stream"; //"application/vnd.ms-excel"; //application/vnd.openxmlformats-officedocument.spreadsheetml.sheet                   
        //context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", fileName)); 
        */
        //below is new writing  
        context.Response.Charset = "UTF-8";
        context.Response.ContentEncoding = System.Text.Encoding.UTF8;
        context.Response.HeaderEncoding = System.Text.Encoding.UTF8;
        context.Response.ContentType = "text/csv";
        //主要是下面这一句
        context.Response.BinaryWrite(new byte[] { 0xEF, 0xBB, 0xBF });
        context.Response.Write(sw);
        context.Response.AppendHeader("content-disposition", "attachment; filename=" + HttpUtility.UrlEncode(exportFileName + ".csv", System.Text.Encoding.UTF8).Replace("+", "%20"));
        //context.Response.OutputStream.Write(fileData, 0, fileData.Length);  
        context.Response.Flush();
        context.Response.End();
        #endregion