Response.Clear();
        Response.Charset = "GB2312";
        Response.AppendHeader("Content-Disposition", "attachment;filename=FileName.xls");
        Response.ContentType = "application/ms-excel";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        Response.Write("<meta http-equiv=Content-Type content=\"text/html;charset=GB2312\">");        GridView1.EnableViewState = false;        System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN", true);
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);        pds.AllowPaging = false;
        bind();        GridView1.RenderControl(htw);
        Response.Write(style);
        Response.Write(sw.ToString());
        Response.Flush();
        Response.End();        pds.AllowPaging = true;
        bind();
代码如上,请说说原理

解决方案 »

  1.   

    原理,不太清楚,
    gridview其实也是一个table,将GRIDVIEW其实等同于遍历TABLR,将其内容输出
      

  2.   

     你的pds  应该也是一Gridview. 所以不知道GridView1,和Pds  是什么。、
      

  3.   

    pds.AllowPaging = false;
            bind();        GridView1.RenderControl(htw);
            Response.Write(style);
            Response.Write(sw.ToString());
            Response.Flush();
            Response.End();        pds.AllowPaging = true;
            bind();
    你要关注的是这些