Create CSV file from a query?
Greetings
I am attempting to create a csv file from a query that would pop up for downloading.
I found this code:
<!--- Create the file with column headers. It is crucial that you have all the outputted text on one line with no spaces between the comma and the next column header.--->
<cffile action="write"
file="C:\TEMP\Analysis.csv"
output="Assigned Technician,Received Date,Received Time,Priority,Due Date,User Name,User Office,Assigned Date,Assigned Time,Completed Date,Completed Time,Hours to Complete,Description"
addnewline="yes">
<!--- Output the contents of the qryResults query ---> <cfoutput> <cfloop query="qryResults">
<!--- Append (Insert) the contents of the query into the already created CSV file. Make sure that you keep all the output on one line exactly like the column header--->
<cffile action="append"
file="C:\TEMP\Analysis.csv"
output= "#(tech_lname)#, #TRIM(queue_dte)#, #TRIM(queue_tme)#, #TRIM(queue_priority)#, #TRIM(due_dte#, #TRIM(user_name)#, #TRIM(office_name)#, #TRIM(assign_date)#, #TRIM(assign_time)#, #TRIM(repair_dte)#, #TRIM(repair_time)#, # TRIM(repair_ttc)#, #Left(q_description,128)#"
addnewline="yes">
</cfloop>
</cfoutput>
<!--- This will pop up the file for downloading. You can open it in excel or any other text editing software. --->
<cflocation url="#your.url#/Analysis.csv">
Something is wrong with the query.
Here's the error:
Invalid CFML construct found on line 135 at column 105.
ColdFusion was looking at the following text:
#
The CFML compiler was processing:
An expression beginning with TRIM, on line 135, etc.
135 : output= "#(tech_lname)#
Any help would be appreciated....
Thanks in advance
Norman
