How to force Excel to open CSV files with data arranged in columns
I generate a CSV file with an extension .csv in which every piece of data in one line is separated with a comma:
1,2,3,4
1,2,3,4
The file is sent via email and I want that when a customer opens it she sees data arranged into columns.
Is such thing possible?
PS: I may freely change the delimeter.
Use tab instead of comma. And if that doesn't work, give your tab-delimited file an xls extension.
Sadly, Microsoft decided to use different separators in different localizations for CSV
(which stands for Comma Separated Values). That's especially annoying when working on an international basis.
If it's only to get the csv
readable at every system, there's an undocumented trick: in the first line write SEP=;
. This line tells EXCEL to use ;
as separator (in fact you can use any (single) character (;,|@#'
...))
NOTE: this line is just part of the csv
file itself. It will not become part of the spreadsheet in EXCEL. that means, it will not be shown and it will not be written, no matter which format you define to write or export.
NOTE: this is Microsoft EXCEL specific. Other spreadsheet programs may not understand this.