实现网页打印实例

代码如下:

View Code
  1 <%@ page language="java" contentType="text/html; charset=GBK" pageEncoding="GBK"%>
  2 <%@include file="/docc/common.jsp"%>
  3 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  4 <HTML><HEAD>
  5 <META content="text/html; charset=gb2312" http-equiv=Content-Type>
  6 <META http-equiv=Pragma content=no-cache>
  7 <META http-equiv=Cache-Control content=no-cache>
  8 <META http-equiv=Expires content=0>
  9 <STYLE type=text/css> 
 10 tr
 11     {mso-height-source:auto;
 12     mso-ruby-visibility:none;}
 13 col
 14     {mso-width-source:auto;
 15     mso-ruby-visibility:none;}
 16 br
 17     {mso-data-placement:same-cell;}
 18 ruby
 19     {ruby-align:left;}
 20 .style0
 21     {mso-number-format:General;
 22     text-align:general;
 23     vertical-align:middle;
 24     white-space:nowrap;
 25     mso-rotate:0;
 26     mso-background-source:auto;
 27     mso-pattern:auto;
 28     color:black;
 29     font-size:11.0pt;
 30     font-weight:400;
 31     font-style:normal;
 32     text-decoration:none;
 33     font-family:宋体;
 34     mso-generic-font-family:auto;
 35     mso-font-charset:134;
 36     border:none;
 37     mso-protection:locked visible;
 38     mso-style-name:常规;
 39     mso-style-id:0;}
 40 .font7
 41     {color:windowtext;
 42     font-size:9.0pt;
 43     font-weight:400;
 44     font-style:normal;
 45     text-decoration:none;
 46     font-family:宋体;
 47     mso-generic-font-family:auto;
 48     mso-font-charset:134;}
 49 .font9
 50     {color:windowtext;
 51     font-size:9.0pt;
 52     font-weight:400;
 53     font-style:normal;
 54     text-decoration:none;
 55     font-family:宋体;
 56     mso-generic-font-family:auto;
 57     mso-font-charset:134;}
 58 td
 59     {mso-style-parent:style0;
 60     padding-top:1px;
 61     padding-right:1px;
 62     padding-left:1px;
 63     mso-ignore:padding;
 64     color:black;
 65     font-size:11.0pt;
 66     font-weight:400;
 67     font-style:normal;
 68     text-decoration:none;
 69     font-family:宋体;
 70     mso-generic-font-family:auto;
 71     mso-font-charset:134;
 72     mso-number-format:General;
 73     text-align:general;
 74     vertical-align:middle;
 75     border:none;
 76     mso-background-source:auto;
 77     mso-pattern:auto;
 78     mso-protection:locked visible;
 79     white-space:nowrap;
 80     mso-rotate:0;}
 81 .xl65
 82     {mso-style-parent:style0;
 83     color:windowtext;
 84     font-size:14.0pt;
 85     white-space:normal;}
 86 .xl66
 87     {mso-style-parent:style0;
 88     color:windowtext;
 89     font-size:14.0pt;}
 90 .xl67
 91     {mso-style-parent:style0;
 92     color:windowtext;
 93     font-size:14.0pt;
 94     border:.5pt solid windowtext;
 95     white-space:normal;}
 96 .xl68
 97     {mso-style-parent:style0;
 98     color:windowtext;
 99     font-size:14.0pt;
100     mso-number-format:"yyyy\0022年\0022m\0022月\0022d\0022日\0022\;\@";
101     text-align:center;
102     border:.5pt solid windowtext;}
103 .xl69 {
104     FONT-SIZE: 14pt; mso-style-parent: style0
105 }
106 .xl70
107     {mso-style-parent:style0;
108     color:windowtext;
109     font-size:14.0pt;
110     mso-number-format:"yyyy\0022年\0022m\0022月\0022d\0022日\0022\;\@";
111     text-align:center;
112     border:.5pt solid windowtext;
113     }
114 .xl71
115     {mso-style-parent:style0;
116     color:windowtext;
117     font-size:14.0pt;
118     mso-number-format:"\@";
119     text-align:left;
120     border:.5pt solid windowtext;}
121 .xl72
122     {mso-style-parent:style0;
123     color:windowtext;
124     font-size:14.0pt;
125     border:.5pt solid windowtext;}
126 .xl73
127     {mso-style-parent:style0;
128     color:windowtext;
129     font-size:14.0pt;
130     text-align:center;
131     border:.5pt solid windowtext;}
132 .xl74
133     {mso-style-parent:style0;
134     white-space:normal;}
135 .xl75
136     {mso-style-parent:style0;
137     color:windowtext;
138     font-size:14.0pt;
139     text-align:center;
140     vertical-align:121;
141     border:.5pt solid windowtext;}
142 .xl76
143     {mso-style-parent:style0;
144     color:windowtext;
145     font-size:14.0pt;
146     text-align:center;
147     vertical-align:121;
148     border:.5pt solid windowtext;
149     white-space:normal;}
150 .xl77
151     {mso-style-parent:style0;
152     color:windowtext;
153     font-size:20.0pt;
154     font-family:黑体, monospace;
155     mso-font-charset:134;
156     text-align:center;}
157 .xl78
158     {mso-style-parent:style0;
159     color:windowtext;
160     font-size:14.0pt;
161     mso-number-format:"yyyy\0022年\0022m\0022月\0022d\0022日\0022\;\@";
162     text-align:right;}
163 .xl79
164     {mso-style-parent:style0;
165     color:windowtext;
166     font-size:14.0pt;
167     text-align:center;
168     border-top:.5pt solid windowtext;
169     border-right:.5pt solid windowtext;
170     border-bottom:none;
171     border-left:.5pt solid windowtext;
172     white-space:normal;}
173 .xl80
174     {mso-style-parent:style0;
175     color:windowtext;
176     font-size:14.0pt;
177     text-align:center;
178     border-top:none;
179     border-right:.5pt solid windowtext;
180     border-bottom:none;
181     border-left:.5pt solid windowtext;
182     white-space:normal;}
183 .xl81
184     {mso-style-parent:style0;
185     color:windowtext;
186     font-size:14.0pt;
187     text-align:center;
188     border-top:none;
189     border-right:.5pt solid windowtext;
190     border-bottom:.5pt solid windowtext;
191     border-left:.5pt solid windowtext;
192     white-space:normal;}
193 .xl82
194     {mso-style-parent:style0;
195     border-top:none;
196     border-right:.5pt solid windowtext;
197     border-bottom:none;
198     border-left:.5pt solid windowtext;}
199 .xl83
200     {mso-style-parent:style0;
201     border-top:none;
202     border-right:.5pt solid windowtext;
203     border-bottom:.5pt solid windowtext;
204     border-left:.5pt solid windowtext;}
205 .xl84
206     {mso-style-parent:style0;
207     color:windowtext;
208     font-size:14.0pt;
209     mso-number-format:"\@";
210     text-align:left;
211     border-top:.5pt solid windowtext;
212     border-right:none;
213     border-bottom:.5pt solid windowtext;
214     border-left:.5pt solid windowtext;}
215 .xl85
216     {mso-style-parent:style0;
217     color:windowtext;
218     font-size:14.0pt;
219     mso-number-format:"\@";
220     text-align:left;
221     border-top:.5pt solid windowtext;
222     border-right:.5pt solid windowtext;
223     border-bottom:.5pt solid windowtext;
224     border-left:none;}
225 .xl86
226     {mso-style-parent:style0;
227     color:windowtext;
228     font-size:14.0pt;
229     text-align:center;
230     border-top:.5pt solid windowtext;
231     border-right:none;
232     border-bottom:.5pt solid windowtext;
233     border-left:.5pt solid windowtext;}
234 .xl87
235     {mso-style-parent:style0;
236     color:windowtext;
237     font-size:14.0pt;
238     text-align:center;
239     border-top:.5pt solid windowtext;
240     border-right:.5pt solid windowtext;
241     border-bottom:.5pt solid windowtext;
242     border-left:none;}
243 .xl88
244     {mso-style-parent:style0;
245     color:windowtext;
246     font-size:14.0pt;
247     text-align:left;
248     vertical-align:121;
249     border-top:.5pt solid windowtext;
250     border-right:none;
251     border-bottom:none;
252     border-left:.5pt solid windowtext;}
253 .xl89
254     {mso-style-parent:style0;
255     color:windowtext;
256     font-size:14.0pt;
257     text-align:left;
258     vertical-align:121;
259     border-top:.5pt solid windowtext;
260     border-right:.5pt solid windowtext;
261     border-bottom:none;
262     border-left:none;}
263 .xl90
264     {mso-style-parent:style0;
265     color:windowtext;
266     font-size:14.0pt;
267     text-align:left;
268     vertical-align:121;
269     border-top:none;
270     border-right:none;
271     border-bottom:.5pt solid windowtext;
272     border-left:.5pt solid windowtext;}
273 .xl91
274     {mso-style-parent:style0;
275     color:windowtext;
276     font-size:14.0pt;
277     text-align:left;
278     vertical-align:121;
279     border-top:none;
280     border-right:.5pt solid windowtext;
281     border-bottom:.5pt solid windowtext;
282     border-left:none;}
283 .xl92
284     {mso-style-parent:style0;
285     color:windowtext;
286     font-size:14.0pt;
287     mso-number-format:Standard;
288     text-align:left;
289     border:.5pt solid windowtext;}
290 .xl93
291     {mso-style-parent:style0;
292     color:windowtext;
293     font-size:14.0pt;
294     text-align:left;
295     border-top:.5pt solid windowtext;
296     border-right:none;
297     border-bottom:.5pt solid windowtext;
298     border-left:.5pt solid windowtext;}
299 .xl94
300     {mso-style-parent:style0;
301     color:windowtext;
302     font-size:14.0pt;
303     text-align:left;
304     border-top:.5pt solid windowtext;
305     border-right:none;
306     border-bottom:.5pt solid windowtext;
307     border-left:none;}
308 .xl95
309     {mso-style-parent:style0;
310     color:windowtext;
311     font-size:14.0pt;
312     text-align:left;
313     border-top:.5pt solid windowtext;
314     border-right:.5pt solid windowtext;
315     border-bottom:.5pt solid windowtext;
316     border-left:none;}
317  
318 </STYLE>
319  
320 <STYLE>@page  {margin: 1.0in .75in 1.0in .75in; mso-header-margin: .5in; mso-footer-margin: .5in; mso-page-orientation: landscape; }
321 TABLE {
322     mso-displayed-decimal-separator: "."; mso-displayed-thousand-separator: ","
323 }
324 RUBY {
325     RUBY-ALIGN: left
326 }
327 RT {
328     FONT-STYLE: normal; DISPLAY: none; FONT-FAMILY: 宋体; COLOR: windowtext; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-generic-font-family: auto; mso-font-charset: 134; mso-char-type: none
329 }
330 </STYLE>
331  
332 <STYLE>@page  {margin: .75in .71in .75in .71in; mso-header-margin: .31in; mso-footer-margin: .31in; mso-page-orientation: landscape; }
333 TABLE {
334     mso-displayed-decimal-separator: "."; mso-displayed-thousand-separator: ","
335 }
336 RUBY {
337     RUBY-ALIGN: left
338 }
339 RT {
340     FONT-STYLE: normal; DISPLAY: none; FONT-FAMILY: 宋体; COLOR: windowtext; FONT-SIZE: 9pt; FONT-WEIGHT: 400; TEXT-DECORATION: none; mso-generic-font-family: auto; mso-font-charset: 134; mso-char-type: none
341 }
342 </STYLE>
343 <style media="print">
344 .Noprint { DISPLAY: none }
345 </style>
346 <style>
347     div.page{page-break-after: always}
348 </style>
349 </HEAD>
350 <BODY link=blue vLink=purple oncontextmenu="return false;" onselectstart="return false;" ondragstart="return false;">
351 <OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0 VIEWASTEXT> </OBJECT>
352 <input type=button value="页面设置" onclick="document.all.WebBrowser.ExecWB(8,1)" class="NOPRINT">   
353 <input type=button value="打印预览" onclick="document.all.WebBrowser.ExecWB(7,1)" class="NOPRINT">
354 <span class="NOPRINT">&nbsp;<font color="red">(注:请选择页面设置按钮,将页面打印设为横向,页眉页脚都设置为空!)</font></span>
355 <c:forEach items="${resultList}" var="record_list" varStatus="status" >
356 <c:if test="${status.index ne resultListCount-1}"><div class="page"></c:if>
357 <TABLE style="WIDTH: 782pt; BORDER-COLLAPSE: collapse; TABLE-LAYOUT: fixed" 
358 border=0 cellSpacing=0 cellPadding=0 width=1042>
359 <COLGROUP>
360   <COL style="mso-width-source: userset;">
361   <COL style="mso-width-source: userset;">
362   <COL style="mso-width-source: userset;">
363   <COL style="mso-width-source: userset;">
364   <COL style="mso-width-source: userset;">
365   <COL style="mso-width-source: userset;">
366   <TBODY>
367   <TR style="HEIGHT: 13.5pt" height=18>
368     <TD style="WIDTH: 111pt; HEIGHT: 13.5pt" class=xl74 height=18 
369 width=148></TD>
370     <TD style="WIDTH: 95pt" width=126></TD>
371     <TD style="WIDTH: 111pt" width=148></TD>
372     <TD style="WIDTH: 111pt" width=148></TD>
373     <TD style="WIDTH: 103pt" width=137></TD>
374     <TD style="WIDTH: 84pt" width=112></TD>
375     <TD style="WIDTH: 167pt" width=223></TD></TR>
376   <TR style="HEIGHT: 25.5pt" height=34>
377     <TD style="HEIGHT: 25.5pt" class=xl77 height=34 
378       colSpan=7>平安证券有限责任公司后柜内转申请表<RUBY><FONT class=font7><RT 
379       class=font7></RT></FONT></RUBY></TD></TR>
380   <TR height=32>
381     <TD style="WIDTH: 111pt; HEIGHT: 24.6pt" class=xl65 height=32 
382       width=148><RUBY><FONT class=font7><RT 
383 class=font7></RT></FONT></RUBY></TD>
384     <TD class=xl78 colSpan=6><fmt:formatDate pattern="yyyy-MM-dd" value="${record_list.allocateDate }"/></TD></TR>
385   <TR height=32>
386     <TD class=xl68 height=32 width=148 align=center>申请部门</TD>
387     <TD class=xl68 colspan=6><c:out value="${record_list.deptName }"/></TD>
388    </TR>
389   <TR height=32>
390     <TD class=xl68 height=115 rowSpan=3 width=148>付款资金账号<RUBY><FONT 
391       class=font7><RT class=font7></RT></FONT></RUBY></TD>
392     <TD class=xl68>&nbsp;&nbsp;&nbsp;&nbsp;<RUBY><FONT class=font7><RT class=font7></RT></FONT></RUBY></TD>
393     <TD class=xl68 colSpan=2 align="center"><c:out value="${record_list.payName }"/></TD>
394     <TD class=xl68 rowSpan=3 width=137>收款资金账号</TD>
395     <TD class=xl68>&nbsp;&nbsp;&nbsp;&nbsp;</TD>
396     <TD class=xl68><c:out value="${record_list.payeeName }"/></TD></TR>
397   <TR height=32>
398     <TD class=xl68 height=32>资金账号</TD>
399     <TD class=xl68 colSpan=2 align="center"><c:out value="${record_list.payAccount }"/> </TD>
400     <TD class=xl68>资金账号</TD>
401     <TD class=xl68 align="center"><c:out value="${record_list.payeeAccount }"/> </TD></TR>
402   <TR height=51>
403   <TD class=xl68 height=51 width=126>&nbsp;&nbsp;<BR>(深/沪)</TD>
404     <TD  class=xl68 colSpan=2 align="center"><c:if test="${record_list.payMarket eq '1' }"></c:if><c:if test="${record_list.payMarket eq '2' }"></c:if> </TD>
405     <TD  class=xl68 width=112>&nbsp;&nbsp;<BR>(深/沪)<RUBY><FONT class=font9><RT 
406       class=font9></RT></FONT></RUBY></TD>
407     <TD class=xl68 align="center"><c:if test="${record_list.payeeMarket eq '1' }"></c:if><c:if test="${record_list.payeeMarket eq '2' }"></c:if> </TD></TR>
408   <TR height=32>
409     <TD class=xl68 height=64 rowSpan=2 colSpan=2><SPAN 
410       style="mso-spacerun: yes">&nbsp;</SPAN>金额(人民币)<RUBY><FONT class=font7><RT 
411       class=font7></RT></FONT></RUBY></TD>
412     <TD  class=xl68>大写:<RUBY><FONT class=font7><RT 
413     class=font7></RT></FONT></RUBY></TD>
414     <TD class=xl68 colSpan=4 style="text-align: left;" id="amount_ch<c:out value='${status.count}'/>"></TD></TR>
415   <TR height=32>
416     <TD class=xl68 height=32>小写:<RUBY><FONT class=font7><RT 
417       class=font7></RT></FONT></RUBY></TD>
418     <TD class=xl68 colSpan=4 style="text-align: left;"><fmt:formatNumber pattern="#,###,##0.00" value="${record_list.amount}"/></TD></TR>
419   <TR height=32>
420     <TD class=xl68 height=32 width=148 align=center>调款原因</TD>
421     <TD class=xl68 colSpan=6 style="text-align: left;border-right:.5pt solid windowtext;"><c:out value="${record_list.allocateReason }" /></TR>
422   <TR style="HEIGHT: 18.75pt" class=xl65 height=25>
423     <TD style="HEIGHT: 18.75pt" class=xl69 height=25 colspan=7>
424         申请人:<c:if test="${!empty record_list.createdBy }"><t:username umid="${record_list.createdBy }" disType="1" /></c:if>
425         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
426         复核人:<c:if test="${!empty record_list.reviewBy }"><t:username umid="${record_list.reviewBy }" disType="1" /></c:if>
427         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
428         经办人:<c:if test="${!empty record_list.confirmBy }"><t:username umid="${record_list.confirmBy }" disType="1" /></c:if>
429         &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
430         经理:<c:if test="${!empty record_list.lastApprovedBy }"><t:username umid="${record_list.lastApprovedBy }" disType="1" /></c:if>
431     </TD></TR>
432   <TR style="HEIGHT: 18.75pt" class=xl66 height=25>
433     <TD style="HEIGHT: 18.75pt" class=xl65 height=25></TD>
434     <TD style="mso-ignore: colspan" class=xl66 colSpan=6></TD></TR><![if supportMisalignedColumns]>
435  <tr height=0 style='display:none'>
436   <td width=148 style='width:111pt'></td>
437   <td width=126 style='width:95pt'></td>
438   <td width=148 style='width:111pt'></td>
439   <td width=148 style='width:111pt'></td>
440   <td width=137 style='width:103pt'></td>
441   <td width=112 style='width:84pt'></td>
442   <td width=223 style='width:167pt'></td>
443  </tr>
444  <![endif]></TBODY></TABLE>
445  <script language="javascript">
446 amountSmallToCapital('<c:out value="${record_list.amount}"/>','amount_ch<c:out value='${status.count}'/>');
447 </script>    
448 <c:if test="${status.index ne resultListCount-1}"></div></c:if>
449 </c:forEach>
450  </BODY></HTML>

重点是这个:

<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(8,1)" class="NOPRINT">   
<input type=button value="打印预览" onclick="document.all.WebBrowser.ExecWB(7,1)" class="NOPRINT">

share page
<c:forEach items="${resultList}" var="record_list" varStatus="status" >
<c:if test="${status.index ne resultListCount-1}"><div class="page"></c:if>

===============================
content
===============================

<c:if test="${status.index ne resultListCount-1}"></div></c:if>
</c:forEach>

 

posted on 2013-01-24 08:56  陈惟鲜的博客  阅读(290)  评论(0编辑  收藏  举报

导航