<CFCONTENT
TYPE="application/vnd.ms-excel" >
<!--- This is for writing the string values in to the output file--->
<CFSCRIPT>
WriteOutput(#youroutput#);
</CFSCRIPT>
the above code writes the output of ur query to a excel file.
if you want to have it in a text file, in the cfcontent tag, change the type to text.
cfscript tag writes the output to the file. in the WriteOutput(#youroutput#), youroutput is the variable which has to store ur query output.
hope this helps.