Re: will not export query to excel
this works: cfquery name=gettemp datasource=#application.datasource# select location,score from SPDOut where SPDINput_id=#url.id# order by location /cfquery cfsetting enablecfoutputonly=yes !--- Required for CSV export to function properly --- cfset delim = 44 !--- Use a comma for a field delimitter, Excel will open CSV files --- !--- cfcontent type=application/msexcel cfheader name=Content-Disposition value=attachment; #url.id#-export.csv --- cfset thefile=Location#chr(delim)#Score#chr(delim)# cfset thefile= #thefile# #chr(13)#!--- line break after column header --- !--- Spill out data from a query --- cfloop query=gettemp cfset thefile= #thefile# #location##chr(delim)##score##chr(13)# /cfloop cfset exportallfile=#GetDirectoryFromPath(GetBaseTemplatePath())##url.id#-export.csv CFFILE ACTION=write FILE=#exportallfile# OUTPUT=#thefile# cfoutputcfset savefilename=#url.id#-export.csv/cfoutput !--- Push file to Client Browser --- CFHEADER NAME=Content-disposition VALUE=attachment; filename=#savefilename# cfcontent file=#exportallfile# type=application/ms-excel deletefile=no On 4/20/2011 2:50 PM, Rick Colman wrote: I am trying to output the results of a query to Excel, but instead, it opens CF Builder. Please advise. TNX. cfquery name=gettemp datasource=#application.datasource# select location,score from SPDOut where SPDINput_id=#url.id# order by location /cfquery cfsetting enablecfoutputonly=yes !--- Required for CSV export to function properly --- cfset delim = 44 !--- Use a comma for a field delimitter, Excel will open CSV files --- cfcontent type=application/msexcel cfheader name=Content-Disposition value=#url.id#-export.csv !--- Output Column Headers --- cfoutputLocation#chr(delim)#Score#chr(delim)#/cfoutput cfoutput#chr(13)#/cfoutput !--- line break after column header --- !--- Spill out data from a query --- cfloop query=gettempcfoutput#location##chr(delim)##score##chr(13)#/cfoutput/cfloop ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343887 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: will not export query to excel
this works: cfquery name=gettemp datasource=#application.datasource# select location,score from SPDOut where SPDINput_id=#url.id# order by location /cfquery cfsetting enablecfoutputonly=yes !--- Required for CSV export to function properly --- cfset delim = 44 !--- Use a comma for a field delimitter, Excel will open CSV files --- !--- cfcontent type=application/msexcel cfheader name=Content-Disposition value=attachment; #url.id#-export.csv --- cfset thefile=Location#chr(delim)#Score#chr(delim)# cfset thefile= #thefile# #chr(13)#!--- line break after column header --- !--- Spill out data from a query --- cfloop query=gettemp cfset thefile= #thefile# #location##chr(delim)##score##chr(13)# /cfloop cfset exportallfile=#GetDirectoryFromPath(GetBaseTemplatePath())##url.id#-export.csv CFFILE ACTION=write FILE=#exportallfile# OUTPUT=#thefile# cfoutputcfset savefilename=#url.id#-export.csv/cfoutput !--- Push file to Client Browser --- CFHEADER NAME=Content-disposition VALUE=attachment; filename=#savefilename# cfcontent file=#exportallfile# type=application/ms-excel deletefile=no On 4/20/2011 2:50 PM, Rick Colman wrote: I am trying to output the results of a query to Excel, but instead, it opens CF Builder. Please advise. TNX. cfquery name=gettemp datasource=#application.datasource# select location,score from SPDOut where SPDINput_id=#url.id# order by location /cfquery cfsetting enablecfoutputonly=yes !--- Required for CSV export to function properly --- cfset delim = 44 !--- Use a comma for a field delimitter, Excel will open CSV files --- cfcontent type=application/msexcel cfheader name=Content-Disposition value=#url.id#-export.csv !--- Output Column Headers --- cfoutputLocation#chr(delim)#Score#chr(delim)#/cfoutput cfoutput#chr(13)#/cfoutput !--- line break after column header --- !--- Spill out data from a query --- cfloop query=gettempcfoutput#location##chr(delim)##score##chr(13)#/cfoutput/cfloop ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:343888 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm