惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Webroot Blog
Webroot Blog
U
Unit 42
A
About on SuperTechFans
宝玉的分享
宝玉的分享
月光博客
月光博客
C
CERT Recently Published Vulnerability Notes
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
P
Privacy & Cybersecurity Law Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Securelist
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Spread Privacy
Spread Privacy
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
K
Kaspersky official blog
Hugging Face - Blog
Hugging Face - Blog
B
Blog
I
Intezer
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
V
V2EX
L
LangChain Blog
AI
AI
G
GRAHAM CLULEY
T
Tor Project blog
人人都是产品经理
人人都是产品经理
D
Docker
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
I
InfoQ
Y
Y Combinator Blog
C
Comments on: Blog
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
N
News and Events Feed by Topic
MyScale Blog
MyScale Blog
H
Help Net Security
Vercel News
Vercel News
T
Tenable Blog
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿

博客园 - angelfeather

json中获取key值 iOS开发常用代码块(2) 区别不同浏览器,CSS hack写法 [推荐]13款js编辑器大全 web标准 CSS Sprites 用户控件(.ascx)与网页间(.aspx)如何传值的几种方法 彩色验证码 一段常用的Page_Load事件 (如果有更好的希望大家留言) - angelfeather - 博客园 c#.net常用函数和方法集 ASP.NET中$#=的用法 - angelfeather - 博客园 利用MD5加密数据库中的密码 - angelfeather - 博客园 小记一篇~ - angelfeather - 博客园 推荐一个.net代码查看器Reflector 推荐一个学习asp.net的好地方 简单的ArrayList遍历 Microsoft .Net 框架 SDK 快速入门教程 - angelfeather asp.net简单的md5算法 遍历页面的所有button控件 GridView统计数据和修改Cell GridView导出Excel
GridView格式化导出Excel
angelfeather · 2008-06-18 · via 博客园 - angelfeather

有时候需要按规则导出到Excel中,用模板的方法外,我提供一个简易的:

1 核心代码如下:

  Response.Write("<table><tr><td>单位负责人</td><td> </td><td>统计负责人:</td></tr></table>");

2 测试效果图

并且可以和表头设置相结合:

 protected void GridViewXinXiLan_RowCreated(object sender, GridViewRowEventArgs e)
    
{
          
switch (e.Row.RowType)
        
{
            
case DataControlRowType.Header:
                
//第一行表头
                TableCellCollection tcHeader = e.Row.Cells;
                tcHeader.Clear();
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
0].Attributes.Add("rowspan""3"); //跨Row
                tcHeader[0].Attributes.Add("bgcolor""white");
                tcHeader[
0].Text = "";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
1].Attributes.Add("bgcolor""Red");
                tcHeader[
1].Attributes.Add("colspan""6"); //跨Column
                tcHeader[1].Text = "全部信息</th></tr><tr>";

                
//第二行表头
                tcHeader.Add(new TableHeaderCell());
                tcHeader[
2].Attributes.Add("bgcolor""DarkSeaGreen");
                tcHeader[
2].Text = "身份证号码";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
3].Attributes.Add("bgcolor""LightSteelBlue");
                tcHeader[
3].Attributes.Add("colspan""2");
                tcHeader[
3].Text = "基本信息";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
4].Attributes.Add("bgcolor""DarkSeaGreen");
                tcHeader[
4].Text = "福利";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
5].Attributes.Add("bgcolor""LightSteelBlue");
                tcHeader[
5].Attributes.Add("colspan""2");
                tcHeader[
5].Text = "联系方式</th></tr><tr>";

                
//第三行表头
                tcHeader.Add(new TableHeaderCell());
                tcHeader[
6].Attributes.Add("bgcolor""Khaki");
                tcHeader[
6].Text = "身份证号码";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
7].Attributes.Add("bgcolor""Khaki");
                tcHeader[
7].Text = "姓名";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
8].Attributes.Add("bgcolor""Khaki");
                tcHeader[
8].Text = "出生日期";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
9].Attributes.Add("bgcolor""Khaki");
                tcHeader[
9].Text = "薪水";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
10].Attributes.Add("bgcolor""Khaki");
                tcHeader[
10].Text = "家庭住址";
                tcHeader.Add(
new TableHeaderCell());
                tcHeader[
11].Attributes.Add("bgcolor""Khaki");
                tcHeader[
11].Text = "邮政编码";
                
break;
        }

    }

效果图: