Skip to main content
Inspiring
June 6, 2017
Question

Extract row ID from a query (from cfspeadsheet)

  • June 6, 2017
  • 1 reply
  • 348 views

Hello,

I working with Coldfusion 10.

I use cfspreadsheet for reading an Excel document. The result is in query. See example below.

As you see (black circled) you have the row ID 1, 2 and 3 (representing the row number of the Excel sheet).

I would like to read that value.

Question:

How can I read this value ?

Reason:

I must make a query of query to filter data.

In case of mistake (bad values or missing values) I must display an error message which explain that "wrong value on row xxx".

After the query of query, the quantity of rows are not the same as the Excel document and the row id is not correct.

My ideas is to add a column to the result of query of the query with the row id of the original query (which represent the row number).

I already search on internet, this forum. But I don't know how to do that !

Or any one have a better ideas?

Thank you so much for your help

Best regards

André L'Hoir

    This topic has been closed for replies.

    1 reply

    Inspiring
    June 6, 2017

    Hello,

    You can close the issue. I founded the solution (see code below)

    <cfset queryAddColumn(YourQuery, "RowNum", ArrayNew(1)) />

    <cfloop query="YourQuery">

       <cfset querySetCell(YourQuery, "RowNum", YourQuery.currentRow, YourQuery.currentRow) />

    </cfloop>

    So.. Thanks

    Best regards

    André L'Hoir