Files
PhpSpreadsheet/samples/Reader/16_Handling_loader_exceptions_using_TryCatch.php
T
oleibman 2482203c3e Resolve Scrutinizer Reports for Samples (#2691)
These are handled about 50-50 between code changes when reasonable, and annotations when not. No source code is changed.
2022-03-21 13:17:25 -07:00

16 lines
575 B
PHP

<?php
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
require __DIR__ . '/../Header.php';
$inputFileName = __DIR__ . '/sampleData/non-existing-file.xls';
$helper->log('Loading file ' . /** @scrutinizer ignore-type */ pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format');
try {
$spreadsheet = IOFactory::load($inputFileName);
} catch (ReaderException $e) {
$helper->log('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
}