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

Reading number is top 10 articles
用PHP程序实现从数组里筛选出重复的数据_[PHP教程]
为DataGrid添加单选框_[Asp.Net教程]
delphi单选分组框组件(TRadioGroup)使用实例
关于ASP.NET,2.0的目录结构变化_[Asp.Net教程]
delphi MapViewOfFile函数将映像文件映射到进程
进阶:精妙SQL语句介绍_[SQL,Server教程]
SQL,Server,2005升级的十个步骤详解_[SQL,Server教程]
支付宝Payto接口的C#.net实现方法_.net资料_编程技术
PHP基础:PHP的语法_[PHP教程]
C#中索引器的概念和应用实例
Reading number is top 10 pictures
9.3阅兵全景图2-英雄连队梯队和外国方阵梯队
The real super beauty2
A man's favorite things2
So beauty, will let you spray blood4
水晶头骨造型的酒瓶
做运动的校花1
好身材能把衣服穿出3D效果
The household of rural style is designed
原子弹轰炸长崎的珍贵照片
The money of more than 100 countries and regions15
Download software ranking
双旗镇刀客B
Love the forty days
WebService在.NET中的实战应用教学视频 → 第2集
Unix video tutorial6
Boxer vs Yellow4
Sora aoi, the nurse, uniform ,nursing assistant
Unix video tutorial2
实战黑客不求人
The cock of the Grosvenor LTD handsome
Unix video tutorial12
delv published in(发表于) 2014/1/8 7:04:09 Edit(编辑)
将ASP.NET页面内的数据导出到Excel,或,Word中_[Asp.Net教程]

将ASP.NET页面内的数据导出到Excel,或,Word中_[Asp.Net教程]

将ASP.NET页面内的数据导出到Excel 或 Word中_[Asp.Net教程]

在以下按钮单击事件中实现:
private void btnMIME_Click(object sender, System.EventArgs e)
{
BindData();
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "inline;filename="
+ HttpUtility.UrlEncode("下载文件.xls",Encoding.UTF8 ) );


//如果输出为Word,修改为以下代码
//Response.ContentType = "application/ms-word"
//Response.AddHeader("Content-Disposition", "inline;filename=test.doc")
StringBuilder sb=new StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(sb);
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
sb.Append("");
dgShow.RenderControl(hw);
sb.Append("");
Response.Write(sb.ToString());
Response.End();
}
注:1.若DataGrid中有按钮列,则在导出前应先将其隐藏.
2.若DataGrid有分页,而又要打印所有数据的话就应先取消分页.


来源:网络







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