Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best mime-type and extension to use when exporting tab delimited?

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?

like image 429
EvilPuppetMaster Avatar asked Nov 05 '08 03:11

EvilPuppetMaster


People also ask

What is the correct MIME type for application?

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 ( 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.

How does mime work in Excel?

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.

Can I use text/xml instead of MIME type?

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.


1 Answers

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?

like image 52
PatrickvL Avatar answered Oct 05 '22 22:10

PatrickvL