Help with iterating through Excel Spreadsheet rows only where value of the lowest row is equal

Hi there,

I need help with iterating backwards through an excel spreadsheet in PHP. I need to use the value of the highest row in column(0) as the reference when iterating through the 0th column so that I can get to the first cell’s row where that value appears.

This is what I need

//Loop to determine the first instance of the highest rows 0th cell value

This what I have to use it for.
while($col = 0; $x <= )
{
    for($row = $highest_row_index; $row <= ; -- $row){
        $cell =  $google_sheet_XLSX->getCellByColumnAndRow($row, $col);
        $val = $cell->getValue();
    }
}

This code above is to create an array of the cells value of the specific column, starting at the highest row and ending at the first instance of the value in the highest rows first cell.

I hope what I’m asking makes sense and it’s confusing, because it’s confusing me.

Well, there is no column “0”… Column 1 is column “A”…

So, if you alter the WHILE to start at #1 instead of #0, you will get data.
But, you also need to check if that column is actually a valid data entry. It might be just an empty cell.
I think you need to know the layout of your sheet and lock your code to access the fields ( Rows/Cols/Cells) as needed to access the data. Or, parse them all and see where the data is actually there…

Sponsor our Newsletter | Privacy Policy | Terms of Service