I am creating a CSV file from some data in javascript. My function looks like:
function exportCSV() {
let csvContent = "data:text/csv;charset=utf-8,";
let header = "color, make, model,";
csvContent = csvContent + "\r\n" + header;
csvData.forEach(function(rowArray) {
let row = rowArray.join(",");
csvContent += row + "\r\n";
});
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
}
As it is, the CSV that I get from this function has the headers, but then the data immediately follows the last header name and does not have a carriage return. Is there a character I am missing, or perhaps doing these things in the wrong order?