content-type for MS Office XML

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
dorferm
Posts: 6
Joined: September 9th, 2010, 4:30 am
Location: Austria

content-type for MS Office XML

Post by dorferm »

Hej all, hope you can help me.

I've got a php script which returns an excel 2003 xml document. content-disposition is set to 'attachment; filename="<filename>.xml"'
If I set the content-type to 'application/vnd.ms-excel' firefox shows the opening dialog and adds .xls to the filename when I choose Open with Microsoft Office Excel (in the dowload window it's shown as <filename>.xml.xls). Excel then displays an error that the file content and file extension mismatch.
If I set the content-type to 'application/xml' firefox doesn't recognize the file as Excel XML, but as plain XML, and therefore you can't open the file with Excel right away.

So the question is, what headers do I have to send, so that firefox lets me open the file in Excel without any errors?

Thanks in advance

P.S. Sorry if this is the wrong subforum
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: content-type for MS Office XML

Post by trolly »

Even MS has nothing better to offer: http://support.microsoft.com/kb/288130
Is it possible to choose "any file" as file type during saving? This prevents adding another extension.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
dorferm
Posts: 6
Joined: September 9th, 2010, 4:30 am
Location: Austria

Re: content-type for MS Office XML

Post by dorferm »

Thank you for your response!

When choosing to save the file, the xls file extension is not added. It's only added when I try to open the file.

Image
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: content-type for MS Office XML

Post by trolly »

As far as i can see the extension is stored in mimetypes.rdf with xls as extension for application/vnd.ms-excel . If it is just for you you might try to edit the file to have xls as extension.
http://kb.mozillazine.org/MimeTypes.rdf

The problem seems to be that now two different file types can be sent with the same content-type. MS should use a different one.
You can also define your own content type e.g. application/vnd.ms-excel-xml and add the correct entry to the above mentioned file.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: content-type for MS Office XML

Post by jscher2000 »

I wonder whether it is a "bug" that the application adds a file extension? I'm sure that was intended to work around the problem that some applications choke in the absence of an expected file extension, but here it is dysfunctional. The problem for the coders is, to add or not to add, how would they know in a particular case?

My Tools > Options... > Applications for XML Files is set to "Always Ask", which should in theory give me the option to open it in Excel if I like. Yes, this is an extra step, but...
dtobias
Posts: 2098
Joined: November 9th, 2002, 3:35 pm
Location: Boca Raton, FL
Contact:

Re: content-type for MS Office XML

Post by dtobias »

I don't think you're supposed to define your own "application/vnd.ms-" MIME types; only Microsoft is supposed to use this prefix, and they have to submit their proposed vendor-specific types through the proper standards process. Types starting with "application/x-" are up for grabs, however.
Dan's Web Tips: http://webtips.dan.info/
Dan's Domain Site: http://domains.dan.info/
Dan's Mail Format Site: http://mailformat.dan.info/
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: content-type for MS Office XML

Post by trolly »

If it is for his/her own purpose he/she can do it. But it wont work anywhere else.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
dorferm
Posts: 6
Joined: September 9th, 2010, 4:30 am
Location: Austria

Re: content-type for MS Office XML

Post by dorferm »

So if I understand you correctly there is no separate content-type for MS Excel XMLs. To attack my problem from a different site, is it possible to tell firefox 'Don't add a file extension, it's ok the way it is.'?
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: content-type for MS Office XML

Post by trolly »

Hmmm, a hack would be to use an empty file extension in mimetypes.rdf. But no guarantee that it works.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
User avatar
Gingerbread Man
Posts: 7735
Joined: January 30th, 2007, 10:55 am

Re: content-type for MS Office XML

Post by Gingerbread Man »

I don't see what the problem is if you send content-type: application/xml. If you also send content-disposition: attachment, then Firefox should always display the download dialog window. Even checking "Do this automatically..." would be ignored. Then, if the program you want to use isn't listed next to Open with, open the drop-down menu to select it.

Image
dorferm
Posts: 6
Joined: September 9th, 2010, 4:30 am
Location: Austria

Re: content-type for MS Office XML

Post by dorferm »

Sure, really user friendly. Everytime one is going to download a xml file he has to choose which program he wants to use to open the file. That's far worse than clicking away the error message in excel everytime.

BTW that solution won't work in IE.
User avatar
Gingerbread Man
Posts: 7735
Joined: January 30th, 2007, 10:55 am

Re: content-type for MS Office XML

Post by Gingerbread Man »

dorferm wrote:Everytime one is going to download a xml file he has to choose which program he wants to use to open the file.

Only once. Whatever program you've last selected remains the default selection for Open with, so all you have to do is press Enter or the OK button.
dorferm
Posts: 6
Joined: September 9th, 2010, 4:30 am
Location: Austria

Re: content-type for MS Office XML

Post by dorferm »

Gingerbread Man wrote:
dorferm wrote:Everytime one is going to download a xml file he has to choose which program he wants to use to open the file.

Only once. Whatever program you've last selected remains the default selection for Open with, so all you have to do is press Enter or the OK button.

And which content-type shall I sent when generating Word XML? Again application/xml? So the user has to know which program he wants to use, cause the content-type is giving no hint.

The fault is clearly at MS for using different filetypes / fileextensions within one content-type. But I don't see why FF is adding an extension when a valid one is used?
User avatar
trolly
Moderator
Posts: 39851
Joined: August 22nd, 2005, 7:25 am

Re: content-type for MS Office XML

Post by trolly »

Probably because the already added file extension matches the one in the content type description.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
User avatar
Gingerbread Man
Posts: 7735
Joined: January 30th, 2007, 10:55 am

Re: content-type for MS Office XML

Post by Gingerbread Man »

Unless you can save your files with an application-specific extension like .docx, I have no other suggestions. XML is a common file extension that is not unique to Microsoft Excel or even Microsoft Office, and there don't seem to be any MIME types for Microsoft Office files with an XML extension.

The relevant bug report seems to be Bug 381936 - Content-Disposition filename not obeyed when choosing to "Open" a file whose extension doesn't match Content-Type.
Post Reply