ColdFusion 10中的标签嵌套配置无效?

时间:2014-02-05 23:36:59

标签: coldfusion coldfusion-10

如何解决此ColdFusion错误? 我正在关注this ColdFusion教程。当我尝试在ColdFusion 10中实现代码时,我收到以下错误:

  

无效的标记嵌套配置。查询驱动的queryloop标记是   嵌套在也具有查询属性的queryloop标记内。这是   不允许。嵌套这些标记意味着您要使用分组   处理。但是,只有顶级标记可以指定查询   推动处理。

     

错误发生在第76行

     

74 : </cfloop>

     

75 : </tr>

     

76 : <cfoutput query="data" startRow="2">

     

77 : <tr>

     

78 : <cfloop index="c" list="#colList

以下是代码:

<cfset showForm = true>
<cfif structKeyExists(form, "xlsfile") and len(form.xlsfile)>

    <!--- Destination outside of web root --->
    <cfset dest = getTempDirectory()>

    <cffile action="upload" destination="#dest#" filefield="xlsfile" result="upload" nameconflict="makeunique">

    <cfif upload.fileWasSaved>
        <cfset theFile = upload.serverDirectory & "/" & upload.serverFile>
        <cfif isSpreadsheetFile(theFile)>
            <cfspreadsheet action="read" src="#theFile#" query="data" headerrow="1">
            <cffile action="delete" file="#theFile#">
            <cfset showForm = false>
        <cfelse>
            <cfset errors = "The file was not an Excel file.">
            <cffile action="delete" file="#theFile#">
        </cfif>
    <cfelse>
        <cfset errors = "The file was not properly uploaded.">   
    </cfif>
</cfif>
<cfif showForm>
    <cfif structKeyExists(variables, "errors")>
        <cfoutput>
            <p>
                <b>Error: #variables.errors#</b>
            </p>
        </cfoutput>
    </cfif>

    <form action="test.cfm" enctype="multipart/form-data" method="post">
        <input type="file" name="xlsfile" required>
        <input type="submit" value="Upload XLS File">
    </form>
<cfelse>
    <style>
        .ssTable {
            width: 100%; 
             border-style:solid;
             border-width:thin;
        }
        .ssHeader { background-color: #ffff00; }
        .ssTable td, .ssTable th { 
            padding: 10px; 
            border-style:solid;
            border-width:thin;
        }
    </style>
    <p>
    Here is the data in your Excel sheet (assuming first row as headers):
    </p>

    <cfset metadata = getMetadata(data)>
    <cfset colList = "">
    <cfloop index="col" array="#metadata#">
        <cfset colList = listAppend(colList, col.name)>
    </cfloop>

    <cfif data.recordCount is 1>
        <p>
        This spreadsheet appeared to have no data.
        </p>
    <cfelse>
        <table class="ssTable">
            <tr class="ssHeader">
                <cfloop index="c" list="#colList#">
                    <cfoutput><th>#c#</th></cfoutput>
                </cfloop>
            </tr>
            <cfoutput query="data" startRow="2">
                <tr>
                <cfloop index="c" list="#colList#">
                    <td>#data[c][currentRow]#</td>
                </cfloop>
                </tr>                    
            </cfoutput>
        </table>
    </cfif>
</cfif> 

1 个答案:

答案 0 :(得分:4)

试试这个:

<cfoutput>
  <cfloop query="data" startRow="2">
        <tr>
        <cfloop index="c" list="#colList#">
            <td>#data[c][currentRow]#</td>
        </cfloop>
        </tr>                    
  </cfloop>
</cfoutput>