I\'m using the PHPExcel library to read an Excel file and perform processing on it. I want to loop through each worksheet. I checked the documentation and all I could find was
Here's a useful function I use for iterating over sheets and returning an array of cell values for each with the sheet title as array key:
function getSheets($fileName) {
try {
$fileType = PHPExcel_IOFactory::identify($fileName);
$objReader = PHPExcel_IOFactory::createReader($fileType);
$objPHPExcel = $objReader->load($fileName);
$sheets = [];
foreach ($objPHPExcel->getAllSheets() as $sheet) {
$sheets[$sheet->getTitle()] = $sheet->toArray();
}
return $sheets;
} catch (Exception $e) {
die($e->getMessage());
}
}