zoukankan
html css js c++ java
导出GridView到Excel中的关键之处(downmoon)
导出GridView到Excel中的关键之处
用法: ToExcel(GVStaff, TextBox1.Text);
public
static
void
ToExcel(System.Web.UI.Control ctl,
string
FileName)
...
{
HttpContext.Current.Response.Charset
=
"
UTF-8
"
;
HttpContext.Current.Response.ContentEncoding
=
System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType
=
"
application/ms-excel
"
;
HttpContext.Current.Response.AppendHeader(
"
Content-Disposition
"
,
"
attachment;filename=
"
+
""
+
FileName
+
"
.xls
"
);
ctl.Page.EnableViewState
=
false
;
System.IO.StringWriter tw
=
new
System.IO.StringWriter();
HtmlTextWriter hw
=
new
HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
必须有下面这句!否则不会通过!
public override void VerifyRenderingInServerForm(Control control)
...
{
// Confirms that an HtmlForm control is rendered for
}
邀月注:本文版权由邀月和博客园共同所有,转载请注明出处。
助人等于自助!
3w@live.cn
查看全文
相关阅读:
isalnum()方法
index()方法
find()方法
expandtabs()方法
endswith()方法
encode()方法
bytes.decode()方法
count()方法
center()方法
capitalize()方法
原文地址:https://www.cnblogs.com/downmoon/p/1019303.html
最新文章
hdu 5950 Recursive sequence 递推式 矩阵快速幂
bzoj 1228 [SDOI2009]E&D SG函数打表 找规律
hdu 3980 Paint Chain 组合游戏 SG函数
hdu 2147 kiki's game 组合游戏 找规律
学习参考
hdu 1848 Fibonacci again and again 组合游戏 SG函数
hdu 1847 Good Luck in CET-4 Everybody! 组合游戏 找规律
hdu 5972 Regular Number 字符串Shift-And算法 + bitset
Codeforces Round #441 Div. 2 A B C D
Codeforces 870E Points, Lines and Ready-made Titles 计数
热门文章
CentOS查看进程、杀死进程、启动进程等常用命令
centos 6.5 查看、开启,关闭 端口
WISH开发API
最全的分区类型及详解
MySQL表的四种分区类型
PHP如何处理yyyyMMddHHmmssSSSZ?
php cli命令 自定义参数传递
HTTP协议详解(真的很经典)
Docker — 从入门到实践
windows安装ssh工具opensssh
Copyright © 2011-2022 走看看