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

Reading number is top 10 articles
概率计算,PHP幸运星_php资料_编程技术
让GridView有新增记录的功能_[Asp.Net教程]
C++类的定义与实现
Delphi使用ADO连接SQL Server 2000数据库
如何清除SQL日志_[SQL Server教程]
PHP 5.0中多态性的实现方案浅析_[PHP教程]
.NET内置对象之Application对象_[Asp.Net教程]
C#网络应用编程基础练习题与答案(六)_.net资料_编程技术
应用技巧:用.net动态创建类的实例_.net资料_编程技术
ASP.NET2.0数据库入门之SQL,Server_[Asp.Net教程]
Reading number is top 10 pictures
Startling Russian girl blind date scene1
含苞欲放的素颜美少女1
人美胸美腿更美3
The other a successor of sora aoi
美女就是美女
关于海盗的研究
2012 national geographic daily picture1
最2B的公司制度
A man's favorite things2
Angie Chiu vijara myth1
Download software ranking
1400篇各类破解文章
matrix1
Boxer's Top ten classic battle6
传奇私服架设教程
好色的外科大夫
Boxer's Top ten classic battle10
虚拟机5.5.3版
都市狐狸姑娘传
天龙八部最新服务端
Tram sex maniac 2 (H) rar bag11
delv published in(发表于) 2014/1/24 9:08:26 Edit(编辑)
Asp.Net页面输出到EXCEL_[Asp.Net教程]

Asp.Net页面输出到EXCEL_[Asp.Net教程]

Asp.Net页面输出到EXCEL_[Asp.Net教程]

利用ASP.NET输出指定内容的WORD、EXCEL、TXT、HTM等类型的文档很容易的。主要分为三步来完成。

一、定义文档类型、字符编码  



   Response.Clear();
   Response.Buffer= true;
   Response.Charset="utf-8"; 



   //下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
   //filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm  



   Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
   Response.ContentEncoding=System.Text.Encoding.GetEncoding("utf-8");  
   //Response.ContentType指定文件类型 可以为application/ms-excel    application/ms-word    application/ms-txt    application/ms-html    或其他浏览器可直接支持文档
   Response.ContentType = "application/ms-excel";
   this.EnableViewState = false;  



  二、定义一个输入流  
   System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
   System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);  



  三、将目标数据绑定到输入流输出  
   this.RenderControl(oHtmlTextWriter);   
   //this 表示输出本页,你也可以绑定datagrid,或其他支持obj.RenderControl()属性的控件
   Response.Write(oStringWriter.ToString());
   Response.End();  



  总结:本例程在Microsoft Visual Studio .NET 2003平台下测试通过,适用于C#和VB,当采用VB的时候将 this 关键字改成 me 。

来源:CSDN







添加到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.