Generate CSV File in Javascript

home-brew-mac

How to Generate CSV File in Javascript //JSON DATAS var data = [ [‘Singaporean’, ‘Singapore’], [‘Indian’, ‘India’] ]; //CONVERT JSON Variant to TWO-DIMENSION Array var csvContent = ”; data.forEach(function(infoArray, index) { dataString = infoArray.join(‘;’); csvContent += index < data.length ? dataString + ‘\n’ : dataString; }); //Function to DOWNLOAD a file. var download = function(content, fileName, mimeType) { var a = document.createElement(‘a’); mimeType = mimeType || ‘application/octet-stream’; if (navigator.msSaveBlob) { // IE10 navigator.msSaveBlob(new Blob([content], { type: mimeType }), fileName); } else if (URL && ‘download’ in a) { //html5 A[download] a.href = URL.createObjectURL(new Blob([content], {…

Read More