Open jkarttunen opened 10 years ago
Hi, why can't you use the "field-separator" attribute ?
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=,***
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 ?
@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
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..
Is there a way to export to an excel file (XLS or XLSX or otherwise) that has a similar interface to ng-csv?
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 notifications@github.com 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.
@davorpeic How did you add sep=, to first line?
@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..
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.
@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.
I had the same problem and solved this by adding a decimal-separator option; #77
Great, thanks! I'll have this closed once i've viewed #77
Just to enrich the conversation: https://stackoverflow.com/questions/10140999/csv-with-comma-or-semicolon
I have two problems with sep=,
Any idea to solve utf8 issue ?!
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