I'm submitting a ...
[x ] bug report
Current behavior
If column data includes commas, when exported to csv the data after the comma is moved to the next column, thereby throwing off the formatting of the sheet
Expected behavior
commas should be escaped inside column data so that all the data for the cell stays under its proper column header
Minimal reproduction of the problem with instructions
use a comma inside cell data eg "other , test" then export the table to csv
Angular version: 2.4
PrimeNG version: 2.0.4
This has been an issue for a while, shouldn't be too hard to fix on their end. I think just escaping the string types should work.
In primeng/datatable/datatable.js, line 1452:
//body
this.value.forEach(function (record, i) {
csv += '\n';
for (var i_1 = 0; i_1 < _this.columns.length; i_1++) {
if (_this.columns[i_1].field) {
if ( typeof _this.resolveFieldData(record, _this.columns[i_1].field) === 'string' )
csv += ("\"" + _this.resolveFieldData(record, _this.columns[i_1].field) + "\"");
else
csv += _this.resolveFieldData(record, _this.columns[i_1].field);
if (i_1 < (_this.columns.length - 1)) {
csv += _this.csvSeparator;
}
}
}
});
Most helpful comment
This has been an issue for a while, shouldn't be too hard to fix on their end. I think just escaping the string types should work.
In primeng/datatable/datatable.js, line 1452: