velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Christian <>
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 

   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/">
> 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 <>
> 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 
>>the outputstream (or printwriter) to the client to deliver the 
>>You can either set the content type and header in the Java code 
>>merging your Velocity template, or you can buffer the merged 
>>before opening the output stream and returning it to the client.
>>- simon
>>leo yanez caro . wrote:
>>>my english is not good, sorry.
>>>i want to put 
>>>somethink like this 
>>>in my A.vm but don't work.
>>>any idea?
>>>i have to do somethink in my
>>>i want to export the result of my A.vm to excel.
>>>thank you very much.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message