zoukankan
html css js c++ java
datagrid gridview 倒出数据为 excel 时,编号问题
把gridview 中的数据倒出 为 excel时 (编号长时在 excel 中会变成科学计数)
//
倒出按钮
protected
void
Btn_ExportClick(
object
sender, EventArgs e)
{
string
style
=
@"
<style> .text { mso-number-format:\@; } </script>
"
;
//
主要是这
Response.ClearContent();
Response.AddHeader(
"
content-disposition
"
,
"
attachment; filename=MyExcelFile.xls
"
);
Response.ContentType
=
"
application/excel
"
;
StringWriter sw
=
new
StringWriter();
HtmlTextWriter htw
=
new
HtmlTextWriter(sw);
gvUsers.RenderControl(htw);
//
Style is added dynamically
Response.Write(style);
Response.Write(sw.ToString());
Response.End();
}
//
行绑定事件
protected
void
gvUsers_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
e.Row.Cells[
4
].Attributes.Add(
"
class
"
,
"
text
"
);
//
主要是这
}
}
具体可以看这
http://gridviewguy.com/ArticleDetails.aspx?articleID=197
查看全文
相关阅读:
php判断token有效期
ecshop数据库操作
CSS3选择器 :nth-child(n) 如何理解
socket_wirte、socket_read、socket_send、socket_recv
Mysql按指定顺序排序的两种写法
Photoshop图片优化文件大小
Wordpress中的自定义栏目是什么玩意,有什么用?
Windows使用压缩包安装Mysql5.7.17服务
Discuz论坛搬家后出现 Unknown column 'app1' in 'where clause' 原因及解决办法
.PHP后缀大写导致Linux下Composer找不到类
原文地址:https://www.cnblogs.com/gwazy/p/484373.html
最新文章
hbase 待看代码
异步IO与回调
sqlmap注入之tamper绕过WAF防火墙过滤
SQL手工注入基础详解---- MySQL篇
绕过注入限制继续注入的一些方法
突破sql 注入过滤Union+SELECT 继续射下去
sqlmap
[转]高级SQL注入:混淆和绕过
SqlMap post cookie注入小结
OWASP TOP10
热门文章
LCX端口转发实现内网突破
Metasploit爆破tcpwrapped服务
php curl header头中添加请求信息
ecshop 左侧菜单栏添加
php 数组实现分页
Redis消息队列实现秒杀
php 编码问题解决
PHP file_get_contents函数报错问题
php常见的web攻击
mysql基础原生sql教程
Copyright © 2011-2022 走看看