当前位置: 代码迷 >> ASP.NET >> gridview打印解决办法
  详细解决方案

gridview打印解决办法

热度:2897   发布时间:2013-02-25 00:00:00.0
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字符串
  相关解决方案