I have to iterate through all rows of first two columns of a xls document. The problem is that first column of this specific document is "G" with and index of 7.
Is there any way of getting the first column index because I don't want to hard-code it.
My loop:
$spreadsheet =\PhpOffice\PhpSpreadsheet\IOFactory::load($path);
$worksheet = $spreadsheet->getActiveSheet();
$highestRow = $worksheet->getHighestRow();
$rows = [];
for ($row = 1; $row <= $highestRow; ++$row) {
// I WANT TO REPLACE HARD-CODED VALUES OF 7 AND 8
// WITH $firstCol and $firstCol+1
for ($col = 7; $col <= 8; ++$col) {
$value = $worksheet->getCellByColumnAndRow($col, $row)->getValue();
$rows[$row][$col] = $value;
}
}