0
我有一个样品fiddle here在那里我可以打印HTML表格为PDF格式,导出HTML表到csv
function printpage() {
var data = '<table border="1" cellspacing="0"><tr><td colspan="4">Sample Report</td></tr>' + document.getElementsByTagName('table')[0].innerHTML + '</table>';
data += '<br/><button onclick="window.print()" class="noprint">Print the Report</button>';
data += '<style type="text/css" media="print"> .noprint {visibility: hidden;} </style>';
myWindow = window.open('', '', 'width=800,height=600');
myWindow.innerWidth = screen.width;
myWindow.innerHeight = screen.height;
myWindow.screenX = 0;
myWindow.screenY = 0;
myWindow.document.write(data);
myWindow.document.close();
myWindow.focus();
}
如何添加使用,我可以导出打印预览页面内多了一个按钮在csv/xls格式的同一张表?
无法下载标题行 – mpsbhat
代码仅写入表行。不用于标题。你可以看到行号3 var $ rows = $ table.find('tr:has(td)'), – Chirag
如何给下载的文件以外的其他名称而不是'download'? – mpsbhat