gridview 分页导出excel 问题

图片说明

  1. 如上图我导出来他会带一个页码
  2. 我怎样导出可以不带页码
  3. 我的想法是
  4. 在现在这个方法里面 参数里面删掉最后一个tr标签在导出
  5. 但是不知道怎么写
  6. 各位大佬有什么方法 或者知道怎么写嘛
   private void ExportGridViewForUTF8(GridView GridView, string filename)
        {

            //SGridView.AllowPaging = false; //清除分页
            string attachment = "attachment; filename=" + filename;

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", attachment);

            Response.Charset = "UTF-8";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
            Response.ContentType = "application/ms-excel";
            System.IO.StringWriter sw = new System.IO.StringWriter();

            HtmlTextWriter htw = new HtmlTextWriter(sw);
            GridView.RenderControl(htw);

            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
            //SGridView.AllowSorting = true; //恢复分页 
        }

图片说明
这是导出数据 不要下面页码

AllowPaging设置为false不行?

  private void ExportGridViewForUTF8(GridView GridView, string filename)
        {
            GridView.AllowPaging = false; //清除分

不行就只能正则替换了

    Response.Output.Write(Regex.Replace( sw.ToString(),"<tr class=\"PagerRow\">[\\s\\S]+?</tr>","",RegexOptions.IgnoreCase));