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
}
查看全文
相关阅读:
[美团 CodeM 初赛 Round A]最长树链
[POI2005]Toy Cars
[CodePlus2017NOV]晨跑
[JLOI2011]不重复数字
[NEERC2007][SHOI2008]Cactus Reloaded
[NOI2015]软件包管理器
[HAOI2015]树上操作
CF1097D Makoto and a Blackboard
Luogu P5339 [TJOI2019]唱、跳、rap和篮球
HNCPC2019H 有向图
原文地址:https://www.cnblogs.com/yank/p/1026076.html
最新文章
接口测试用例设计实践总结
如何应对“保姆式”软件开发
测试已死,我看未必
Appium移动自动化框架
Appium移动自动化框架
如何快速掌握阿里巴巴内部高效测试流程?
如何快速掌握阿里巴巴内部高效测试流程?
bzoj 1568: [JSOI2008]Blue Mary开公司
bzoj 2957: 楼房重建
luogu P2894 [USACO08FEB]酒店Hotel
热门文章
[POI2007]ZAP-Queries
luogu P2158 [SDOI2008]仪仗队
luogu P2056 采花
最小费用最大流
AC自动机(加强版)
AC自动机
网络最大流
[AGC014D]Black and White Tree
[SDOI2013]直径
[SDOI2011]消防
Copyright © 2011-2022 走看看