I'm trying to get the total number of sheets present in an uploaded Excel file in Laravel. The file I'm uploading has 3 sheets. So I'm expecting to get an output of $counter = 3
.
Code:
$counter=0;
Excel::load($fileDetails['file_path'], function($sheet) use($counter) {
$sheet->each(function($sheet) use($counter) {
echo "It works</br>";
$counter++;
});
});
echo $counter; exit;
Output:
It works
It works
It works
0 //-- This is $counter, which is not get incremented. It has to be 3.