如何打印Gridview??

msony 2009-06-03 11:26:23
我用vs2005做了一个asp.net的web查询使用gridview显示数据,如何将Gridview中的查询内容点击打印后进预览打印,由于是新手请高手说详细,能附例子说明由为感激
...全文
1610 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
mengjixinglove 2009-06-05
  • 打赏
  • 举报
回复
我也在找这个
linlusheng 2009-06-04
  • 打赏
  • 举报
回复
<input type=button value=打印 onclick= "document.all.WebBrowser.ExecWB(6,1) " class= "NOPRINT ">
<input type=button value=直接打印 onclick= "document.all.WebBrowser.ExecWB(6,6) " class= "NOPRINT ">
<input type=button value=页面设置 onclick= "document.all.WebBrowser.ExecWB(8,1) " class= "NOPRINT ">
<input type=button value=打印预览 onclick= "document.all.WebBrowser.ExecWB(7,1) " class= "NOPRINT ">
看这个链接,楼主http://blog.csdn.net/wdwgr/archive/2009/03/30/4036551.aspx
chenwei175528 2009-06-04
  • 打赏
  • 举报
回复
mark and up and study
yan286093636 2009-06-04
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 lvjin110 的回复:]
HTML code
//非常經典的WEB列印方案
<html>
<head>
<title>好?</title>
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--media=print 這個屬性可以在列印時有效-->
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>

<style>
.tdp
{
borde…
[/Quote]



好像还行。。。。。。。。。
antiking 2009-06-04
  • 打赏
  • 举报
回复
建议用打印控件或导出到Excel表然后打印,看自己需求了。
bzhyan 2009-06-04
  • 打赏
  • 举报
回复
up
shelleyzhang 2009-06-04
  • 打赏
  • 举报
回复
打印GridView可以用javascript的window.print,也可以获取GridView的html代码,打印。

GridView如果进行了分页,在打印之前要先去掉分页。这样打印的数据才能完整,打印完毕后,再分页。不会对程序造成影响。
femg93 2009-06-04
  • 打赏
  • 举报
回复
up
吕津 2009-06-04
  • 打赏
  • 举报
回复

//非常經典的WEB列印方案
<html>
<head>
<title>好?</title>
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--media=print 這個屬性可以在列印時有效-->
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>

<style>
.tdp
{
border-bottom: 1 solid #000000;
border-left: 1 solid #000000;
border-right: 0 solid #ffffff;
border-top: 0 solid #ffffff;
}
.tabp
{
border-color: #000000 #000000 #000000 #000000;
border-style: solid;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 1px;
border-left-width: 1px;
}
.NOPRINT
{
font-family: "宋體";
font-size: 9pt;
}

</style>

</head>

<body>
<center class="Noprint">
<p>
<object id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT></object>
<input type=button value=列印 onclick=document.all.WebBrowser.ExecWB(6,1) id="Button1" name="Button1">
<input type=button value=直接列印 onclick=document.all.WebBrowser.ExecWB(6,6) id="Button2" name="Button2">
<input type=button value=頁面設置 onclick=document.all.WebBrowser.ExecWB(8,1) id="Button3" name="Button3">
</p>
<p>
<input type=button value=列印預覽 onclick=document.all.WebBrowser.ExecWB(7,1) id="Button4" name="Button4"><br/>
</p>
<hr align="center" width="90%" size="1" noshade>
</center>

<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp" id="Table1">
<tr>
<td colspan="3" class="tdp">第1頁</td>
</tr>
<tr>
<td width="29%" class="tdp"> </td>
<td width="28%" class="tdp"> </td>
<td width="43%" class="tdp"> </td>
</tr>
<tr>
<td colspan="3" class="tdp"> </td>
</tr>
<tr>
<td colspan="3" class="tdp">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="Table2">
<tr>
<td width="50%" class="tdp"><p>這樣的報表</p><p>對一般的要求就夠了。</p></td>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>

<hr align="center" width="90%" size="1" noshade class="NOPRINT" >

<div class="PageNext"></div><!--分頁-->

<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp" id="Table3">
<tr>
<td class="tdp">第2頁</td>
</tr>
<tr>
<td class="tdp">看到分頁了吧</td>
</tr>
<tr>
<td class="tdp"> </td>
</tr>
<tr>
<td class="tdp"> </td>
</tr>
<tr>
<td class="tdp">
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="Table4">
<tr>
<td width="50%" class="tdp"><p>這樣的報表</p><p>對一般的要求就夠了。</p></td>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>


bieqing 2009-06-04
  • 打赏
  • 举报
回复
window.print() 直接整页打印
需要打印网页中定义的部分内容加上<!--startprint-->与<!--endprint-->标识
mengxj85 2009-06-04
  • 打赏
  • 举报
回复
直接调用IE中的打印
或者通过JS调用IE中的打印
ifcrp 2009-06-03
  • 打赏
  • 举报
回复
·双线主机 100M/35元/年,免费送数据库(自选MY/MSSQL)
·详情请访问:http://www.cqfad.com

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧