Kai
Kai

Reputation: 147

Why does my csv file open in a browser window and not in Excel - only in Safari

Is there something special I need to know to get my csv file to open automatically in Excel when downloading with Safari (5.1)? At the moment it opens in a browser window, which doesn't happen in any other major browser, so I'm not sure if it's a browser setting or a proper bug that I need to fix.

I'm adding headers like so:

Response.AddHeader("content-disposition:", "attachment;filename=exportglossary.csv");
Response.ContentType = "text/csv";

I have had a brief look through the browser settings in Safari and can't see anything that looks to me like it would obviously fix this.

I have seen that I can add:

header("Content-type: application/vnd.ms-excel")

instead of text/csv, but as it works in all other browsers I would rather not change it.

Thanks :)

Upvotes: 4

Views: 8138

Answers (1)

Sima
Sima

Reputation: 180

It's definitly because of Content-Type. I used to have the same problem. using this solved my problem

response.setHeader("Content-Type","application/ms-excel");

and it's work perfectly fine in all browsers

Upvotes: 4

Related Questions