日期:2014-05-16  浏览次数:20623 次

比较通用的,就是用IE的WebBrowser

看到了这篇:

http://www.dev-club.com/club/bbs/ShowAnnounce.asp?ID=2312527

后,查了下MSDN,查到了WebBrowser的东东 
再结合偶的 
http://www.dev-club.com/club/bbs/showEssence.asp?id=24093&page=2

就整出了这样的效果:

<html> 
<head> 
<title>Untitled Document</title> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<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; 

</style> 
</head> 
<center> 
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0> 
</OBJECT> 
<div id="printsub"> 
<input type=button value="打印" onclick="document.all.WebBrowser.ExecWB(6,1)"> 
<input type=button value="页面设置" onclick="document.all.WebBrowser.ExecWB(8,1)"> 
<input type=button value="预览" onclick="document.all.WebBrowser.ExecWB(7,1)"> 
</div> 
</center> 
<body onbeforeprint="printsub.style.display='none';" onafterprint="printsub.style.display='';"> 
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp"> 
<tr align="center"> 
<td height="25" colspan="3" class="tdp"><strong>计算机世界开发者俱乐部</strong></td> 
</tr> 
<tr> 
<td width="31%" height="26" align="center" class="tdp">PHP版</td> 
<td width="34%" align="center" class="tdp">DELPHI版</td> 
<td width="35%" align="center" class="tdp">JAVA版</td> 
</tr> 
<tr> 
<td height="40" colspan="3" class="tdp"><p>一段很小但很实用的CSS打印样式。一般带背景的表格在打印的时候,页面上看到的格线实际却打印不出来。其实不是打印不出来,是需要在打印的时候选择&quot;打印背景&quot;。1般不可能要求用户必须做这步。但用样式表&quot;画&quot;出来的格线在打印的时候就能得到&quot;所见即所打&quot;的效果。这效果当然不能和专业的打印控件如&quot;水晶报表&quot;想比,但满足普通的需求还是能够胜任的。</p></td> 
</tr> 
<tr> 
<td height="59" colspan="3" class="tdp">但在打印的时候,&quot;打印&quot;按纽不能被打印出来,所以就在&lt;body&gt;里用两个事件来控制它,这步很重要。</td> 
</tr> 
<tr> 
<td height="59" colspan="3" class="tdp">在使用这两个样式时,1个是让&lt;table&gt;的class=&quot;tabp&quot;,然后再它下面的每个&lt;td&gt;的class=&quot;tdp&quot;,&lt;tr&gt;不需要指定。记住,每个&lt;td&gt;都要指定一下。。。。</td> 
</tr> 
<tr> 
<td height="59" colspan="3" class="tdp"&