TableExport icon indicating copy to clipboard operation
TableExport copied to clipboard

Escape cell if there's a comma

Open harryadel opened this issue 6 years ago • 0 comments

Table cells that contains commas are usually ignored if not causing misalignment, so we check if the text string contains a comma to escape it.

((val.textContent.indexOf(',') > -1) ? '"\'' : '"') + settings.formatValue(val.textContent.replace(/"/g, '""')) + '"';

The ES6 version of this solution is

`"'${settings.formatValue(val.textContent.replace(/"/g, '""'))}"`;

But we opted for the ES5 one for backwards compatibility, thanks!

harryadel avatar Nov 11 '18 16:11 harryadel