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
查看全文
相关阅读:
网络爬虫技术总结
MongoDB(7):集群部署实践,包含复制集,分片
MongoDB(6):简单配置,环境变量,关闭服务
Mongod(5):启动命令mongod参数说明
MongoDB(4):多种方式关闭服务命令
Linux下的Source命令及脚本的执行方式解析
linux第一天
echarts 各种细节问题
MongoDB(3):小的细节问题
获取用户Ip地址通用方法常见安全隐患(HTTP_X_FORWARDED_FOR)
原文地址:https://www.cnblogs.com/gwazy/p/484373.html
最新文章
Chrome之谷歌插件开发
微信之语音存储
redis之使用场景
企业微信之扫码登陆
工具站汇总
PHP之常用第三方库
git常用命令之log
进程管理工具之supervisor[安装并使用]
python之requests
(转)Python3 zip() 函数
热门文章
Python【map、reduce、filter】内置函数使用说明(转载)
(转)字符编码笔记:ASCII,Unicode 和 UTF-8
Python基础
(转)Centos7 yum 源安装nginx
(转)Kubernetes部署WordPress+MySQL
(转)Kubernetes 配置Pod和容器(十七) 使用Secrets管理安全证书
(转)原理到实现 | K8S 存储之 NFS
(转)详解k8s组件Ingress边缘路由器并落地到微服务
(转)CoreDNS介绍
decode行转列,case when,
Copyright © 2011-2022 走看看