Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

export CVS on client side with non CVS character

$
0
0
I'm facing issues when I try to export tables in CSV format on client-side (no call to the server's datasources, this is mandatory for my use case). Indeed, some fields in these tables contains "\n" character (carriage return). For readibility, I can't remove these characters in the table, but during export, I've noticed that there is no escaping for such characters from smartclient API.
I've produced a piece a code that"s working fine, but for thousands of lines in a table, it can be acceptable to have a double loop just to remove non CSV character.
I've seen nothing in smartclient documentation ( DataSourceField and FormatString in particular seems dedicated to Date and Number formatting).

Code:

//aInFieldTitles contains the list of attributes to export
lListToExport_a = this.getSelectedRecords();
for (i = 0; i < lListToExport.length; i++) {
  lexportedObject_a = lListToExport.get(j);
  for (i = 0; i < aInFieldTitles.length; i++) {
      lFieldName = aInFieldTitles.get(i);
      lValue = lexportedObject_a[lFieldName];
      if ((typeof lValue) === "string")) {
          lListToExport_a[lFieldName] = lValue.replace(/[\n]/gi, " ");
      }
  }
}
lRequestProperties.exportData = lListToExport_a;
lRequestProperties.exportHeader = "\uFEFF";
lRequestProperties.exportFilename = this.fileNameExport;
lRequestProperties.exportAs = "csv";
lRequestProperties.exportDisplay = this.showExportInWindow_b ? "window" : "download";
this.exportClientData(lRequestProperties);

Is there any other solutions to escape non CSV characters during export?

I'm using smarclient 9.1_20_7.

Viewing all articles
Browse latest Browse all 4756

Trending Articles