大家经常遇到再ie中打印表格时需要隐藏一些不需要打印的对象,比如说按钮,输入框,或者希望莫个表格显示的时候表格线是由颜色的,而打印的时候只需要有粗细之分,其实在css中可以设定在打印或者显示的不同样式,最近作了一个应用(实属逼上梁山),可以得到以上效果,下面是我的样式表。。。。
<style type="text/css" media=print> 主要是media选项对照下面的那一个style一起看
.noprint{visibility:hidden}
span.double {border-bottom-style: double; border-left-style: double;
border-right-style: double; border-top-style: double; color: mediumblue;
cursor: hand; font-size: 12pt; height: 22px; left: 314px; text-align: center;
width: 96px}
select.sb{z-index: 121; left:0px;width: 90px; position: absolute;
height: 170px}
span.tab{left:40px;width: 900px; position: relative; top: 0px; height: 225px}
table{border-right: black medium inset; border-top: black medium inset; border-left: black medium inset; width: 900px; border-bottom: black medium inset; height: 31px;position: absolute}
tr.col0{border-right: thick inset; border-top: thick inset; font-weight: bold; font-size: 15px; border-left: thick inset; border-bottom: 10px ; font-family: 宋体; background-color: blue; text-align: center}
tr.tr1{}
td.td0{width: 120px; text-align: center;height:30px;}
td.td1{width: 330px; text-align: right}
td.td2{width: 70px;text-align: right}
td.td3{width: 330px;text-align: right}
</style>
<style media=screen>主要是media选项对照上面的那一个style一起看
span.double {border-bottom-style: double; border-left-style: double; border-right-style: double; border-top-style: double; color: mediumblue;
cursor: hand; font-size: 12pt; height: 22px; left: 314px; text-align: center;
width: 96px}
select.sb{z-index: 121; left:0px;width: 90px; position: absolute;
height: 170px}
span.tab{left:154px;width: 900px; position: relative; top: 30px; height: 225px}
table{border-right: blue groove; border-top: blue groove; border-left: blue groove; width: 900px; border-bottom: blue groove; position: absolute}
tr.col0{border-right: red thick inset; border-top: red thick inset; font-weight: bold; font-size: 15px; border-left: red thick inset; color: white; border-bottom: yellow 10px solid; font-family: 宋体; background-color: blue; text-align: center}
tr.tr1{border-bottom: fuchsia inset}
td.td0{width: 120px; border-left-style: none; text-align: center;border-bottom-style: none}
td.td1{width: 330px;border-left: blue thin solid; text-align: right}
td.td2{width: 70px;border-top-style: inset; border-right-style: inset; border-left-style: inset; text-align: right; border-bottom-style: inset}
td.td3{width: 330px;border-top-style: inset; border-right-style: inset; border-left-style: inset; text-align: right; border-bottom-style: inset}
td.td5{text-align: right}
</style>
大家仔细看一下其实只要建立2个style而么个style指向不同的设备,但是在style中使用相同的id,这样再在需要打印和显示是需要不同的样式的对象中引用同一个id号(比如说<td class=td3>。。。。。。</td>)但是有一个重要问题时仔细看我在打印是设定不打印是通过设定“visibility:hidden”来实现的,但是我在实际应用中发现如果在脚本代码中使用了“obj.style.visibility=visible”也就是对莫个对象的visibility进行了操作这时候咋打印的时候也会显示出来,也就是说脚本代码的操作对不同的设备同时有效(但是我想应该有办法对某一个设备准向指定的但是找了半天没发现,也可能是css还没有完善)我最后通过了另一个style属性display了实现了,也就是说在脚本代码中用obj.style.diaplay="block"或者"none"来实现对象的显示这样就不影响打印功能的实现了。
但是总的来说ie的打印还是不完善比如说无法实现分页大量的打印数据,但是在visual .net中我发现微软加入了crystal的报表功能我估计应该可以实现了,但是还没有应用过,以后有机会在向大家汇报。
