File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes General Computing and the fly likes JSP-EXCEL save defualt in .xls extension, open excel with in the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "JSP-EXCEL save defualt in .xls extension, open excel with in the browser" Watch "JSP-EXCEL save defualt in .xls extension, open excel with in the browser" New topic
Author

JSP-EXCEL save defualt in .xls extension, open excel with in the browser

ajay halmandge
Greenhorn

Joined: Oct 04, 2005
Posts: 7
-----
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment;filename=\"" + date_num + "\"");
.....
here date_num variable is for name of file in terms of date string.

I am working with Mysql,jsp,excel,linux.The above code line works pefectly.And i am able to see the data in Excel sheet. But the problem is that ,The excel file is opening in the name like http://www.localhost/21.jsp?list=20051002?list=

When user wants to save the excel file,default will be (html*,htm*)...But the requirement is to save in .xls extension (Note: user should not go on to edit filename while saving it)

Point: I am not downloading the file from server, infact it is generated dynamically .... And displaying in the excel.

One more thing : I want to open excel file with in the explorer browser
any Idea. I have tried by replacing attachment with inline...but didnt work.

Help Me!!!

Thanks in Advance
Gerhard K Greyvenstein
Greenhorn

Joined: Nov 01, 2005
Posts: 1
/*<---- start ---->*/
response.setHeader("Content-Disposition","attachment;filename=report.xls") ;
/*<---- end ---->*/

Change the above 'attachement' to 'inline' to produce

/*<---- start ---->*/
response.setHeader("Content-Disposition","inline;filename=report.xls") ;
/*<---- end ---->*/

This will show the report your generating within the web-page, although it is still just an Excel instance running within the web-page.

joseph prabhu
Ranch Hand

Joined: Feb 26, 2008
Posts: 162


The above code(report.jsp) is working fine when this is given in the action attribute of input.jsp.

when i try to include this report.jsp in some other jsp (output.jsp) excel file is not opening

what i have to do
srikanth nallapaneni
Greenhorn

Joined: Jun 08, 2009
Posts: 4
Is there any suggestion if we would like download the data into a standard Template
Dima Chornyi
Greenhorn

Joined: Mar 25, 2009
Posts: 9
First, you need something like this in your code:

Second, in explorer you go to Tools->Folder options->Data types->[.xls/.xlsx]->Advanced-> check "Open in same window" (Exact text may be different as i am on German Windows). This can also be set trough registry.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

arun sherwal,
Your post was moved to a new topic.
Let's try the Struts forum...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP-EXCEL save defualt in .xls extension, open excel with in the browser
 
Similar Threads
No one is there to solve excel problem????
opening the excel sheet from servlet
Export to excel question
Saving JSP output to a File with extension .xls
Export to Excel via a servlet with POI not working under internet explorer 6