ignore commas within string in JSON when exporting to csv ignore commas within string in JSON when exporting to csv json json

ignore commas within string in JSON when exporting to csv


For Excel, you need to wrap values in quotation marks. See this question.

In json-export-excel.js you'll see that the _objectToString method wraps the output in quotes but because the fieldValue variable isn't an object this is never called for this example.

function _objectToString(object) {  var output = '';  angular.forEach(object, function(value, key) {    output += key + ':' + value + ' ';  });  return '"' + output + '"';}var fieldValue = data !== null ? data : ' ';if fieldValue !== undefined && angular.isObject(fieldValue)) {  fieldValue = _objectToString(fieldValue);}

If you add an else statement to this to wrap the value in quotes, the CSV opens in Excel as desired.

} else if (typeof fieldValue === "string") {  fieldValue = '"' + fieldValue + '"';}  

Plunker