velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Christian <si...@stoutstick.com>
Subject Re: excel
Date Fri, 04 Apr 2003 17:02:12 GMT
Well it does rather depend on the code you currently have in your java 
class, but assuming you're overriding the following method from 
VelocityServlet:

   public Template handleRequest( HttpServletRequest request, 
HttpServletResponse response, Context ctx )

Then you just need to add the following lines at some point before you 
return your Template object (and therefore before the outputstream has 
been opened):

 >  response.setContentType( "application/x-octet-stream" );
 >  response.setHeader( "Content-Disposition", 
"attachment;filename=\"Export.xls\"" );

If you're not extending VelocityServlet, can you provide the relevant 
part of your code and I'll try to give a more specific reply.

- simon



leo yanez caro . wrote:
> HI. thanxs for response.
> and... how i can set the header in the java?
> and how i can call it in the .vm?
> 
> or, can i put the header directly like html.
> 
> this work,
> <meta http-equiv="Content-Type" content="application/vnd.ms-excel">
> but this NOT.
> <meta http-equiv="Content-Disposition" content="attachment;filename="Export.xls"">
> 
> the second stament how i make the second stament???
> 
> very thanxs.
> Leo.
> 
> ----- Original Message -----
> De: Simon Christian <simon@stoutstick.com>
> Fecha: Friday, April 4, 2003 5:50 pm
> Asunto: Re: excel
> 
> 
>>Hi Leo,
>>
>>Your problem appears to be that the headers must be set before you 
>>open 
>>the outputstream (or printwriter) to the client to deliver the 
>>response.
>>You can either set the content type and header in the Java code 
>>before 
>>merging your Velocity template, or you can buffer the merged 
>>output 
>>before opening the output stream and returning it to the client.
>>
>>- simon
>>
>>leo yanez caro . wrote:
>>
>>>hi,
>>>my english is not good, sorry.
>>>i want to put 
>>>somethink like this 
>>>$response.setContentType("application/vnd.ms-excel")
>>>$response.addHeader("content-disposition", 
>>
>>"attachement;filename=Export.xls")> 
>>
>>>in my A.vm but don't work.
>>>any idea?
>>>i have to do somethink in my A.java?
>>>i want to export the result of my A.vm to excel.
>>>thank you very much.
>>>Leo.
>>>
>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message