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

推荐订阅源

S
SegmentFault 最新的问题
MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
The GitHub Blog
The GitHub Blog
博客园 - Franky
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
V
Visual Studio Blog
IT之家
IT之家
美团技术团队
博客园 - 司徒正美
Martin Fowler
Martin Fowler
Last Week in AI
Last Week in AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
雷峰网
雷峰网
B
Blog
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
D
Docker
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
爱范儿
爱范儿

博客园 - 清虚真人

关于flask-sqlalchemy的用法研究 [原]跟我学silverlight系列教程[1]—wpf/silverlight体系架构和运行机制 [原]跟我学silverlight系列教程 sql2005 数据库没有完全关闭,无法重新生成日志 IIS中网站出错 javascript获取滚动条位置 - 清虚真人 - 博客园 .Net framework [转载]My97DatePicker在Frame中无法打开站点 sql select的时候按特定的顺序排序 vs2008 安装Silverlight tools遇到的崩溃问题。。。 关于.NET中的Server push技术 .net 几种序列化类的比较 asp.net ajax实现(—):Jquery+Json WPF中BitMapEffect的性能问题 我写的PageDataSurce分页的 asp.net页面执行机制 关于服务器端控件的attributes属性的奇怪问题 关于使用javascript+asp.net实现多文件上传的若干问题 正则表达式相关教程
输出datagrid的内容到excel - 清虚真人 - 博客园
清虚真人 · 2009-10-15 · via 博客园 - 清虚真人

private void OutPutToExcel()
        {
            Response.Clear();
            Response.Buffer = true;

            Response.Charset = "GB2312";
            Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=GB2312\">");
            this.EnableViewState = false;
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            Response.ContentType = "application/ms-excel";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("FileName", System.Text.Encoding.UTF8) + ".xls");
            System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
            StringWriter sw = new StringWriter(myCItrad);
            HtmlTextWriter writer = new HtmlTextWriter(sw);
            GridExcel.RenderControl(writer);
            Response.Write(sw.ToString());
            Response.End();
        }