2022-11-04 18:58:35 -07:00
|
|
|
function saveData(csvStr, filename) {
|
2022-11-04 18:42:22 -07:00
|
|
|
// string rep
|
|
|
|
// var csvStr = "";
|
|
|
|
// for (let r = 0; r < csvData.length; r++) {
|
|
|
|
// let row = csvData[r]
|
|
|
|
// for (let c = 0; c < row.length; c++) {
|
|
|
|
// let item = row[c]
|
|
|
|
// csvStr += item;
|
|
|
|
// if (c < row.length - 1)
|
|
|
|
// csvStr += ",";
|
|
|
|
// }
|
|
|
|
// if (r < csvStr.length - 1)
|
|
|
|
// csvStr += "\r\n";
|
|
|
|
// }
|
2022-11-04 17:55:25 -07:00
|
|
|
|
2022-11-04 18:42:22 -07:00
|
|
|
// define data blob
|
|
|
|
var data = new Blob([csvStr]);
|
|
|
|
|
|
|
|
// create & click temp link
|
2022-11-04 18:58:35 -07:00
|
|
|
// slightly modded https://stackoverflow.com/a/15832662
|
|
|
|
var link = document.createElement("a");
|
|
|
|
link.download = filename;
|
|
|
|
link.href = URL.createObjectURL(data);
|
|
|
|
document.body.appendChild(link);
|
|
|
|
link.click();
|
|
|
|
document.body.removeChild(link);
|
|
|
|
delete link;
|
2022-11-04 17:55:25 -07:00
|
|
|
}
|