Thanks for the reply. If I use, response.addHeader("Content-Disposition", "attachment; filename=\""+fileName+"\""); I can open the file in a new window but not in the current window. The file opened in the new window will have the name with a (1) at the end as the filename (say filename(1)). Is there a way to fix this? When I download the file and hit "save" button on the "open-save-cancel" dialog it saves the file with correct name. If I hit "open" button and use File>Save As... I am having the problem.
Has anyone resolved this issue of the naming convention? I am facing a similar situation now.
Here is my code in JSP: <%@ page contentType="application/vnd.ms-excel" %> <% response.setHeader("Content-Disposition", "attachment; filename=\"abc.xls\""); %>
When this code is executed, an open save dialog box opens up. If I hit save, it saves my file correctly as "abc.xls" BUT if I hit open, it opens the excel file with name "abc.xls" and the sheet name is ".xls]abc". Due to this, when user hits save on the excel sheet, it fails saying there shouldn't be any special characters like "[", "]". User has to now rename the file to save it (which I dont want).
This issue is only with IE. I'm using IE6 version currently. Firefox opens and saves it correctly.
If anyone can throw some light as to what I should do to resolve this and have the file name be correct as specified with the trailing numbers ans brackets and not have the user to rename the file and then save, it'll be great!