That is not something you can do with cfspreadsheet. CFSpreadsheet only returns the cell values. It does not provide the physical row numbers, within the spreadsheet, that contained those values.
Also, something else to keep in mind is that CFSpreadsheet only returns "logical" (ie populated) rows/cells. That is not the same as the "physical" row numbers 1,2,3,...
and column headers A,B.C....
that you see in Excel. Since users can enter values anywhere within a spreadsheet, logical and physical are not always the same thing.
For example, create a blank spreadsheet. Then enter values in cells
A2
and A25
. Now run your code above. While you might expect the
resulting query to contain twenty-five (25) records, it will only
contain two (2), because only two cells were populated.
query Row | COL_1 1 | Value in cell A2 (physical row 2) 2 | Value in cell 25 (physical row 25)
I think best you could do with cfspreadsheet is to loop through the query and display the relative row number within the results ie query.currentRow
. If the populated data always starts within the first few rows, that might be good enough for your purposes. If not, it could get a bit confusing ...
That said, technically you could get the real physical row numbers. However, it requires much lower level code, which quite honestly ... seems like a lot of work, for very little gain.