function downloadFile(fileName, urlData) {
var aLink = document.createElement('a');
var evt = document.createEvent("HTMLEvents");
evt.initEvent("click");
aLink.download = fileName;
aLink.href = urlData;
aLink.dispatchEvent(evt);
}
var data = '"Column One","Column Two","Column Three"';
downloadFile('2.csv', 'data:text/csv;charset=UTF-8,' + encodeURIComponent(data));
//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);
}