读书人

gridview打印解决办法

发布时间: 2011-12-29 22:09:38 作者: rapoo

gridview打印
gridview打印出力面的数据包括分页当中未被显示出来的数据呢?

[解决办法]
重新取数据,将取出的数据配置成HTML字符串,然后导出
public static void GenerateByHtmlString(string Typename, string TempHtml)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "utf-8 ";
string Filename = Typename + ".xls ";
HttpContext.Current.Response.AppendHeader( "Content-Disposition ", "online;filename= " + Filename);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding( "utf-8 ");
HttpContext.Current.Response.ContentType = "application/ms-excel ";
//this.EnableViewState = false;
HttpContext.Current.Response.Write(TempHtml);
HttpContext.Current.Response.End();
}

Typename为导出的文件名,TempHtml为HTML字符串

读书人网 >asp.net

热点推荐