[英]Export the html table to csv
I have a sample fiddle here where i can print the html table to pdf format as, 我在这里有一个样本小提琴 ,我可以将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();
}
how can i add one more button inside the print preview page using which i can export the same table in csv/xls format? 如何在打印预览页面内添加一个按钮,使用该按钮可以以csv / xls格式导出同一表格?
Go through below link . 通过下面的链接。 You will get the solution
您将获得解决方案
`http://jsfiddle.net/terryyounghk/KPEGU/`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.