thank u very much for ur reply.
but thats what iu am doing.but i want it to open new window or do the thing
which i wrote u in previous mail;
this is my code
thanks in advance
raghava
On click of Export, I need to send the Selected Rows to MS Excel, I have th
following Method for doing this Job.
public void ExportDataToExcel(HttpServletRequest request,
HttpServletResponse response) throws IOException
{
try
{
File excel = new File("c:\\export.xls");
String args = request.getParameter("ExportData");
System.out.println("Inside try tuuutt");
StringBuffer sb = new StringBuffer();
// response.setContentType("application/vnd.ms-excel");
// PrintWriter pw = response.getWriter();
sb.append("<TABLE border=1 cellpadding=0
cellspacing=0 width=600 height=600>");
sb.append("<B>");
sb.append("<TR align=\"center\" bgcolor=\"aqua\">");
sb.append("<TD width=\"20\">Claim #</TD>");
sb.append("<TD width=\"150\">Sym</TD>");
sb.append("<TD width=\"150\">MJC</TD>");
sb.append("<TD width=\"30\">Trans Date</TD>");
sb.append("<TD width=\"150\">Err. Code</TD>");
sb.append("<TD width=\"30\">Policy #</TD>");
sb.append("<TD width=\"150\">Mod</TD>");
sb.append("<TD width=\"120\">AS/Co</TD>");
sb.append("<TD width=\"30\">Eff. Date</TD>");
sb.append("<TD width=\"125\">Insured Name</TD>");
sb.append("<TD width=\"160\">Claimant Name</TD>");
sb.append("<TD width=\"150\">Adj #</TD>");
sb.append("<TD width=\"30\">Handling Office</TD>");
sb.append("<TD width=\"40\">Issu Co #</TD>");
sb.append("<TD width=\"30\">Division</TD>");
sb.append("<TD width=\"40\">Pol Exp Date</TD>");
sb.append("<TD width=\"30\">Error Desc</TD>");
sb.append("</TR>");
StringTokenizer st2 = new StringTokenizer(args,
"@");
int totalrows = st2.countTokens();
System.out.println("total rows "+ totalrows);
String sToken= new String();
for(; st2.hasMoreTokens(); sb.append("</TR>"))
{
sb.append("<TR>");
for(StringTokenizer st1 = new
StringTokenizer(st2.nextToken(), "~"); st1.hasMoreTokens();
sb.append("</TD>"))
{
sb.append("<TD width=\"120\">");
sToken=st1.nextToken();
sToken.trim();
if(sToken.equals("SPACE"))
{
sToken=" ";
}
sb.append(sToken);
//sb.append(st1.nextToken());
}
}
sb.append("</B>");
sb.append("</TABLE>");
System.out.println("before Catch");
FileOutputStream fileToWrite = new
FileOutputStream(excel);
fileToWrite.write(sb.toString().getBytes(),0,sb.toString().length());
fileToWrite.close();
}
catch(Exception e)
{
e.printStackTrace();
}
try {
Runtime r = Runtime.getRuntime();
Process p = null;
p = r.exec(" C:\\export.xls");
} catch (Exception Ex){
Ex.printStackTrace();
}
}
> -----Original Message-----
> From: Galbreath, Mark [SMTP:[EMAIL PROTECTED]]
> Sent: Saturday, May 04, 2002 7:45 PM
> To: [EMAIL PROTECTED]
> Subject: Re: how to open a excel sheet from aservlet
>
> I never done this, so this is just a guess. I'd say you'd store an empty
> spreadsheet (empty.xls) somewhere on the server and when you click on the
> export button it invokes the servlet to store the spreadsheet sent in the
> request and serves empty.xls in the response.
>
> Mark
>
> -----Original Message-----
> From: Raghava Krishna (CTC) [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, May 04, 2002 10:09 AM
>
> thats fine but now when i am clicking the export button again, the new
> excel
> sheet should be open .how to do that or i should get back the control from
> servlet to html saying that one is opened and when i click the button it
> should close the old one and open new one.
> if u cam give me solutions for both of the conditions please.....
> thanks in advance
> raghava
>
> > -----Original Message-----
> > From: Galbreath, Mark
> > Sent: Saturday, May 04, 2002 9:46 AM
> >
> > In your HTML/JSP:
> >
> > <form enctype="application/vnd.ms-excel">
> >
> > In your servlet:
> >
> > response.setContentType( "application/vnd.ms-excel");
> >
> > Mark
>
> __________________________________________________________________________
> _
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html