下面代码是导出到excel函数的?

this.dg.Columns[3].Visible = false;
HttpContext.Current.Response.Charset = "GB2312";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

    HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("out.xls", System.Text.Encoding.UTF8));
    HttpContext.Current.Response.ContentType = "application/ms-excel";
    this.EnableViewState = false;
    System.IO.StringWriter tw;
    tw = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter hw;
    hw = new HtmlTextWriter(tw);
    this.dg.RenderControl(hw);
    HttpContext.Current.Response.Write(tw.ToString());
    HttpContext.Current.Response.End();
    this.dg.Columns[3].Visible = true;

据我所知,应该是的,但是还是不太了解哈