asp中用c#实现对网页中表格中数据的打印 表格中的内容即对数据库的检索,要实现的打印功能就是把检索数据库得到的内容打印出来就行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你将表格里的数据生成excel,然后在用excel自带的打印功能打印就好了 生成Excel文件如下 public static void GridViewToExcel(GridView gv, string excelName) { HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + excelName + ".xls"); //关闭 ViewState //this.EnableViewState = false; System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw); //获取control的HTML gv.RenderControl(hw); //把HTML写回浏览器 HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End(); tw.Close(); hw.Close(); } public override void VerifyRenderingInServerForm(Control control) { //方法重写 } C# 农历显示 求高人指教,我是C#初学者,想提取txt文件中的内容 如何将自定义控件放到工具箱? 要显示数据库中所有的图像数据,怎么做好? 模板列中放单选按钮 如何做一个登录验证呢? 请问鼠标右键的“复制”项是如何实现的? 请教C#中 [STAThread] 语句的作用。 一个自认为很繁琐的问题。 如何获得服务器的IP地址或则域名 sos 如何用Serializable序列化一个类
生成Excel文件如下
public static void GridViewToExcel(GridView gv, string excelName)
{
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + excelName + ".xls"); //关闭 ViewState
//this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
//获取control的HTML
gv.RenderControl(hw);
//把HTML写回浏览器
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
tw.Close();
hw.Close();
}
public override void VerifyRenderingInServerForm(Control control)
{
//方法重写
}