The advice below is good but we've also found the the following header works well;
response.addHeader("Content-disposition","inline; filename=export.xls" ); Another thing, you could be making much more use of Excel, because Excel (also Word and Powerpoint) can be completely expressed using HTML. Some time ago, Office 2000 I think, Microsoft created a universal HTML/XML specification for these products. You can download the spec. from the MS web site if you look for "Office HTML and XML Reference". Even if you only use a couple of the features e.g. line breaks within cells, you're going to give your users a much more useful output. Steve -----Original Message----- From: [EMAIL PROTECTED] .org [mailto:[EMAIL PROTECTED] a.apache.org]On Behalf Of Will Glass-Husain Sent: 25 June 2005 00:07 To: Velocity Users List; Jack Holt Subject: Re: Sending an CSV file as an Excel file I generally find something like this works fine. response.setContentType("application/vnd.ms-excel;charset=iso-8859-1"); response.addHeader("Content-disposition","attachment; filename=" + "export.xls" ); Unfortunately, the extension in the content-disposition header apparently needs to be "xls". But the content can be csv, HTML, or xml as well. HTML is quite nice because you can do basic formatting. WILL ----- Original Message ----- From: "Jack Holt" <[EMAIL PROTECTED]> To: "Velocity Users List" <velocity-user@jakarta.apache.org> Sent: Friday, June 24, 2005 2:43 PM Subject: Sending an CSV file as an Excel file I don't know whether I should be doing this at the Server side in the servlet or in the Velocity Template, but let me get y'all's opinion. On the server side, I am setting the response's content type to excel [using resp.setContentType("application/vnd.ms-excel")] and placing lines of comma-separated text into a String variable (data) and placing the variable into the Velocity context. I am then setting the view to be displayed to a Velocity template that has nothing but the following in it: $data The generated text is appearing in the browser as if the content type were "text/html". Is there some way to set the content type in a Velocity template? --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]