It's not a secret anymore!*
The moose likes Servlets and the fly likes ms-excel mime type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "ms-excel mime type" Watch "ms-excel mime type" New topic
Author

ms-excel mime type

shiva shankar
Ranch Hand

Joined: Jun 10, 2001
Posts: 84
I am trying to export excel in browser

I am setting content type as




This works perfectly in Firefox but in IE it ends up opening in the browser itself as plain text with junk characters. Any suggestions would be helpful

thanks
Shiva

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Well everything looks fine to me. Did you try it in a different IE than your system. Maybe your IE is corrupt or something. And which version of IE are you using??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Getting Content-Types to work in IE is a bit of a black art! Windows doesn't rely solely on the Content-Type header to know what to do, it has an extra step called MIME sniffing whereby it interogates the first n bytes of the response and tries to guess what MIME type it is (see this for more). If you are on XP SP2 or higher you can turn this feature off and see if this is what is clouding the issue.

Assuming IE correctly honours the Content-Type, or correctly sniffs the MIME type it uses the registry key in HKEY_CLASSES_ROOT/MIME/Database/Content Type to map to the application to use. You could double check there to make sure your registry is not corrupt. Unfortunately this MIME database just contains keys to the classes that represent each MIME type so you will have to do more digging to find out what applciation is actually registered to handle a particular MIME type.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ujjwal soni
Ranch Hand

Joined: Mar 28, 2007
Posts: 403
Hi,

I was facing the same problem in IE in exporting powerpoint using POI in java. If you have multiple tab opened on the browser then the browser renders the content instead of opening it in ms office. I dont know which browser you use but, try installing IE 6. In IE 8 there are bit problems.


Cheers!!!
Ujjwal B Soni <baroda, gujarat, india> <+919909981973>
"Helping hands are better than praying lips......"
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

ujjwal soni wrote:Hi,

I was facing the same problem in IE in exporting powerpoint using POI in java. If you have multiple tab opened on the browser then the browser renders the content instead of opening it in ms office. I dont know which browser you use but, try installing IE 6. In IE 8 there are bit problems.



There are far fewer problems in IE8 than there are in IE6. Multiple tabs play no part. IE will not try to open in a browser window unless:
  • The content is something that is embeddable (e.g. a MS Office document)
  • It incorrectly sniffs the content and decides its something the browser can render (for example, an Outlook message might behave like this)

  • shiva shankar
    Ranch Hand

    Joined: Jun 10, 2001
    Posts: 84
    Thanks all. I got it resolved by having the mime type set into the response at first line instead of a few lines below.

    thanks
    Shiva

     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: ms-excel mime type
     
    Similar Threads
    Serving Excel Content
    how to detect MS excel using servlet?
    Problem with exporting data from JSP to excel sheet
    How to make an excel sheet rendered on browser read only?
    URL-Pattern, Internet Explorer and Flash Videos