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

推荐订阅源

Project Zero
Project Zero
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
C
Check Point Blog
S
SegmentFault 最新的问题
腾讯CDC
IT之家
IT之家
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
博客园 - Franky
V
Visual Studio Blog
The Register - Security
The Register - Security
GbyAI
GbyAI
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
U
Unit 42
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
Schneier on Security
Schneier on Security
N
News and Events Feed by Topic
T
Troy Hunt's Blog
小众软件
小众软件
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
TaoSecurity Blog
TaoSecurity Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
C
CERT Recently Published Vulnerability Notes
aimingoo的专栏
aimingoo的专栏
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
G
GRAHAM CLULEY
T
Tenable Blog
P
Palo Alto Networks Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
H
Help Net Security
WordPress大学
WordPress大学
The Cloudflare Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
MongoDB | Blog
MongoDB | Blog
Forbes - Security
Forbes - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
W
WeLiveSecurity
I
InfoQ
P
Privacy International News Feed

博客园 - gotolovo

导出excel 正则学习电话匹配 logmanager des 加密 解密 - gotolovo c# 发送邮件 工作流学习过程-事务 工作流学习过程-状态机 蛋疼的viewstate 工作流学习过程-持久化服务 工作流学习过程-使用关联 工作流学习过程-本地服务之事件处理 工作流学习过程-本地服务之调用方法 工作流学习过程-验证活动 工作流学习过程-自定义活动 工作流学习过程-开篇 基本的几个排序算法 关于sql中时间的格式转换 数据行变列 请编程遍历页面上所有TextBox控件并给它赋值为空
导出csv
gotolovo · 2012-04-13 · via 博客园 - gotolovo
public class ExcelHelper
    {
        //导出csv格式
        public static void ExportToCSV(Page page, DataTable dt, string FileName)
        {
            System.Web.HttpResponse resp;
            resp = page.Response;
            resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            resp.HeaderEncoding = System.Text.Encoding.GetEncoding("GB2312");

            resp.AddHeader("Content-Disposition", "attachment; filename=" +System.Web.HttpUtility.UrlEncode(FileName) + ".csv");
            resp.ContentType = "application/ms-excel";
            StringWriter sw = new StringWriter();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                sb.Append(dt.Columns[i].ColumnName);
                if (i != dt.Columns.Count - 1)
                {
                    sb.Append(",");
                }
            }
            sw.WriteLine(sb.ToString());
            foreach (DataRow dr in dt.Rows)
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    sw.Write(dr[i].ToString().Replace("<br/>", ""));
                    if (i != dt.Columns.Count - 1)
                    {
                        sw.Write(",");
                    }

                }
                resp.Write(sw);
                sw.WriteLine("");
                //sw.WriteLine("");
            }
         //   sw.Close();
          //  resp.Clear();
            resp.Write(sw);
            resp.End();
        }
}