所以显然我不能使用任何特殊字符,甚至不能用点缩写来设置cfspreadsheet中的列名。有没有办法解决这个问题?我基本上是使用 cfspreadsheet 将我的查询结果转储到一个 excel 文件中,并且需要保留某些字符,例如点号来缩写某些术语。将其提升到一个新的水平并在这些列名中使用特殊字符会很好。有解决办法吗?
代码示例。
<cfset qryColumnList = "CaseNo,Model,Name" />
<cfset qryResultSet = QueryNew(qryColumnList) />
<cfoutput query="getUsedCars">
<cfset QueryAddRow(qryResultSet, 1) />
<cfset querySetCell(qryResultSet, "CaseNo", caseno EQ " " ? "" : caseno) />
<cfset querySetCell(qryResultSet, "Model", model EQ " " ? "" : model) />
<cfset querySetCell(qryResultSet, "Name", name EQ " " ? "" : name) />
</cfoutput>
<cfscript>
xlsxopencases = SpreadsheetNew("opencases",true);
SpreadsheetAddRow(xlsxopencases,qryColumnList);
SpreadsheetAddRows(xlsxopencases,qryResultSet);
strFileName=GetDirectoryFromPath(GetCurrentTemplatePath()) & "OpenCasesReport.xlsx";
SpreadsheetFormatRow(xlsxopencases, {bold="true"}, 1);
SpreadsheetFormatRows(xlsxopencases, {dataformat="text"}, "1-#qryResultSet.recordcount + 1#");
SpreadsheetFormatColumn(xlsxopencases, {dataformat="dd/MM/yy HH:mm:SS"},18);
</cfscript>
<cfspreadsheet action="write"
filename="#strFileName#"
name="xlsxopencases"
sheet="1"
sheetname="OpenCasesReport"
overwrite="true" />
<cfheader name="Content-Disposition" value="attachment; filename=OpenCasesReport.xlsx">
<cfcontent file="#strFileName#" type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
<cffile action="delete" file="#strFileName#" />
</cfif>