tags:

views:

588

answers:

1

My application lets user download their data as csv files. These are supposed to open in spreadsheet applications. On a linux system, I get prompted correctly to open with OpenOffice. But some of my users complain that when they download the file, it doesnot open automatically excel, but asks them to choose the application. When they download a csv from someother site it opens correctly in excel.

I am setting:
mimetype: text/csv
content_disposition: attachment; filename.csv

+1  A: 

Try this:

Content-Type: text/csv; name="filename.csv"
Content-Disposition: attachment; filename="filename.csv"

In Windows browsers the MIME type is ignored after the file is downloaded and only file name extension is used to determine the corresponding application.

Also, making .CSV file open in Excel correctly is hard, because the default separator is taken from Regional settings on the machine on which the CSV is opened. Furthermore, the encoding is not determined from the file content or MIME type, so any non-ASCII characters are hard to get working.

Filip Navara
The choice of separator (, or ;) may be locale-dependent. I've never had trouble opening a comma-separated file.
pavium
@pavium: You are right, it is very probably the "List separator" in Regional settings..
Filip Navara