File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 41180
    
  45
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.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to give seperate file names for xls reports genetared usinf POI
 
Similar Threads
Saving data to Excel files
Excel Generation using POI
$ symbol not displayed properly in excel
Excel Generation using POI
Generate Filter Cells For Excel Sheets Using POI HSSF