-
Notifications
You must be signed in to change notification settings - Fork 0
/
exporttable.html
11 lines (10 loc) · 1.73 KB
/
exporttable.html
1
2
3
4
5
6
7
8
9
10
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Export to CSV</title>
</head>
<body>
Drag me to the bookmark toolbar: <a href="javascript:void%20function(){function%20e(e,t){var%20a=document.createElement(%22script%22);a.src=e;var%20n=document.getElementsByTagName(%22head%22)[0],o=!1;a.onload=a.onreadystatechange=function(){o||this.readyState%26%26%22loaded%22!=this.readyState%26%26%22complete%22!=this.readyState||(o=!0,t(),a.onload=a.onreadystatechange=null,n.removeChild(a))},n.appendChild(a)}function%20t(){jQuery(%22.csvLink%22).remove(),jQuery(%22table%22).each(function(e){jQuery(this).attr(%22data-csvtable%22,e).before('%3Ca%20href=%22%23%22%20class=%22csvLink%22%20data-forcsvtable=%22'+e+'%22%3EExport%20to%20CSV%3C/a%3E')}),jQuery(%22.csvLink%22).click(function(){var%20e=%22%22,t=jQuery(this).attr(%22data-forcsvtable%22);jQuery('table[data-csvtable=%22'+t+'%22]%20tr').each(function(){jQuery(%22td,%20th%22,this).each(function(t){0!=t%26%26(e+=%22,%22),e+='%22'+jQuery(this).text().replace(/\xa0/g,%22%20%22).replace(/\r%3F\n|\r/g,%22%22).replace(/%22/g,'%22%22')+'%22'}),e+=%22\r\n%22}),jQuery(%22.csvLink%22).remove(),a(%22TableExport.csv%22,%22text/csv%22,e)})}function%20a(e,t,a){if(window.navigator.msSaveOrOpenBlob){var%20n=new%20Blob([decodeURIComponent(encodeURI(a))],{type:%22text/csv;charset=utf-8%22});window.navigator.msSaveBlob(n,e)}else{var%20o=document.createElement(%22a%22);o.setAttribute(%22href%22,%22data:%22+t+%22;charset=utf-8,%22+encodeURIComponent(a)),o.setAttribute(%22download%22,e),document.body.appendChild(o),o.click(),document.body.removeChild(o)}}%22undefined%22==typeof%20jQuery%3Fe(%22//code.jquery.com/jquery-latest.min.js%22,function(){t()}):t()}();">Export to CSV</a>
</body>
</html>