web列印table,每頁都顯示錶頭
阿新 • • 發佈:2019-01-09
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" c>
<title>test</title>
<style>
@media print{
INPUT {display:none}
}
</style>
</head>
<body >
<TABLE border="0" style="font-size:9pt;" width="300px" align="center">
<THEAD style="display:table-header-group;font-weight:bold">
<TR><TD colspan="2" align="center" style="font-weight:bold;border:3px double red">每頁都有的表頭</TD></TR>
</THEAD>
<TBODY style="text-align:center"">
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR style=" page-break-after:always;"><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR style="page-break-after:always;"><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR><TD>表格內容</TD><TD>表格內容</TD></TR>
<TR style="page-break-after:always;"><TD>表格內容</TD><TD>表格內容</TD></TR>
</TBODY>
<TFOOT style="display:table-footer-group;font-weight:bold">
<TR>
<TD colspan="2" align="center" style="font-weight:bold;border:3px double blue">每頁都有的表尾</TD>
</TR>
</TFOOT>
</TABLE>
<input type=button value=" 打 印 " onclick="window.print()">
</body>
</html>
我的專案裡頁面用的是jsp,調了很長時間,還是不能實現每頁都有表頭的功能,後來靈感一現,把檔案字尾改成了html,然後就ok了。
如果想實現這樣的功能,也許不止一種方法,直接在頁面裡輸出多個表頭,按每頁需要列印的內容排好版,應該也能實現這個的功能的,有時間了測試一下。