Exporting An Array Of Arrays To Csv
I'm trying to loop through a multidimensional array to export it to CSV. I've tried to copy copy some of the guides online, and most seem to show similar solutions to How to export
Solution 1:
I was over complicating it. The below code has worked and I've created a button to trigger the function, rather than forcing a click.
function createCSV() {
var csv = "";
properties.forEach(function(row) {
csv += row.join(',');
csv += "\n";
});
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURI(csv);
hiddenElement.target = '_blank';
hiddenElement.download = 'properties.csv';
hiddenElement.click();
}
Post a Comment for "Exporting An Array Of Arrays To Csv"