aspose file tools*
The moose likes Other Open Source Projects and the fly likes How to give seperate file names for xls reports genetared usinf POI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "How to give seperate file names for xls reports genetared usinf POI" Watch "How to give seperate file names for xls reports genetared usinf POI" New topic
Author

How to give seperate file names for xls reports genetared usinf POI

amitava guha
Greenhorn

Joined: Jul 30, 2009
Posts: 7
Hi
I am using apache POI to generate reports in excel format which will be displayed in Internet Explorer window.
I am creating the excel file in a folder and reading that from my action page and displaying it in IE using response.setContentType("application/vnd.ms-excel");

Because of this every time I generate a report the name of the file is shown as Report.do for all reports. How can I set the file name?

Any help will be appreciated.
Thanks
Amit
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41818
    
  62
Are you setting a Content-Disposition header? Something like:

response.setHeader("Content-Disposition", "inline; filename=\"spreadsheet.xls\"");


Ping & DNS - my free Android networking tools app
amitava guha
Greenhorn

Joined: Jul 30, 2009
Posts: 7
Thanks for your reply.
Although I am setting the header that you have given

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "inline; filename=\"spreadsheet.xls\"");

Still I am getting the file name as "Copy of SAOReport.do" when trying to save it. The below address is showing in the IE address bar.

http://127.0.0.1:9080/ServicePlatformWeb/SAOReport.do

Is there a solution for this?
amitava guha
Greenhorn

Joined: Jul 30, 2009
Posts: 7
Hi

After setting the header as

response.setHeader("Content-Disposition","attachment; filename="+reportEntity.getReportName());

I am getting a popup saying download file which has option to Open/Save/Cancel. If I save the file then it get saved with the report name [reportEntity.getReportName()] but if I click Open then it is opening in IE and then if I try to do save as, it shows "Copy of Reports.do" as file name.

Is there any way this can be resolved?

Regards,
Amit.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to give seperate file names for xls reports genetared usinf POI