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

Reading number is top 10 articles
Asp.net,弹出对话框基类,(输出alet警告框)_[Asp.Net教程]
Asp.net数据库操作类,c#_[Asp.Net教程]
ASP.NET,2.0服务器控件之复合控件事件_[Asp.Net教程]
用AJAX编写用户注册实例及技术小结_[AJAX教程]
PHP技巧:用PHP导出MySQL数据库内容为.sql文件_[PHP教程]
delphi发展的历史
网页最简短的拖动对象代码实例演示_JavaScript技术_编程技术
如何在服务端(Page.Write)调用自定义的JS方法_JavaScript技术_编程技术
《SQL,Server,2005技术内幕:T-SQl查询》:常见sql问题归类解答_mssql学习_编程技术
连接PHP和Java
Reading number is top 10 pictures
The money of more than 100 countries and regions7
A letter to parents choose world of warcraft seven big reason
关于海盗的研究
The little girl with long hair3
刘亦菲写真集2
真正的国产-非模拍 贵在是真实2
移民小国也实惠2
西游四格漫画(三)
China telecom 114 spokesman MeiYanXu1
Sora aoi mirror memorial classics1
Download software ranking
Boxer vs Yellow3
The Bermuda triangle3
Boxer vs Yellow1
Sora aoi's film--cangkong_Blue.Sky
Tram sex maniac 2 (H) rar bag18
仙剑奇侠传98版歌曲
Tram sex maniac 2 (H) rar bag8
I for your crazy
美女写真2
Boxer vs Yellow4
delv published in(发表于) 2014/1/24 9:08:23 Edit(编辑)
asp.net页面导出为Word文档_[Asp.Net教程]

asp.net页面导出为Word文档_[Asp.Net教程]

asp.net页面导出为Word文档_[Asp.Net教程]

///


/// 获取指定远程网页内容
///

/// 所要查找的远程网页地址
/// 超时时长设置,一般设置为8000
/// 是否输出换行符,0不输出,1输出文本框换行
/// 编码方式
///
private string GetRequestString( int timeout, int enterType, Encoding EnCodeType)


{
string strResult;
try


{



string url = HttpContext.Current.Request.Url.AbsoluteUri;
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(url);
myReq.Timeout = timeout;
//myReq.Method="POST";
myReq.ContentType = "application/x-www-form-urlencoded";
//Stream myStream = myReq.GetRequestStream();
WebResponse HttpWResp = myReq.GetResponse();
Stream myStream = HttpWResp.GetResponseStream() ;
StreamReader sr = new StreamReader(myStream , EnCodeType);
StringBuilder strBuilder = new StringBuilder();
while (-1 != sr.Peek())


{
strBuilder.Append(sr.ReadLine());
if(enterType==1)
{
strBuilder.Append("\r\n");
}
}
strResult = strBuilder.ToString();
}
catch(Exception ex)


{
strResult = "请求错误:" + ex.Message;
}


return strResult ;
}



//调用此方法导出为word文档,传入参数为this.Page
public void getWordFile(System.Web.UI.Page Page)
{

HttpResponse resp=Page.Response;
resp.Clear();
resp.Buffer= true;
resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
resp.AddHeader("Content-disposition","attachment; filename="+HttpUtility.UrlEncode("1.doc",Encoding.UTF8 ));
string context=GetRequestString(8000,1,Encoding.GetEncoding("GB2312"));//调用GetRequestString方法获取指定远程网页内容
resp.ContentType="application/msword";
resp.Write(context);
resp.End();
}

来源: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.