• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-----
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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*<---- 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.

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any suggestion if we would like download the data into a standard Template
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 24467
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
arun sherwal,
Your post was moved to a new topic.
Let's try the Struts forum...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!