2014-02-05 24 views
1

我该如何解决这个ColdFusion错误? 我跟随this ColdFusion教程。当我试图实现的ColdFusion 10的代码,我得到了以下错误:ColdFusion 10中的标签嵌套配置无效?

Invalid tag nesting configuration. A query driven queryloop tag is nested inside a queryloop tag that also has a query attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing.

The error occurred in line 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> 
+0

是所有的应该是一段代码,你还没有付钱给格式化,或者你是否试图通过格式化来传递某种信息? –

+0

这真的是产生错误的代码吗?我认为不是,因为上面不包含任何嵌套的查询循环。 – Leigh

+3

无论您运行什么代码来获取该错误,它都不是您在上面发布的代码,也不是Ray的博客上的代码。发布您正在运行的实际代码。该代码中没有嵌套输出。 –

回答

4

试试这个:

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

工作正常!我会接受答案。 – ConfusedDeer