This function checks the query for a column with the same name as the key provided.
boolean QueryKeyExists(Object query, String key)
Parameter | Description |
query | (Required) Query to be checked whether a key is available. |
key | (Required) Key to be matched with the columns. |
<cfquery name="courses" datasource="cfdocexamples" cachedwithin="#CreateTimeSpan(0, 6, 0, 0)#"> SELECT CORNUMBER,DEPT_ID,COURSE_ID,CORNAME FROM COURSELIST </cfquery> <cfscript> //Use an absolute path for the files. - theDir=GetDirectoryFromPath(GetCurrentTemplatePath()); theFile=theDir & "courses.xls"; //Create two empty ColdFusion spreadsheet objects theSheet = SpreadsheetNew("CourseData"); SpreadsheetAddRows(theSheet,courses); </cfscript> <!--- Write the two sheets to a single file ---> <cfspreadsheet action="write" filename="#theFile#" name="theSheet" sheetname="courses" overwrite=true> <cfspreadsheet action="read" src="#theFile#" sheetname="courses" query="queryData"> <cfoutput>querydata.KeyExists("col_1"):#querydata.KeyExists("col_1")#</cfoutput>