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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

博客园 - xiazhaoxia

关于《会员专区》项目经验分享 dell的1501和640m,买哪个好呢? 数码相机成像好坏的关键?! 我要试试洋酒! 我爱网购! DataGrid数据导出到Excel You are my everything Remeber me by 李孝利 关于oracle中的去除null和空格的问题 致力于blog的新衣服 datagrid小tip(二):拼接多层表头 datagrid小tip(一):鼠标的移动和点击变色 相对路径or绝对路径? DataGrid的动态绑定问题(二) 续 oracle中的联合主键查询问题! DataGrid的动态绑定问题(二) __doPostBack()无效 ? 屏蔽页面刷新功能 asp.net学习点滴
datagrid小tip(三):导入Excel的问题?!
xiazhaoxia · 2007-02-07 · via 博客园 - xiazhaoxia

string FileName ="文件名" +".xls";        
            Response.Clear(); 
            Response.Buffer
= true
            Response.Charset
="GB2312";    
            Response.AppendHeader(
"Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(FileName,Encoding.UTF8).ToString());
            Response.ContentEncoding
=System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
            Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。 
            this.EnableViewState = false;    
            System.Globalization.CultureInfo myCItrad 
= new System.Globalization.CultureInfo("ZH-CN",true);
            System.IO.StringWriter oStringWriter 
= new System.IO.StringWriter(myCItrad); 
            System.Web.UI.HtmlTextWriter oHtmlTextWriter 
= new System.Web.UI.HtmlTextWriter(oStringWriter);
            
this.DataGrid1.RenderControl(oHtmlTextWriter); 
            Response.Write(oStringWriter.ToString());
            Response.End();            

       问题1:如果Excel 绑定了模板列或进行表头排序(表头变成了linklabel),导出Excel 就会报错.因为时间匆忙,我能想到的方法就是在导出前重新绑定datagrid,但是相对的效率好像就低了.
       问题2:关于这段代码没有问题,但是当弹出下载提示框后,点击保存,浏览器在保存文件后,将弹出该提示的窗口也关闭掉了,为什么?(此种现象在有的机器上会出现,有的就不会)为什么?是有关浏览器的设置不同吗?在网上找了很久,还是没有找到有问相关问题的!

      上面两个问题困扰我很久了,希望知道的大人不吝赐教!