All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET,Web应用程序的简单AJAX实现_[Asp.Net教程]
C#教程:使用Visual Studio 2005 创建项目
LINQ,的演变及其对,C#,设计的影响_.net资料_编程技术
.net组件开发系列(二)之武术系列-太极拳,开发ajax控件_[Asp.Net教程]
XP下Asp.net访问被拒绝_[Asp.Net教程]
精通数据库系列之入门-技巧篇3_mssql学习_编程技术
Sql,server,2005的XML最佳实施策略(4)_[SQL,Server教程]
C#中国身份证验证(包括省份验证和校验码验证,符合GB11643-1999标准)_[Asp.Net教程]
初学网页制应知道HTML和XHTML的特点_[Html教程]
PHP脚本的8个技巧(3)包含文件_[PHP教程]
Reading number is top 10 pictures
Flow chart of breast implants
Parking technology is great, that give you the keys can't stolen
Beauty Sun Feifei
Absolutely shocked. National geographic 50 animal photographys1
China's first snake village2
So beauty, will let you spray blood2
美女当网吧管理员的悲剧
农夫山泉变身记
Embarrassing things comic collection1
The hot big eye big breast beauty2
Download software ranking
The king of fighters 97(Mobile phone games-apk)
Proficient in JavaScript
Eclipse 4.2.2 For Win32
Sora aoi - one of more PK
Ashlynn Video3
XML+Web+Service开发教程
Prostitutes diary
linux安装大全
美女游泳记
WebService在.NET中的实战应用教学视频 → 第3集
delv published in(发表于) 2014/1/6 9:11:49 Edit(编辑)
在系统中生成Excel流并传给用户_[Asp.Net教程]

在系统中生成Excel流并传给用户_[Asp.Net教程]

在系统中生成Excel流并传给用户_[Asp.Net教程]

在系统中经常出现这样的情况就是生成excel流 并将生成的Excel 流传给用户

  一般的来讲可以利用 Response 来向客户端发送一个HTTP头 ,并将Excel流发送出去就可以了,但会出现一个问题就是点击打开的时候会出现两次 文件下载 对话框,主要的原因:(现在的猜测,还没有找到准确的原因)。


  第一次打开 时 ,在系统中已经存在了excel流的临时文件(就是文件,没有文件的后缀名的存在) ,但没有原来的(真实文件的存在),要求用户是否将临时文件保存到计算机其他的位置上。(是否跟没有后缀名有关)


  第二次 ,选择客户端文件的位置,是否保存到其他的非临时文件夹位置。


  现在的解决方案是


  新建一个页面专门提供导出数据的


  在这个页面中的Page_load中写这样的代码


private void Page_Load(object sender, System.EventArgs e)


{


// 在此处放置用户代码以初始化页面
ReportRule reportRule=new ReportRule();
byte[] result= reportRule.RenderReport(HttpContext.Current.Server.UrlDecode(this.Request.QueryString["peportpath"]),Request.QueryString["id"]); //生成excel流


HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";


HttpContext.Current.Response.AppendHeader("Content-disposition","attachment;filename=hahh.xls");


HttpContext.Current.Response.BinaryWrite(result);


HttpContext.Current.Response.End();


}







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.