I've come across the problem where Excel will not play nice with UTF-8 encoded CSV files. See this related question on Stack Overflow.
I've followed the solution of exporting as UTF-16, however it seems that with UTF-16, the comma character doesn't work as a delimiter, only the tab character.
However I can't find anywhere what the correct filename and mime-type should be for tab-delimited files. I found somewhere stating that it was application/vnd.ms-excel and xls. This works ok for Excel 2003 but 2007 does not approve.
So what should it be?
You could use text/xml, but the correct MIME type would be application/rss+xml. Show activity on this post. text/xml is the only correct answer. Mime types are a registration based system.
What is MIME ( Multi-Purpose Internet Mail Extensions ) What is MIME? The MIME stands for Multi-Purpose Internet Mail Extensions. As the name indicates, it is an extension to the Internet email protocol that allows it’s users to exchange different kinds of data files over the Internet such as images, audio, and video.
Nothing magical is happening - you are indeed just generating HTML; the MIME type is merely there to indicate which application should handle the data. The operating system and browser work together on that front, so when the browser sees a response with that MIME type, it opens Excel for you.
You could use text/xml, but the correct MIME type would be application/rss+xml. application/xml is prefered over text/xml because XML doesn't follow normal text content encoding rules. It can embed its encoding in its data, which will cause problems if proxies try to blindly transcode the text.
For tab-delimited files, http://www.rfc-editor.org/rfc/rfc4180.txt mentions 'text/tab-separated-values'.
That format is (sparsely) described at http://www.iana.org/assignments/media-types/text/tab-separated-values.
More info can be found at : http://www.cs.tut.fi/~jkorpela/TSV.html
I hope this helps?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With