Francesco Report post Posted September 6, 2018 Hi, we used client side export chart functionality for creating an excel report. However when exported data contains commas, generated excel got broken (rows with commas have more columns than header). So...digging in fusioncharts.js code we did this trick: Quote k = function() { var c = 0; Oa = []; Na.replace(/[^\r\n]+/g, function(a) { Oa[c] = []; // FB fix for exporting data with comma inside /* Oa[c] = a.split(",").map(function(c) { return c.replace(/"/g, "") }); */ Oa[c] = splitCsv(a).map(function(c) { return c.replace(/"/g, "") }); c += 1 }) }, ..using stackoverflow splt function below: Quote function splitCsv(str) { return str.split(',').reduce((accum,curr)=>{ if(accum.isConcatting) { accum.soFar[accum.soFar.length-1] += ','+curr } else { accum.soFar.push(curr) } if(curr.split('"').length % 2 == 0) { accum.isConcatting= !accum.isConcatting } return accum; },{soFar:[],isConcatting:false}).soFar } Our problem seems to be solved right now ...but is there any side effect we don't know? May I have broken something else? Regards, Francesco Share this post Link to post Share on other sites
Francesco Report post Posted September 10, 2018 ...or if preferred : var regex = /,(?=(?:(?:[^'"]*(?:'|")){2})*[^'"]*$)/; Oa[c] = a.split(regex).map(function(c) { return c.replace(/"/g, "") }); Share this post Link to post Share on other sites