Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

export csv single javascript

//EXPORT SINGLE COLUMN CSV JAVASCRIPT
function downloadCSV(csv, filename) {
var csvFile;
var downloadLink;
csvFile = new Blob([csv], {type: "text/csv"});
downloadLink = document.createElement("a");
downloadLink.download = filename;
downloadLink.href = window.URL.createObjectURL(csvFile);
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
downloadLink.click();
}
//export
function exportss(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr");
let aa = Array.from(rows).map((x,y)=> {
var row = [], cols = rows[y].querySelectorAll("td, th"); 
    Array.from(cols).forEach((a,b)=>{
        row.push(cols[b].innerText);
    })
    csv.push(row.join(","))
    console.log(csv)   
    return x
    })
downloadCSV(csv.join("
"), filename);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #export #csv #single #javascript
ADD COMMENT
Topic
Name
7+9 =