The best way? 

What has worked for me is the following: 

1) Format the file in SQL
  <cfquery name="qry_appeal_detail" datasource="#application.datasource#">
        SELECT  ISNULL(quotename(accountcodeid,'""""'),'') + ',' +
ISNULL(quotename(lname,'""""'),'') + ',' +
ISNULL(quotename(fname,'""""'),'') col
        FROM appeals app
                LEFT OUTER JOIN savings sav
                ON sav.savingid = app.savingid
  </cfquery>

2) Serve it to the user via one of two methods:


A - The CFHEADER route: This will rename the file as the user goes to save
it.

<CFHEADER NAME="Content-Disposition"
VALUE="attachment;filename=#report_name#.csv">
<CFCONTENT TYPE="unknown" reset="Yes"><cfoutput query="#queryname#">#col#
</cfoutput><cfabort>

B - The URL Hack route: This will rename the file via the link to the page,
but is trouble for some installations of IIS. Do the same thing as above,
but forget the CFHEADER tag and use the following to link to the page:

<a href="mycfmpage.cfm/report.csv?urlvar=value">Click Here</a>

Hopefully, this helps.

Mike


-----Original Message-----
From: Peter Tilbrook [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 04, 2001 9:54 PM
To: CF-Talk
Subject: File save as...


What's the best way to force the browser to "save as" ColdFusion generated
content as a simple (comma delimited) text file, eg:

My Custom Ingredient,Energy,125.00,Protein,47.93,Fat,93.9

Cheers!

Peter Tilbrook ([EMAIL PROTECTED])
Macromedia ColdFusion Applications Developer
Cubok Pty. Ltd.
Units 7-10
Australian Heritage Village
Watson ACT 2602
AUSTRALIA

http://www.cubok.com

Mobile: 0401 973 415
Tel: +61-2-6262-4080

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to