function printTbl() { var TableToPrint = document.getElementById('Table1'); var htmlToPrint = '' + '<style type="text/css">' + 'table th, table td {' + 'padding: 5px; ' + '}' + ' #walkheader{border-left: none!important; border-right: none!important;}' + ' #Table1{padding: 4px; border-collapse:collapse; font; font-size:12pt;}' + ' #printHeader2 td{ border-bottom: solid black 1px; border-right: solid black 1px!important; }' + ' td{ border-bottom: solid black 1px; border-right: solid black 1px!important; border-left: solid black 1px!important; }' + '</style>'; htmlToPrint += TableToPrint.outerHTML; newWin = window.open(""); newWin.document.write("<h2>Header</h2>"); newWin.document.write(htmlToPrint); newWin.print(); newWin.close(); }
<a href="java<!-- no -->script:void(0);" id="printPage" >Print</a>
<table id="Table1" runat="server" style="display:none"> <tr runat="server" id="printHeader1_row"> <td runat="server" id="walkheader" colspan="2"></td> </tr> <tr style="border-bottom: solid 1px black" runat="server" id="printHeader2"> <td>Time</td> <td>Name and Surmane</td> </tr> </table>
<style media="print">
printTbl
htmlToPrint
display:none
document.getElementById
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)