I had a problem at work which I solved, but that raised me another question.
I wanted to export a page to excel, so I used this:


It worked but while I was searching for an answer I found 3 possible content types for the excel:

> application/vnd.ms-excel
> application/x-msexcel
> application/ms-excel

As well as this: http://stason.org/TULARC/business/spreadsheets/10-19-What-is-the-correct-registered-MIME-Content-Type-for.html

What is the correct, registered MIME Content-Type for Excel files?


see http://www.isi.edu/in-notes/iana/assignments/media-types/application/vnd.ms-excel

so don't use any of these:

Why only this: application/vnd.ms-excel is correct and those are not:
> application/x-msexcel
> application/ms-excel

kvprajapati commented: Great! +6

Recommended Answers

All 6 Replies

That's a job for a servlet, not a jsp.

The correct content type is the one registered with bodies like the w3c, not one that someone cooked up in his head because he thought it "sounds kewl".

That's a job for a servlet, not a jsp.

The correct content type is the one registered with bodies like the w3c, not one that someone cooked up in his head because he thought it "sounds kewl".

I used this and it worked

But I found in various sites other options as well:
Search for "excel"

But the quote from the article I posted said that only the one I used is the correct one.

So is there any difference between the one I used and the others, or it is like you said, someone came up with these names and they never worked?

RFC - http://www.isi.edu/in-notes/rfc2045.txt

Beyond this syntax, the only syntactic constraint on the definition
of subtype names is the desire that their uses must not conflict.
That is, it would be undesirable to have two different communities
using "Content-Type: application/foobar" to mean two different
things. The process of defining new media subtypes, then, is not
intended to be a mechanism for imposing restrictions, but simply a
mechanism for publicizing their definition and usage. There are,
therefore, two acceptable mechanisms for defining new media subtypes:

(1) Private values (starting with "X-") may be defined
bilaterally between two cooperating agents without
outside registration or standardization. Such values
cannot be registered or standardized.

(2) New standard values should be registered with IANA as
described in RFC 2048.

registered iana media types (and a link to a registration form)

I also found that link but I cannot open it

Just a small addition to this issue.
We have been having some problems in displaying Greek character at the excel generated and after some tests it was discovered that in order to do that this tag also needed to be added at the <head> of the page.
Without it, it only displayed English characters:

<%@ page contentType="charset=iso-8859-7"%>


        [B]<meta http-equiv="Content-Type" content="application/vnd.ms-excel;charset=UTF-8" />[/B]

In case someone else is having the same problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.