jQuery UI Widgets › Forums › Grid › jqxGrid Export Issue with Quotes
This topic contains 6 replies, has 5 voices, and was last updated by svetoslav_borislavov 2 years ago.
-
Author
-
I’m using 3.6.0 Developer License, and I’m having an issue with the ‘exportdata’ method.
When I choose an export type of CSV or JSON, any fields with data that contain(s) quotation mark(s) is not exported with the quotes escaped, so it is producing invalid CSV and JSON exports. CSV example:
“ID”, “Date”,”Time”,”Event”
“1026”, “01/13/2015”,”Username “admin” logged in successfully”(Notice ‘admin’ has unescaped quotes around it). This seems to be a bug. The same issue occurs with a JSON export – invalid structure due to lack of escaping. Now, in this example, I could fix it by changing the double-quotes to single-quotes, however, I have data that is encoded as JSON in one of the fields and contains (valid) quotation marks. It would really be nice if I could export data containing double-quotes.
Is there a quick-and-easy way to fix this?
Thank you,
DanielHi Daniel,
No, there’s no API for changing the export logic and put escaping. Probably you can export the data to a variable by not passing file name parameter and parse it on your own.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comI’ve just discovered this. Also, if there are \r\n in any of the cells it also fails to treat that properly.
This is a bug –> It’s producing an invalid CSV format.
When will it be fixed?
As far as I can see it’s a one line fix in jqxdata.export.js
function prepareData(data, dataOptions) {
if (dataOptions) {
var format = me.getFormat(dataOptions);
data = me.formatData(data, format.type, format.formatString, format.localization);
}
//**************************************************
// data = ‘”‘ + data + ‘”‘;
data = ‘”‘ + data.replace(/”/g,'””‘).replace(/\r\n/g,’\r’) + ‘”‘;
//**************************************************
return data;
};Why after 3+ years of the problem being known that simple fix still hasn’t been made – who knows. But I really don’t want to manage a codeset of simple fixes that you couldn’t be arsed to make – so please – fix it. Soon.
Have tested and it actually requires 2 changes to make a CSV file that will properly handle multi-line cells and save in a format that Excel can open (which is what most people use in the business world)
this.beginRow = function () { if ((rowIndex > 0) || (rowIndex == 0 && hasHeader)) { //************************************************** //file += '\n'; file += '\r\n'; //************************************************** } rowIndex++; };
function prepareData(data, dataOptions) { if (dataOptions) { var format = me.getFormat(dataOptions); data = me.formatData(data, format.type, format.formatString, format.localization); } //************************************************** // data = ‘”‘ + data + ‘”‘; data = ‘”‘ + data.replace(/”/g,'””‘).replace(/\r\n/g,’\n’) + ‘”‘; //************************************************** return data; };
Hi JQWidgets Team,
Do you have any plans of integrating this fix in your releases?
Until now for version v13.2 this bug still exists.Hi,
May you, please, update to the latest version and confirm whether the bug exists?
Best regards,
Svetoslav BorislavovjQWidgets Team
https://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.