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

推荐订阅源

Cloudbric
Cloudbric
Schneier on Security
Schneier on Security
V2EX - 技术
V2EX - 技术
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
O
OpenAI News
S
Security @ Cisco Blogs
Scott Helme
Scott Helme
Security Archives - TechRepublic
Security Archives - TechRepublic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
T
Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
Microsoft Azure Blog
Microsoft Azure Blog
Know Your Adversary
Know Your Adversary
博客园 - 三生石上(FineUI控件)
A
About on SuperTechFans
Forbes - Security
Forbes - Security
NISL@THU
NISL@THU
Security Latest
Security Latest
G
Google Developers Blog
D
Docker
T
Threat Research - Cisco Blogs
N
Netflix TechBlog - Medium
C
CERT Recently Published Vulnerability Notes
H
Help Net Security
B
Blog
Martin Fowler
Martin Fowler
N
News and Events Feed by Topic
Simon Willison's Weblog
Simon Willison's Weblog
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
Lohrmann on Cybersecurity
Y
Y Combinator Blog
PCI Perspectives
PCI Perspectives
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
Project Zero
Project Zero
爱范儿
爱范儿
Cisco Talos Blog
Cisco Talos Blog
博客园 - 聂微东
Hugging Face - Blog
Hugging Face - Blog
人人都是产品经理
人人都是产品经理
V
Vulnerabilities – Threatpost
P
Proofpoint News Feed
Cyberwarzone
Cyberwarzone
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
TaoSecurity Blog
TaoSecurity Blog
N
News | PayPal Newsroom
Recorded Future
Recorded Future

博客园 - huazi4995

prototype.js开发笔记 JS应用 java环境配置 关于梅花雪的js树 - huazi4995 - 博客园 MagicAjax的使用 - huazi4995 - 博客园 div+css制作的选项卡 - huazi4995 - 博客园 关于word文档的数据库存取 SQL查询语句精华使用简要 - huazi4995 - 博客园 身份证号码验证-支持新的带x身份证 c#常用函数和方法集汇总 动态创建层 C#操作Word文档(Office 2007) datagrid控件使用技巧大集合 网站设计常用技巧 jsp编程技巧 ArrayList的使用方法(转载) js中的小技巧 ajax+xml数据岛,增加编辑与删除按钮 利用webservice实现省、市的无刷新
将datagrid里的资料导入到excel
huazi4995 · 2006-12-08 · via 博客园 - huazi4995

private void DG_TO_Excel()
{
            Response.clear();
            Response.Buffer
=true;
            Response.Charset
="GB2312";
            Response.AppendHeader(
"content-Disposition","attachment;filename=FileName.xls");
            Response.contentEncoding
=System.Text.Encoding.GetEncoding("GB2312");
            Response.ContentType
="application/vnd.ms-excel";
//Response.ContentType="application/vnd.ms-word"; //导到word
            
Response.Charset="";
            
this.EnableViewState=false;
            System.Io.StringWriter str
=new System.Io.StringWriter();
            System.Web.UI.HtmlTextWriter htw
=new System.Web.UI.HtmlTextWriter(str);
//this.ClearControls(DataGrid1);
            
DataGrid1.RenderControl(htw);
            Response.write(str.ToString());
            Response.End();
}

Private wid clearcontrols(control control)
{
for(int i=control.controls.Count-1; i>=0;i--)
{
clearControls(control.controls[i])
{
if(!(control is Tablecell))
{
if(control.GetType().Getproperty("SelectedItem")!=null)
Literalcontrol literal
=new LiteralControl);
control.Parent.Controls.Add(literal);
try
{
literal.Text
=(string)control.GetType().Getproperty("SelectedItem").GetValue(control.null);
}

catch
{
throw;
}

control.Parert.Controls.Remove(control);
}

else if(control.GetType().Getproperty("Text")!=null)
{
LiteralControl literal
=new LiteralControl();
control.Parent.controls.Add(literal);
literal.Text
=(string)control.GetTypel().Getproperty("Text").GetValue(control,null)
control.parent.Controls.Remove(control);
}

}

return;
}