protected void Button3_Click(object sender, EventArgs e)
    {
        ExportDataGrid("application/ms-excel", "城市品牌报表.xls");
    }

    private void ExportDataGrid(string FileType, string FileName)        //从DataGrid导出
    {
        Response.Charset = "GB2312";
       
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
        Response.ContentType = FileType;
        this.EnableViewState = false;
        StringWriter tw = new StringWriter();
       
        HtmlTextWriter hw = new HtmlTextWriter(tw);
      
          
        this.GV_city.RenderControl(hw);
      
        Response.Write(tw.ToString());
        Response.End();
    }
    public override void VerifyRenderingInServerForm(Control control)//重载该方法 确保正常保存
    {
        //base.VerifyRenderingInServerForm(control);

相关文章:

  • 2021-07-29
  • 2021-12-19
  • 2022-12-23
  • 2021-12-05
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-05
  • 2021-07-16
  • 2021-11-27
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案