Skip to content

Instantly share code, notes, and snippets.

Created August 1, 2015 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fd27b43dfa2a36107e2e to your computer and use it in GitHub Desktop.
Save anonymous/fd27b43dfa2a36107e2e to your computer and use it in GitHub Desktop.
TryCF Gist
<cfset hdr = ["ID","Name","DOB"] />
<cfset qList = queryNew("c1,c2,c3") />
<cfloop from="1" to="10" index="i">
<cfset queryAddRow(qList, 1) />
<cfset querySetCell(qList, "C1", i) />
<cfset querySetCell(qList, "C2", "10/" & i & "/1985") />
<cfset querySetCell(qList, "C3", "Vikas" & i) />
</cfloop>
<!--- <cfdump var="#qList#" /> --->
<cfset data = arrayNew(1) />
<cfloop query="qList">
<cfset dataRow = structNew() />
<cfset dataRow.ID = qList.c1 />
<cfset dataRow.Name = qList.c3 />
<cfset dataRow.DOB = qList.c2 />
<cfset ArrayAppend(data, dataRow) />
</cfloop>
<!--- <cfoutput>#SerializeJSON(data)#</cfoutput> --->
<cfset arrData = arrayNew(2) />
<cfloop from="1" to="#arrayLen(data)#" index="i">
<cfloop from="1" to="#arrayLen(hdr)#" index="j">
<cfset cell = structNew() />
<cfset cell.value = " " & data[i][hdr[j]] />
<cfif hdr[j] EQ "ID">
<cfset cell.number = " 1" />
<cfset cell.format = " 0.0" />
<cfelseif hdr[j] EQ "Name">
<cfset cell.style.color = " red" />
<cfset cell.style.backgroundcolor = " Yellow" />
</cfif>
<cfset arrData[i][j] = cell />
</cfloop>
</cfloop>
<cfoutput>#SerializeJSON(arrData)#</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment