Reputation: 13743
I'm attempting to dump a bunch of get
functions into a spreadsheet using cfspreadsheet
- instead of passing each individual function, I've decided to create a list and loop through it. I think I am using Evaluate()
incorrectly here, but I'm not sure what the best way to accomplish this is. Any suggestions/optimizations would be appreciated, as my Cold-Fu isn't that great.
Error thrown is Variable GETFIELDS is undefined.
<cfset var fields = "Function1,Function2" />
<cfspreadsheet action="read" src="#strDestinationPath#information.xls" name="xlsInfo" headerrow="1" />
<cfset var row = xlsData.rowcount + 1 />
<cfset var count = 1 />
<cfloop list="fields" index="f" delimiters=",">
<cfscript>
SpreadsheetSetCellValue(xlsInfo,Evaluate('get' & f & '()'),row,count);
count++;
</cfscript>
</cfloop>
<cfspreadsheet action="write" overwrite="true" filename="#strDestinationPath#information.xls" name="xlsInformation" />
Upvotes: 0
Views: 413
Reputation: 1261
cfloop
expects a list of items as an argument.
Try changing from
<cfloop list="fields" index="f" delimiters=",">
to
<cfloop list="#fields#" index="f" delimiters=",">
or to
<cfloop list="Function1,Function2" index="f" delimiters=",">
Upvotes: 2