Vikas,

Thinking on this overnight, I realized my answer was a bit simplistic on just setting 
the response's content type, e.g. response.setContentType( "application/vnd.ms-excel" 
);.

This actually does not write anything in "Excel format"; the output is whatever your 
JSP is producing and it sounds like it is HTML. If you need "Excel format," Bill 
Barker's post offers an excellent idea using POI (jakarta.apache.org/poi). Your HTML 
output is still readable by Excel. And you could theoretically send this HTML page via 
eMail--tar'd, zip'd or archived to prevent the user's HTML-capable browser from 
reading it first of course. :)

response.setContentType( String s ) will simply queue the browser/user-agent to open a 
helper application per the user preferences. So if the user is a hard-core 
WordPerfect/Quattro wizard, it may not work as expected (not to disparage Corel fans, 
only used as an example. Of course betting on client side support is risky anyway. 
Unless your environment is homogenous and allows you a "guarantee" of support.)

Hope this helps,
Tim


> -----Original Message-----
> From: Stone, Timothy 
> Sent: Tuesday, November 12, 2002 14:23
> To: Tomcat Users List
> Subject: RE: OFF_TOPIC: How to convert JSP page into an EXCEL format
> 
> 
> Vikas Nagpal,
> 
> Hmmm... someone correct me if I'm wrong, but can't you do 
> this by setting the MIME type 
> javax.servlet.ServletResponse.setContentType(String s)?
> 
> ...
> response.setContentType("application/vnd.ms-excel");
> ...
> 
> One could generate the response to a file 
> (myExcelResponse.xls) and mail it to an end-user at that 
> point. This is off-topic however.
> 
> To answer the specific questions in a implementation agnostic manner:
> 
> 1. Can somebody tell me what should i do so that i can 
> convert columns of my JSP page into columns of my EXCEL worksheet?
> 
> This is automagically done in more recent versions of Excel 
> where HTML tables are correctly converted (if you trust Micros~1).
> 
> 2. How can I sort so as to start from alphabets?
> This is more general Java question. A simple array could use 
> one of static Arrays.sort() methods; it sounds as if you are 
> sorting strings in the English language, Arrays.sort( 
> Object[] o, Comparator c) might be handy. You can 
> implementing the Comparator as an anonymous inner class even. 
> More sophiticated methods in the java.util package could do 
> this as well, especially if you are dealing with I18N environments.
> 
> Hope this helps,
> Tim
> 
> 
> 
> > -----Original Message-----
> > From: Nagpal, Vikas [mailto:vinagpal@;utmb.edu]
> > Sent: Tuesday, November 12, 2002 13:57
> > To: '[EMAIL PROTECTED]'
> > Subject: OFF_TOPIC: How to convert JSP page into an EXCEL format
> > 
> > 
> > Hi EveryBody,
> > 
> > 1) I have a JSP page which contains the TABLE. Now i want 
> to send this
> > JSP page as an  EXCEL email attachment so that as soon as 
> people opens
> > this attachment they can view there JSP page as an EXCEL 
> worksheet. I
> > have downloaded JINTEGRA.JAR from the web. I have put this package
> > into my classpath. Can somebody tell me what should i do so 
> that i can
> > convert columns of my JSP page into columns of my EXCEL worksheet.
> > 
> > 2) I have been trying to sort the elements of an array but I want to
> > ignore any SPECIAL CHARACTERS that preceeds alphabets. In  most of
> > these elements I have double quotes as my special charcter. 
> How can I
> > sort so as to start from alphabets.
> > 
> > Thanks,
> > With regards,
> > Vikas Nagpal.
> > 
> > --
> > To unsubscribe, e-mail:   
> > <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
> > For additional commands, e-mail: 
> > <mailto:tomcat-user-help@;jakarta.apache.org>
> > 
> > 
> 
> --
> To unsubscribe, e-mail:   
<mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@;jakarta.apache.org>

Reply via email to