【发布时间】:2014-02-13 12:24:52
【问题描述】:
我有一个示例fiddle here,我可以在其中将 html 表格打印为 pdf 格式,
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 格式导出同一个表格?
【问题讨论】:
标签: javascript csv printing html-table export-to-csv