国产精品人成在线播放新网站,欧洲吸奶大片在线看,亚洲欧洲成人a∨在线,国产18禁黄网站免费观看

微信號(hào):
當(dāng)前位置:首頁 > 資訊文摘 > 新聞資訊

網(wǎng)頁內(nèi)容保存或?qū)С鰹閣ord或excel

2015/10/28 10:30:51

        #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();
        }

相關(guān)新聞: