[Zope] content-type (was Re: export to excel)

Jens Vagelpohl jens@digicool.com
Thu, 15 Feb 2001 18:19:00 -0500


<dtml-call expr="RESPONSE.setHeader('Content-type', 'xyz')">

this should be at the top of your "exportDirectlyToExcel.csv" method

jens


on 2/15/01 14:37, Lee Reilly CS1997 at lreilly@cs.strath.ac.uk wrote:

>> Here's some crude code to do what you want. Note that some lines are
>> broken by my emailer and excel may be picky about extra white space.
>> 
>> yourMethodName.csv:
>> 
>> Content-type: application/ms-excel <snip>
> 
> Hi,
> 
> I've developed some import/export functions myself taking database info
> to/from CSV and/or tab delimited text files. Originally, I just
> displayed the output to the user directly (in text form)  but as I've
> seen from the past few messages, I can have it displayed directly in
> Excel. I have had success with this in IE but Netscape is giving me
> "jip"...
> 
> Simplified version below:
> 
> Id: exportDirectlyToExcel.csv
> Title: exportDirectlyToExcel.csv
> -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> <dtml-in get_matrics_from>
> <dtml-var expr="export(_.this, classcode, matric)">
> </dtml-in>
> -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
> 
> When I open this document in IE it opens Excel automatically but it only
> opens the text representation when I open it Netscape. I presume that
> adding a content-type would remedy this but where and how do I add it?
> 
> "Content-type: application/ms-excel" at the head of the page doesn't
> help. Including it in <HEAD><META> tags isn't helping either. Can anyone
> tell me the solution?
> 
> Here's a sample output...
> 
> 9728430, Lee, Reilly, lreilly, 8, 2, 0, 0, 0, 0, 0, 0, 0, *, *, 0, 0
> 9702709, Gordon, Macleod, gmacleod, 25, 0, 3, 0, 0, 0, 0, 0, 0, *, *, 0,
> 0
> 9702075, Alan, Hamilton, ahamilto, 7, 0, 0, 4, 0, 0, 0, 0, 0, *, *, 0, 0
> 9712346, Alec, Littlechild, alittlec, 5, 0, 0, 0, 5, 0, 0, 0, 0, *, *,
> 0, 0
> 9712347, Fernando, Ricksen, fricksen, 8, 0, 0, 0, 0, 6, 0, 0, 0, *, *,
> 0, 2
> 9712349, Arthur, Numan, anuman, 3, 0, 0, 0, 0, 0, 7, 0, 0, *, *, 0, 2
> 9712351, Chris, Sutton, csutton, 10, 0, 0, 0, 0, 0, 0, 8, 0, *, *, 0, 2
> 9712352, Claudio, Cannigia, ccannigi, 12, 0, 0, 0, 0, 0, 0, 0, 9, *, *,
> 1, 0
> 9712350, Henrik, Larsson, hlarsson, 9, 0, 0, 0, 0, 0, 0, 0, 0, *, *, 0,
> 0
> 
> What can I add to this to make Netscape realise it's an Excel file and
> open in accordingly?
> 
> Cheers in advance ;-)
> 
> Lee
>