这段代码是把页面所有的内容导入到EXECL,导入是可以成功的,但是导入了以后我当前的页面就死机了,我也不知道为什么,怎么才能解决这个问题?
Button1.Visible=false;
Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=FileFlow.xls");
Response.ContentEncoding=System.Text.Encoding.UTF8;
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",t
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();

解决方案 »

  1.   

    把后面这几句删掉试试:
    System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",t
    System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
    this.RenderControl(oHtmlTextWriter);
    Response.Write(oStringWriter.ToString());
    Response.End();
      

  2.   

    private void btnToExcel_Click(object sender , System.EventArgs e)
            {
                Response.ContentType = "application/vnd.ms-excel";
                Response.Charset = "";
                this.EnableViewState= false;
                System.IO.StringWriter tw = new System.IO.StringWriter();
                System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
                this.RenderControl(hw);
                Response.Write(tw.ToString());
                Response.End();
            }
      

  3.   


    try{} 
    catch{}
    试试
      

  4.   

    http://dotnet.aspx.cc/ShowDetail.aspx?id=8A4CBF47-B888-4832-3389-ED3A3A3C8AAB
      

  5.   

    忘了说一句,我页面上有几个控件
    Response.Write(oStringWriter.ToString());我感觉这里有问题
      

  6.   

    Response.Clear(); 
    Response.Buffer= true;
    Response.Charset="GB2312";
    Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls");
    Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
    //设置输出流为简体中文
    Response.ContentType = "application/ms-excel";
    //设置输出文件类型为excel文件。
    this.EnableViewState = false;
    System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
    System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
    System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
    this.dgData.RenderControl(oHtmlTextWriter);
    Response.Write(oStringWriter.ToString());
    Response.End(); 
      

  7.   

    重刷新一下框架页面
    localtion.href=XXX
      

  8.   

    重刷新一下框架页面
    localtion.href=XXX这段单吗那里写?
      

  9.   

    http://www.yesky.com/20030214/1652186.shtml
    http://community.csdn.net/Expert/topic/4038/4038223.xml?temp=.9106714
    http://www.cnblogs.com/hbzxf/archive/2004/07/12/23456.html
      

  10.   

    在你关闭子窗口的时候
    <script>parent.location.href='main.aspx';window.close();</script>
    试一下