heffingtond Posted April 26, 2007 Share Posted April 26, 2007 Hello-I am attempting to redirect to an xls file that gets created by my web application. Instead of opening the file with Excel, the file is being displayed as raw text within a browser window. If, on the other hand, I open the same xls file by double clicking it in Windows Explorer, the file opens correctly in Excel. I have included the following code prior to the creation and redirect to the file:resp.setContentType("application/vnd.ms-excel"); The same redirect process is working for the PDF and html versions of the same report. Is there an additional step necessary to get the client to open an Excel file with Excel when a redirect id done on the server? Thanks,David. Link to comment Share on other sites More sharing options...
heffingtond Posted May 1, 2007 Author Share Posted May 1, 2007 I got this to work by defining the mime type in the web.xml: <mime-mapping> <extension>xls</extension> <mime-type>application/vnd.ms-excel</mime-type> </mime-mapping> Link to comment Share on other sites More sharing options...
edikk Posted May 2, 2007 Share Posted May 2, 2007 Try this:response.setContentType("application/xls");It work well for me.Edik Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now