GeeCON Prague 2014*
The moose likes Servlets and the fly likes PROJECT HELP USING SERVLETS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "PROJECT HELP USING SERVLETS" Watch "PROJECT HELP USING SERVLETS" New topic
Author

PROJECT HELP USING SERVLETS

shabbir zakir
Ranch Hand

Joined: Nov 12, 2000
Posts: 183
hi!
HTML documents cannot be imported directly from the web into the spreadsheet program usually they must be downloaded as files and then imported.
Can we directly open html documents in a spreadsheet programme such as microsoftexcel.Can we use servlets in this.Can anyone explain me how should i proceed.
Thanks in advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16103
    
  21

Depending on the version of MS-Office you're using, Excel can read html, though what it did with the results didn't exactly excite me.
A more useful approach often used is to have the servlet/jsp output a CSV file, which Excel will happily parse into a table.
A good example of this in action is available at http://quote.yahoo.com/q?s=msft&d=v1 - click on the "Download spreadsheet" link. A JSP that sets the appropriate MIME content type (application/x-msexcel is what I have listed -- or maybe application/vnd.ms-excel) can cause Excel to be brought up within Internet Explorer. Or, launched, if they're using Netscape.


Customer surveys are for companies who didn't pay proper attention to begin with.
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi there,
I have gotten this task to work, in terms of having my servlet set the content type and write to an excel spreadsheet, unfortunately when Excel comes up, it doesn't seem to recognize that my output is in csv format, so it puts all of the data per row in the first cell, for example, a row such as
1,2,3
doesn't get broken up into 3 cells, it is all put in the first cell as one string.
Any tips on how to get Excel to recoginze the comma seperators?
I am setting my content type using:
setContentType("application/vnd.ms-excel");
Thanks!
Kim
Senthil B Kumar
Ranch Hand

Joined: Feb 09, 2004
Posts: 140
Hi,

Try using the following Content Type

text/comma-separated-values

or try setting the Header instead of Content Type

response.setHeader("Content-Type", "text/comma-separated-values");


Work like you don't need the money. Love like you've never been hated. Dance like nobody's watching. Sing like nobody's listening. Live like it's Heaven on Earth.
Currently I Reside Here WEBlog
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you may also have to map the URI for the generated text to end in .xls depending on your browser, OS and Excel version.


42
 
GeeCON Prague 2014
 
subject: PROJECT HELP USING SERVLETS