Skip to content

Instantly share code, notes, and snippets.

@dhunmoon
dhunmoon / jsCSVFileCreationBlob.js
Created Mar 22, 2017
JS: CSV File Creation Using BLOB
View jsCSVFileCreationBlob.js
function exportToCsv(filename, rows) {
var processRow = function (row) {
var finalVal = '';
for (var j = 0; j < row.length; j++) {
var innerValue = row[j] === null ? '' : row[j].toString();
if (row[j] instanceof Date) {
innerValue = row[j].toLocaleString();
};
var result = innerValue.replace(/"/g, '""');
if (result.search(/("|,|\n)/g) >= 0)