Question

How do I get around this ColdFusion error? I'm following this ColdFusion tutorial. When I tried to implement the code in ColdFusion 10 I got the following error:

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

Here is the code:

<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> 
Was it helpful?

Solution

Try this:

<cfoutput>
  <cfloop query="data" startRow="2">
        <tr>
        <cfloop index="c" list="#colList#">
            <td>#data[c][currentRow]#</td>
        </cfloop>
        </tr>                    
  </cfloop>
</cfoutput>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top