Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

excel sheets

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp file and a href link which points to a javascript function.
In the javascript functio I am trying to open an excel sheet stored in the server.

But it opens in IE, doesnt open in application excel, doesnt do a download either.

How can I do it ?
Right now I am just doing window.open("/....xls")

My mime type has xls settings.

Thanks
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to investigate setting the content-disposition header to identify the file as an "attachment". Search this (and perhaps the Servlet or JSP) forum for details.
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.

I should say I tried to create a servlet also and do this in the doPost method. Then I get junk charachers in the o/p. Excel dont open also.. Then I was trying javascript. Still no luck..

String fileName ="C:/Test.xls";
File targetFile = new File(fileName);

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename="+fileName+"");

Thanks,
[ July 06, 2007: Message edited by: Atul Mishra ]
 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll move this to the Servlets forum.
 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why a POST? Fetches should be done with a GET.

Regardless, how are you reading and streaming the bytes to the output stream?
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic