• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

open excel file

 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How would I open the existing xsl file in JSP page or java?

I have done like this, but I don't see the contents of the ATR.xls. This file is located in C: drive.



response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment; filename= c:\\ATR.xls");


Can anyone tell what is the wrong in this code please?

Thanks
[ March 07, 2008: Message edited by: lakshmi manepally ]
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lakshmi,

The response.setHeader(..) doesn't do what you think it does. It does not attach the file to your response. It merely gives a name to your response.
You can read more about this here.

So additionally, you will have to read the excel file content, and stream that content to your response.

Best to do it with a Servlet. A jsp will add additional content to your stream - and that spoils the output.

Regards, Jan

(There is a separate JSP and Servlets forum on the Ranch)
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want only in jsp
 
Jan Cumps
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by lakshmi manepally:
I want only in jsp


Ok. Please read Stefan Evans' remark, the latest post on 29 november 2007 in this thread.

Regards, Jan
 
author & internet detective
Posts: 41933
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by lakshmi manepally:
I want only in jsp


Why? This makes your task significantly harder. Is there a reason for the JSP only requirement?
 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have gone through this program.
CODE]

try{
String ROOT_PATH = "C:\\tomcat\\webapps\\SnetReport\\REPORT\\"; FileInputStream in = new FileInputStream(ROOT_PATH + sFilename);
response.setContentType("application/xls"); response.setHeader("Content-Disposition", "attachment;filename=\"Report.xls\"");

int i; while ((i=in.read()) != -1)
{ out.write(i); }
in.close();
out.close();}catch(Exception e)

System.out.println("...error while loading: "+e.toString());}
[/CODE]

In the above code what is the sFileName
 
reply
    Bookmark Topic Watch Topic
  • New Topic