Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bux on Dec 11, 2009 19:27
open dhtmlx forum
DhtmlXGrid - Export to CSV: failed csv file when field contains ',' character

I am having a problem when exporting grid content to CSV.

There are some fields that contains free text. Some of them contains ',' (comma) character. I noticed DhtmlXGrid component does not generate a CSV with quote-delimited text. It means that if I try to load the generated CSV, it will incur in errors, since the "extra" comma will make the program (used to load CSV) thinks that a new field should be created (instead of meaning a comma character).

Does DhtmlXGrid contain any method in order to prevent that ?

Thanks.
Answer posted by dhxSupport on Dec 14, 2009 05:49
You should change CSV delimiter:
mygrid.setCSVDelimiter("any_single_char");
Answer posted by Bux on Dec 14, 2009 08:20
Hi.

I'm aware of the setCSVDelimiter() method, but I was looking for something that would control the text fields.
E.g,:
DhtmlXGrid content:
Name | Age | Description
Steve | 19 | Likes pizza, skate and punk music.
John | 23 | Likes spending time watching TV series, movies and reading books.
Sarah | 27 | Dislikes noise environments, but likes live rock concerts.

Expected CSV output would be:
Name,Age,Description
Steve,19,"Likes pizza, skate and punk music."
John,23,"Likes spending time watching TV series, movies and reading books."
Sarah,27,"Dislikes noise environments, but likes live rock concerts."

Do we have this functionality ?
I did not want to use a different delimiter character since comma is the default one.

Thanks.