CFScript Evaluate() 在循环中抛出错误
我正在尝试使用 cfspreadsheet 将一堆 get
函数转储到电子表格中 - 我决定创建一个列表并循环遍历它,而不是传递每个单独的函数。我认为我在这里错误地使用了 Evaluate()
,但我不确定实现此目的的最佳方法是什么。任何建议/优化将不胜感激,因为我的 Cold-Fu 不是那么好。
抛出的错误是变量GETFIELDS未定义。
<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" />
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" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
cfloop
需要一个项目列表 作为参数。尝试更改为
或
到
cfloop
expects a list of items as an argument.Try changing from
to
or to