WEB打印,分页首行自动带出栏目标题
<!--startprint-->
<div style="margin-left: 10px; margin-right: 10px">
<h3 style="text-align: center">
动情网科技(厦门)有限公司<br/>
采购单
</h3>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableX" cellspacing="0">
<tr>
<td style="text-align: right; background-color: #b7d9c5; width:12%;">
单号
</td>
<td align="left" style="width:25%;">
<asp:Label ID="lblBH" runat="server"></asp:Label>
</td>
<td style="text-align: right; background-color: #b7d9c5; width:12%;">
日期
</td>
<td align="left" style="width:25%;">
<asp:Label ID="lblDATE" runat="server"></asp:Label>
</td>
</tr>
<!--startprint1-->
<tr>
<td colspan="4">打印的时候不打印出来
</td>
</tr>
<!--endprint1-->
<div style="display: block;" id="tr_rplist">
<table class="tableX" width="100%">
<thead style="display:table-header-group;">
<tr>
<th style="width: 3%; text-align: center; border: 1px solid #000;">
序号
</th>
<th style="width: 40%; text-align: center; border: 1px solid #000;">
采购单号
</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rplist" runat="server">
<ItemTemplate>
<tr>
<td>
<%# Container.ItemIndex+1 %>
</td>
<td style="text-align: center">
<%# Eval("BH")%>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</div>
<div style="float:right; padding-right:180px; padding-top:30px; font-weight:bold;"> 厂商签字/盖章:</div>
</div>
<!--endprint-->
<div style=" width:100%; text-align:center;">
<br />
<input type="button" name="aa" value="打 印" onclick="preview()"/>
<br />
<script language="javascript">
function preview() {
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
sprnstr1="<!--startprint1-->";
eprnstr1="<!--endprint1-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
prnhtml = prnhtml.substring(0, prnhtml.indexOf(sprnstr1)) + prnhtml.substr(prnhtml.indexOf(eprnstr1) + 16);
window.document.body.innerHTML = prnhtml;
// window.document.getElementsByTagName('body')[0].style.zoom = 95;
window.print();
window.document.body.innerHTML=bdhtml;
}</script>
打印的时候,要求每页上都要有表头。定义 thead,样式设置成:style="display:table-header-group"。
如果要求有表尾,定义其tfoot,样式设置成 :style="display:table-footer-group"。