PHPExcel Reader Example #16

Handling Loader Exceptions using Try/Catch

'; try { $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName); } catch (\PHPExcel\Reader\Exception $e) { die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage()); } echo '
'; $sheetData = $spreadsheet->getActiveSheet()->toArray(null, true, true, true); var_dump($sheetData); ?>