$highestColumn = $sheet->getHighestColumn(); // 取得总列数 ++$highestColumn; for ($row = 5; $row <= $highestRow; $row++) { $rowData = array(); for ($column = 'A'; $column != $highestColumn; $column++) { $columnData = $sheet->getCell($column . $row)->getValue(); } }
两处改动:1、++$highestColumn;2、$column != $highestColumn;