#region 網(wǎng)頁內(nèi)容保存或?qū)С鰹閣ord或excel
/**//// <summary>
/// 網(wǎng)頁內(nèi)容保存或?qū)С鰹閣ord或excel
/// </summary>
/// <param name="url">網(wǎng)頁地址</param>
/// <param name="num">0為導(dǎo)出word,1為導(dǎo)出excel</param>
public static void SaveOrOutData( string url, int num )//導(dǎo)出數(shù)據(jù)的函數(shù)0為word,1為Excel
{
WebRequest req = WebRequest.Create( url );
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader( resp.GetResponseStream(), System.Text.Encoding.UTF8 );
string x = sr.ReadToEnd();
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding( "gb2312" );
string fName = DateTime.Now.ToString( "yyyy-MM-dd-ss" );
if( num == 0 )
{
fName = HttpUtility.UrlEncode( fName, System.Text.Encoding.GetEncoding( "gb2312" ) ) + ".doc";
System.Web.HttpContext.Current.Response.ContentType = "application/ms-word";
}
else
{
fName = HttpUtility.UrlEncode( fName, System.Text.Encoding.GetEncoding( "gb2312" ) ) + ".xls";
System.Web.HttpContext.Current.Response.ContentType = "application nd.xls";
}
System.Web.HttpContext.Current.Response.AddHeader( "content-disposition", "attachment;filename=" + fName );
System.Web.HttpContext.Current.Response.Write( getBodyContent( x ) );//獲取table標(biāo)簽
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}