31

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?

Community
  • 1
  • 1
EvilPuppetMaster
  • 8,072
  • 10
  • 34
  • 31

2 Answers2

32

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?

Frew Schmidt
  • 9,364
  • 16
  • 64
  • 86
PatrickvL
  • 4,104
  • 2
  • 29
  • 45
  • 1
    Thanks, probably that is what it SHOULD work like, but excel has no understanding of that mime-type whatsoever. – EvilPuppetMaster Dec 03 '08 at 00:01
  • For CSVs, there's an optional `header=present` or `header=absent` component of the Content-type. This seems to be left out of the IANA page for *TSVs*. Can we include it for TSVs, does anyone know, or would doing that make the Content-type invalid? – Doin Jul 29 '19 at 01:57
0

Mime-type is an HTTP thing and only has meaning to the browser - it is not saved along with the file when you download a local copy. So Excel doesn't ever see your mime-type.

hristo
  • 25
  • 1
  • 2
    So it's just going off the file extension (at least initially) to check you are importing a supported file type? – Paul C Jan 16 '13 at 09:42
  • 6
    You are right about Excel not checking MIME types, however MIME not _just_ an HTTP thing at all. It is a _multipurpose, Internet_ thing which originated within email (which has nothing to do with HTTP whatsoever). These days, MIME types have many uses outside of the Internet, too. Linux OSes, for example, associate default programs to open files with MIME-types, (as opposed to the file-extension solution used by Windows). – daiscog Dec 03 '13 at 19:33