public void CreateExcelxxbb(string FileName) //
    {
        WebRequest mywebrq;

        WebResponse mywebresp;

        StreamReader sr;

        string strexcel = this.sqltoexcelxx();

        string strurl = Request.Url.ToString();
        strurl = strurl.Substring(0, strurl.LastIndexOf("/") + 1);
        strurl = strurl + "fel_yzbb.aspx?str=" + strexcel + "&stid=" + this.drpstname.SelectedValue.Trim() + "&reid=" + this.rbtrole.SelectedValue.Trim();
        //int n = strurl.LastIndexOf("/");
        //strurl = strurl.Substring(0, n - 5);
        mywebrq = WebRequest.Create(strurl);

        mywebresp = mywebrq.GetResponse();

        sr = new StreamReader(mywebresp.GetResponseStream());

        HttpResponse resp;
        resp = Page.Response;
        resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        resp.AppendHeader("Content-Disposition", "attachment;filename=" + FileName);
        string str = sr.ReadToEnd();
        str = str.Substring(str.IndexOf("<div>"));
        str = str.Substring(0, str.LastIndexOf("</div>") + 6);
        //str = str.Substring(str.IndexOf("<!--biaojikaishi-->")+19);
        //str = str.Substring(0, str.IndexOf("<!--biaojijieshu-->"));
        resp.Write(str);
        //写缓冲区中的数据到HTTP头文件中
        resp.End();
    }

posted on 2007-12-19 14:55  洛阳~波  阅读(578)  评论(0编辑  收藏  举报