Open Jsp in Excel
I am trying to open JSP file in excel and I get the following message: excel cannot open the file because the file format or file extension is not valid.Verify that the file has not been corrupted and that the file extension matches the format of the file. By the way, I have MS excel 2007.
here's my method:
response.setContentType("application/vnd.ms-excel");
response.setHeader("content-disposition","attachment; filename=Report.xlsx");
Also, I have add the following to web.xml:
<mime-mapping>
<extension>xlsx</extension>
<mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>
# 2
Try this.Create another file Report.xls in previous office packages. Its seems you're trying to open a .xlsx file in the MS Office envireonment which doesn't support this file extension. To my understanding the *.xlsx *.docx etc are new file extentions for MS Office( as for example office package which comes with windows vista, or MS office 2007).
You can't open such a file extension like *.xlsx in previous office packages if you did not set the compatibility issues.
hope it helps
aiExa at 2007-7-12 18:07:04 >

# 4
Hi aiEx,
Thank you for replying. I am not sure what you mean by "setting up the compatibility issue". I have added the following to web.xml:
<mime-mapping>
<extension>xlsx</extension>
<mime-type>application/vnd.ms-excel</mime-type>
</mime-mapping>
Also, I have changed the file extension from xlsx to xls, it didn't work either. Any other thoughs.
Thank you again