What to set as mimetype for CSV files to open in spreadsheet applications

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.

You can define the separator in first line of your CSV file using sep so that it appears as follows:

sep=;

See also @FilipNavara’s answer.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)