Skip to content

Instantly share code, notes, and snippets.

@evangrim
evangrim / jsCsvDownload
Last active May 10, 2022 05:12
JavaScript create and download CSV
//columns is array of string values, or something falsy
//rows is 2d array with inner arrays comprised of cell values (strings)
//columns array will have same length as each member of rows array
$scope.downloadCsv = function(columns, rows, filenameWithoutExtension) {
let separator = "\n";
// join(',') + "\n";
// const header = columnsArr.join(',') + "\r\n";
const header = columns.join(',') + separator;