zoukankan
html css js c++ java
GridView导出Exel
在我们的开发,特别是大数据量情况下,经常要设计到系统与办公工具的连接,以便更好的处理这些数据。特别是Exel的应用。
具体的实现代码。
导出Exel Code
1
protected
void
Button1_Click(
object
sender, EventArgs e)
2
{
3
//
Gridview绑定数据
4
BindData();
5
Response.Buffer
=
true
;
/**/
///
定义文档类型、字符编码
6
Response.Clear();
7
HttpContext.Current.Response.Charset
=
"
UTF-8
"
;
8
HttpContext.Current.Response.ContentEncoding
=
System.Text.Encoding.Default;
9
HttpContext.Current.Response.ContentType
=
"
application/ms-excel
"
;
10
/**/
///
输出的文件
11
HttpContext.Current.Response.AppendHeader(
"
Content-Disposition
"
,
"
attachment;filename=
"
+
"
Old.xls
"
);
12
/**/
///
定义一个输入流
13
System.IO.StringWriter tw
=
new
System.IO.StringWriter();
14
System.Web.UI.HtmlTextWriter hw
=
new
System.Web.UI.HtmlTextWriter(tw);
15
/**/
///
将目标数据绑定到输入流输出
16
DataGrid1.RenderControl(hw);
17
HttpContext.Current.Response.Write(tw.ToString());
18
HttpContext.Current.Response.End();
19
}
查看全文
相关阅读:
poj 2251 Dungeon Master
poj 2488 A Knight's Journey
poj 3349
poj 2442
poj 3274 Gold Balanced Lineup
优先队列
广州华盟信息科技有限公司
山东山大华天软件有限公司
RvmTranslator6.5 is released
PipeCAD之管道标准库PipeStd(2)
原文地址:https://www.cnblogs.com/yank/p/1026076.html
最新文章
新LNMP环境,但是SESSION跨页面或者刷新 session丢失
Nginx Location配置总结
用PHP尝试RabbitMQ(amqp扩展)实现消息的发送和接收
RabbitMQ消息队列(一): Detailed Introduction 详细介绍(转)
反向代理服务器的工作原理 (转)
CentOS 6.4 编译安装Mysql 5.6.14
vsftpd配置文件详解
Linux网络编程入门
转:select、poll、epoll之间的区别总结[整理]
Http协议详解
热门文章
Fiddler教程
转:线程池的研究和实现
转:Java多线程基础问题
转:动态规划
OpenGL ES2.0 入门经典例子
OpenGL ES2 缩放移动
背包问题-C语言实现
网页中的Div属性(摘抄)
poj 3126 Prime Path
poj 1426 Find The Multiple
Copyright © 2011-2022 走看看