JS

JAVASCRIPT EXPORT ARRAY TO CSV FILE

var array = [   ["Job", "job@doe.com", "123456"],   ["Joe", "joe@doe.com", "234567"],   ["Joi", "joi@doe.com", "345678"],   ["Jon", "jon@doe.com", "456789"],   ["Jou", "jou@doe.com", "987654"],   ["Joy", "joy@doe.com", "876543"]  ];

DUMMY ARRAY

01

var csv = ""; for (let row of array) {   for (let col of row) { csv += col + ","; }   csv += "\r\n";  }

ARRAY TO CSV STRING

02

CREATE BLOB OBJECT  var cb = new Blob([csv], {type: "text/csv"});

DOWNLOAD CSV FILE

03

CREATE DOWNLOAD LINK var url = window.URL.createObjectURL(cb); var anchor = document.createElement("a"); anchor.href = url; anchor.download = "demo.csv";

"FORCE DOWNLOAD" anchor.click(); window.URL.revokeObjectURL(url); anchor.remove();