ng-csv icon indicating copy to clipboard operation
ng-csv copied to clipboard

European Excel wants Semicolon-Separated-Files.

Open jkarttunen opened this issue 10 years ago • 15 comments

Thanks for very helpful little project!

I just ran into Excel not opening the CSV file, bur displaying it as plain text. Turns out that european version of Excel want Comma-Separated-Files to be Semicolon-Separated-Files instead. 0_o

Maybe we can add as default or as an option 'sep=,' to the first line of the file to fix this thing.

See http://kb.paessler.com/en/topic/2293-i-have-trouble-opening-csv-files-with-microsoft-excel-is-there-a-quick-way-to-fix-this

jkarttunen avatar May 22 '14 09:05 jkarttunen

Hi, why can't you use the "field-separator" attribute ?

asafdav avatar May 22 '14 21:05 asafdav

Because then excel would not open the file properly (without import) with my US users. So I don't want to change the field separator, just make the excel understand what the field separator is, regardless of some stupid localization differences. What seems to fix excel default behavior when opening file is adding that separator to the top of the file with sep=,*

jkarttunen avatar May 23 '14 08:05 jkarttunen

Your solution is Excel specific and I can't see any reference to it in the CSV spec, therefore we can't add just like that, it might break things for other users.

We can add an optional attribute for that, sounds good ?

asafdav avatar May 24 '14 09:05 asafdav

@jkarttunen You can always show a different ng-cvs tag for each user group. Just check their locale on an ng-if (or ng-switch) and set a different field-separator property for each one as noted by @asafdav

andion avatar May 28 '14 14:05 andion

I just toped to this issue also, I'm try opening my csv in excel with spanish locale and it doesn't detect comma, I just hate M$ product in general :)

My workaround: I added sep=, to the first line because I'm exporting raw data and I don't mind users in 'non excel' apps see that first line.. it is not visible in excel thou..

davorpeic avatar Jun 19 '14 00:06 davorpeic

Is there a way to export to an excel file (XLS or XLSX or otherwise) that has a similar interface to ng-csv?

pastafaria avatar Jun 19 '14 01:06 pastafaria

I plan to add XLSX support to this directive, any help from you guys would be highly appreciated !

On Thu, Jun 19, 2014 at 4:00 AM, pastafaria [email protected] wrote:

Is there a way to export to an excel file (XLS or XLSX or otherwise) that has a similar interface to ng-csv?

— Reply to this email directly or view it on GitHub https://github.com/asafdav/ng-csv/issues/28#issuecomment-46513062.

asafdav avatar Jun 24 '14 21:06 asafdav

@davorpeic How did you add sep=, to first line?

jkarttunen avatar Aug 21 '14 07:08 jkarttunen

@jkarttunen well, you have several ways, first is avoid using built-in header and build your own, so you would create your JSON file in this order, first push is a sep=, then is header and then is everything else.

I'm working with CSV service all of my logic is behind and not on the front end as my JSON is generated by the app.

In my case, I'm encoding everything to base64 before sending it by email, so I'm adding sep=, just the moment before I send it, that way you can use built-in header creation as usual.

// Using $base64 service to encode
CSV.stringify(intervalJson, options).then(function(result){
    intervals = $base64.encode('sep=,\n' + result);
});

But it should work if you just put together those values without the encoding..

davorpeic avatar Aug 21 '14 11:08 davorpeic

Just used $scope.getTableHeader = function() { return ['sep=,']; };

and

     csv.unshift([["Name"], ["Description"], ["id"]]);
     return csv;

in $scope.getTable to get headers. Seems to work fine.

jkarttunen avatar Aug 28 '14 07:08 jkarttunen

@andion It would be flaky to deduce excel locale/installation from locale at web browser. And i would prefer my comma-separated columns separated by commas.

jkarttunen avatar Oct 07 '14 14:10 jkarttunen

I had the same problem and solved this by adding a decimal-separator option; #77

vstene avatar Jan 02 '15 13:01 vstene

Great, thanks! I'll have this closed once i've viewed #77

jkarttunen avatar Feb 23 '15 21:02 jkarttunen

Just to enrich the conversation: https://stackoverflow.com/questions/10140999/csv-with-comma-or-semicolon

gaia avatar Jul 10 '15 22:07 gaia

I have two problems with sep=,

  1. UTF8 encoding not detected by excel anymore! (even with DOM)
  2. Its only support in excel and not officially support in all CSV parser!

Any idea to solve utf8 issue ?!

AliMD avatar Dec 24 '17 13:12 AliMD