0 Replies - 1328 Views - Last Post: 09 May 2005 - 04:15 PM

#1 wiredwizard   User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 76
  • Joined: 07-May 05

export to excell

Posted 09 May 2005 - 04:15 PM

Description: I didn't write this one but I have found it quit usful see code for useexport info to excell
<CFQUERY NAME="ExportData" DATASOURCE="test">
SELECT field1, field2, field3
FROM tablename
WHERE conditions
</CFQUERY>
     <CFSET tempfile = "C:tempexptemp.csv">

<!--- The "spaces" in the text below are TAB characters. Do not change them
to spaces otherwise the Excel export will not work --->

<CFSET output = "">
<CFSET output = output & "field1     field2     field3">

<CFFILE ACTION="WRITE"
     FILE="#tempfile#"
     OUTPUT="#output#">

<CFLOOP QUERY="GetList">
     <CFSET output = "">
     <CFSET output = output & "#field1#     #field2#     #field3#>
     <CFFILE ACTION="APPEND"
          FILE="#tempfile#"
          OUTPUT="#output#">
</CFLOOP>

     <CFCONTENT TYPE="application/excel" FILE="#tempfile#">


Is This A Good Question/Topic? 0
  • +

Page 1 of 1