天天看点

比较通用的,就是用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> 

<td height="40" colspan="3" class="tdp"><p>一段很小但很实用的CSS打印样式。一般带背景的表格在打印的时候,页面上看到的格线实际却打印不出来。其实不是打印不出来,是需要在打印的时候选择"打印背景"。1般不可能要求用户必须做这步。但用样式表"画"出来的格线在打印的时候就能得到"所见即所打"的效果。这效果当然不能和专业的打印控件如"水晶报表"想比,但满足普通的需求还是能够胜任的。</p></td> 

<td height="59" colspan="3" class="tdp">但在打印的时候,"打印"按纽不能被打印出来,所以就在<body>里用两个事件来控制它,这步很重要。</td> 

<td height="59" colspan="3" class="tdp">在使用这两个样式时,1个是让<table>的class="tabp",然后再它下面的每个<td>的class="tdp",<tr>不需要指定。记住,每个<td>都要指定一下。。。。</td> 

<td height="59" colspan="3" class="tdp">打印效果如图:(打印出的东东不包括菜单,只有下面的内容):</td> 

</table> 

</body> 

</html>

感谢lran啊~~

msnd中查看WebBrowser的资料: 

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/vclib/html/vcrefCHtmlViewExecWB.htm

btw:该怎样分页呢?CSS好象可以,偶再查查CSS手册看看。。。

2.不通用的,就是用打印控件喽。比如偶单位就有专门WEB打印的东东。