You use the JSP to do this.

String data="Whatever";

To display in excel inside browser
out.write(data);

To write to a file
File xyz= new java.io.File("..\\webapps\\Project\\data.csv");
FileOutputStream fos = new FileOutputStream(xyz);
byte[] Data=data.getBytes();
fos.write(Data);
fos.close();
Use jsp forward to forward to this file(data.csv).

>From: "Chen, Dean (Zhun)" <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
>Subject: RE: Excel Export
>Date: Fri, 3 May 2002 11:38:19 -0400
>
>I have a simple question regarding these implementations?
>
>After a bean is populated by the Action class, do I write the contents of
>the bean to a temporary xls file and then do:
>
>Response.ContentType = "application/vnd.ms-excel"
>Response.AddHeader ("CONTENT-DISPOSITION", "attachment; filename 
>=file.xls")
>
>in the Action class?
>
>
>Or do I build the JSP using contents of the bean but setting
>
>response.setHeader("Content-Disposition","attachment;filename=data.csv");
>response.setHeader("Content-Type", "application/ms-excel");
>
>Will the file created by the JSP be called data.csv?
>
>Thanks,
>
>Dean Chen
>
>
>
>-----Original Message-----
>From: Ajay Chitre [mailto:[EMAIL PROTECTED]]
>Sent: Monday, April 29, 2002 3:16 PM
>To: Struts Users Mailing List
>Subject: RE: Excel Export
>
>
>I really liked Vic's suggestion regarding SOAP.  I am going to explore that
>myself.  In the mean time here's a quick & dirty Test.jsp that you can
>use....
>
>
>HTH!
>
>
>
>
><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
><HTML>
><HEAD>
><Title>Excel Format</Title>
><%
>
>
>response.setContentType("application/vnd.ms-excel");
>response.setHeader("Content-Disposition","inline" );
>
>ServletOutputStream outStream = response.getOutputStream();
>
>PrintWriter pw = response.getWriter();
>
>
>
>pw.println("<HTML>");
>pw.println("<HEAD>");
>pw.println("</HEAD>");
>pw.println("<BODY>");
>pw.println("<TABLE border=0 cellpadding=0 cellspacing=0>");
>pw.println("<TR>");
>pw.println("<TD>Custom Reports Process - xxx Report</TD><!--- Cell :
>A1 --->");
>pw.println("<TD></TD><!--- Cell : B1 --->");
>pw.println("</TR>");
>pw.println("<TR>");
>pw.println("<TD>Selection Criteria</TD><!--- Cell : A2 --->");
>pw.println("<TD>&nbsp;</TD><!--- Cell : B2 --->");
>pw.println("</TR>");
>pw.println("</TABLE>");
>pw.println("<p>This is a test<br>");
>pw.println("</BODY>");
>pw.println("</HTML>");
>
>pw.println("Testing$$$$$$$");
>pw.flush();
>pw.close();
>
>
>%>
>
>
></BODY>
></HTML>
>
>
> >-- Original Message --
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >From: "Galbreath, Mark" <[EMAIL PROTECTED]>
> >To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
> >Subject: RE: Excel Export
> >Date: Mon, 29 Apr 2002 13:44:00 -0400
> >
> >
> >This is way too complicated.  All you have to do is set the MIME type in
> >the
> >setContentType() declaration in the servlet delivering the output to
> >"application/vnd.msExcel" and the browser will automatically display the
> >output in an Excel spreadsheet.
> >
> >Mark
> >
> >-----Original Message-----
> >From: Struts Newsgroup [mailto:[EMAIL PROTECTED]]
> >Sent: Monday, April 29, 2002 1:40 PM
> >To: [EMAIL PROTECTED]
> >Subject: Re: Excel Export
> >
> >
> >Subject: Re: Excel Export
> >From: Vic C <[EMAIL PROTECTED]>
> > ===
> >Struts is Java. Excel is VBA. They don't like each other. One good way
>
> >is to expose your Java (Form) beans via SOAP.
> >Then in Excel (using Pocket Soap client for example) write a VBA macro
>
> >that gets the SOAP XML data.
> >You will need to add SOAP interface to you web app server.
> >
> >SOAP is good for most distributed  or diverse applications and good for
>
> >hetrogenous enviroments. (There is a news list on soap at
> >news.strutsplus.com)
> >
> >Vic
> >
> >
> >Chen, Dean (Zhun) wrote:
> >> This might be a little of topic, however, does struts support a
> >standardized
> >> way to export results from queries in a comma delimited format, for
> >> importing into excel?
> >> Thanks,
> >>
> >> Dean Chen
> >>
> >> --
> >> To unsubscribe, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> >> For additional commands, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> >>
> >
> >
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> >
> >--
> >To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
> >
>
>Ajay Chitre
>
>Diligent Team, Inc.
>(Where Diligent People Work as a Team)
>
>http://www.DiligentTeam.com
>
>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>
>
>--
>To unsubscribe, e-mail:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>
>




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to