GridView Excel 내보내기 디코드 문제 해결

2223 단어 GridView
  Response.Clear();

        Response.Charset = "gb2312";

        Response.Buffer = true;

        Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(" .xls").ToString());

        Response.ContentType = "application/ms-excel";

        Response.Write("<html><head><meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">");

        System.IO.StringWriter sw = new System.IO.StringWriter();

        HtmlTextWriter hw = new HtmlTextWriter(sw);

        GridView1.AllowPaging = false;

        Bind();

        this.GridView1.RenderControl(hw);

        Response.Write(sw.ToString());

        Response.Write("</body></html>");

        Response.Flush();

        Response.End();

좋은 웹페이지 즐겨찾기