Created
August 1, 2015 20:02
-
-
Save anonymous/fd27b43dfa2a36107e2e to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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