I am triying to read all columns from an excel file but its number is variable depending on the row. For example: Row1, col2, col3, col4 Row2, col2,col3 Row3,col2,col3,col4,col5,col6
I am trying to do something like:
for ($row = 1; $row < 2; $row++){
$rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row,
NULL,
TRUE,
FALSE);
echo print_r($rowData[0][0]);
echo "<br>";
$list_of_coordinates = "";
$i = 1;
//echo print_r($rowData[$row][$i+1]);
while($rowData[0][$i+1] != ""){
/*$list_of_coordinates = $list_of_coordinates .
"," .
$rowData[0][$i+1] .
"," .
$rowData[0][$i];
*/
$i+2;
}
$list_of_coordinates = ltrim($list_of_coordinates, ",");
echo $list_of_coordinates;
echo "<br>";
}
But the $highestcolumn has the column number of the maximum one, in this file: BM. But some of the rows have just 3 or 4 columns. Is it possible to update this number? MY while loop is not working right now.