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));