请问如何把datagrid中的数据打印出来? http://ms.mblogger.cn/wayneliuhttp://expert.csdn.net/expert/faq/faq_index.asp?id=3494相信会对楼主有帮助。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DataGrid显示的数据打印http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=3494 How to Print a DataGrid in C# and .NEThttp://www.c-sharpcorner.com/Graphics/DataGridPrinterMG.asp //将HTTP头添加到输出流 HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=word.doc"); //指定生成文件的类型 Response.ContentType = "application/vnd.ms-text"; HttpContext.Current.Response.Charset = ""; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; this.Datagrid2.Page.EnableViewState = true; System.IO.StringWriter tw= new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw= new System.Web.UI.HtmlTextWriter(tw); this.DataGrid1.Visible = true; //将服务器控件中的内容输出到System.Web.UI.HtmlTextWriter对象中 this.DataGrid1.RenderControl(hw); HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End(); 使用这个开源免费的打印http://community.csdn.net/Expert/topic/3278/3278050.xml?temp=.5012934 XML 特性 求助 CRC32 变态多项式,谁解出来给跪了。 C#写入excel报异常! 事件和响应的方法整合在一起要怎么写? 使用c#判断文件时rtf格式还是txt格式 PLC与计算机串口通信问题? C#怎么引用dll中的函数 一些C#里面概念性的问题 学生求帮助!!!! C# winform 如何发布? 高分求教思路:如何做一个像打印预览时所用的整个界面?? 请问我用水晶报表做得打印程序,到了客户那里不能使用,提示错误
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=3494
http://www.c-sharpcorner.com/Graphics/DataGridPrinterMG.asp
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=word.doc"); //指定生成文件的类型
Response.ContentType = "application/vnd.ms-text";
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
this.Datagrid2.Page.EnableViewState = true; System.IO.StringWriter tw= new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw= new System.Web.UI.HtmlTextWriter(tw);
this.DataGrid1.Visible = true;
//将服务器控件中的内容输出到System.Web.UI.HtmlTextWriter对象中
this.DataGrid1.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
http://community.csdn.net/Expert/topic/3278/3278050.xml?temp=.5012934