zhaojs
2023-07-31 d705c1fff4f6dcb08eda795229c98567dd5ec9f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
 
use PhpOffice\PhpSpreadsheet\IOFactory;
 
require __DIR__ . '/../Header.php';
 
$inputFileName = __DIR__ . '/sampleData/non-existing-file.xls';
$helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory to identify the format');
 
try {
    $spreadsheet = IOFactory::load($inputFileName);
} catch (InvalidArgumentException $e) {
    $helper->log('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME) . '": ' . $e->getMessage());
}