下面是我将查询输出到电子表格的代码。
<cfscript>
//Use an absolute path for the files. --->
theDir=GetDirectoryFromPath(GetCurrentTemplatePath());
theFile=theDir & "getTestInv.xls";
//Create an empty ColdFusion spreadsheet object. --->
theSheet = SpreadsheetNew("invoicesData");
//Populate the object with a query. --->
SpreadsheetAddRows(theSheet,getTestInv);
</cfscript>
<cfset format = StructNew()>
<cfset format.dataformat = "#,###0.00">
<cfset SpreadsheetFormatColumn(theSheet,format,10)
<cfspreadsheet action="write" filename="#theFile#" name="theSheet" sheetname="getTestInv" overwrite=true>我得到的错误是:
Invalid CFML construct found on line 125 at column 32.
ColdFusion was looking at the following text:
,
The CFML compiler was processing:
An expression beginning with /", on line 125, column 30.This message is usually caused by a problem in the expressions structure.
A cfset tag beginning on line 125, column 4.
A cfset tag beginning on line 125, column 4.
125: <cfset format.dataformat = "#,###0.00">出于某种原因,它不喜欢逗号,即使根据documentation它是有效的。如果我去掉逗号,它是有效的,但我需要它来进行千位分组。
有人遇到过这种情况吗?
发布于 2013-01-18 18:25:03
在ColdFusion中,#是保留字符。为了逃脱它,你必须加倍它们才能逃脱:
<cfset format.dataformat = "##,######0.00">愚蠢的是,他们既没有在文档中说明这一点,也没有遵循ColdFusion的格式规则,使用9s而不是#s。
下面是我完整的独立测试代码:
<cfset myQuery = QueryNew('number')>
<cfset newRow = QueryAddRow(MyQuery, 2)>
<cfset temp = QuerySetCell(myQuery, "number", "349348394", 1)>
<cfset temp = QuerySetCell(myQuery, "number", "10000000", 2)>
<cfscript>
//Use an absolute path for the files. --->
theDir=GetDirectoryFromPath(GetCurrentTemplatePath());
theFile=theDir & "getTestInv.xls";
//Create an empty ColdFusion spreadsheet object. --->
theSheet = SpreadsheetNew("invoicesData");
//Populate the object with a query. --->
SpreadsheetAddRows(theSheet,myQuery,1,1);
</cfscript>
<cfset format = StructNew()>
<cfset format.dataformat = "##,######0.00">
<cfset SpreadsheetFormatColumn(theSheet,format,1)>
<cfspreadsheet action="write" filename="#theFile#" name="theSheet" sheetname="theSheet" overwrite=true>发布于 2013-01-18 18:26:34
应该是这样的
<cfset format = StructNew()>
<cfset format.dataformat = "##,####0.00">https://stackoverflow.com/questions/14396499
复制相似问题