Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createCSV(selector){
- var contentString, $els, i,j, l,m, tmp,
- row = document.querySelectorAll(selector)
- for(i=0, l=$row.length; i<l; i++){
- $els = $row[i].children;
- tmp = [];
- for(j=0, m=$els.length; j<m; j++){
- tmp.push($els[j].innerText);
- }
- contentString += tmp.join(",")+"\n";
- }
- return contentString;
- }
- function download(data, opt){
- var a = window.document.createElement('a');
- a.href = window.URL.createObjectURL(new Blob([data], {type: opt.mimeType}));
- a.download = opt.filename;
- document.body.appendChild(a)
- a.click();
- document.body.removeChild(a)
- }
- download(createCSV("table tr"), {
- mimeType:'text/csv',
- filename: 'table.csv'
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement