无法从 url phpoffice/spreadsheet 加载文件
unable to load file from url phpoffice/spreadsheet
正在尝试从 url 加载 .xlsx 文件,但出现类似
的错误
Fatal error: Uncaught InvalidArgumentException: File
"http://localhost/test/csvfile/samplesms.xlsx" does not exist. in
D:\wamp\www\test\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Shared\File.php on line 137
正在加载以下文件,
$filename = "http://localhost/test/csvfile/samplesms.xlsx";
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$reader->setReadDataOnly(TRUE);
$spreadsheet = $reader->load($filename);
文件已在指定位置。
phpoffice/spreadsheet 不支持从 URL 加载。
您可以使用 php_get_content 或 curl 加载文件内容并将其临时保存在本地然后加载文件的本地版本
$filename = "http://localhost/test/csvfile/samplesms.xlsx";
$file = file_get_contents($filename);
$inputFileName = 'tempfile.xlsx';
file_put_contents($inputFileName, $file);
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
正在尝试从 url 加载 .xlsx 文件,但出现类似
的错误Fatal error: Uncaught InvalidArgumentException: File
"http://localhost/test/csvfile/samplesms.xlsx" does not exist. in
D:\wamp\www\test\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Shared\File.php on line 137
正在加载以下文件,
$filename = "http://localhost/test/csvfile/samplesms.xlsx";
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$reader->setReadDataOnly(TRUE);
$spreadsheet = $reader->load($filename);
文件已在指定位置。
phpoffice/spreadsheet 不支持从 URL 加载。
您可以使用 php_get_content 或 curl 加载文件内容并将其临时保存在本地然后加载文件的本地版本
$filename = "http://localhost/test/csvfile/samplesms.xlsx";
$file = file_get_contents($filename);
$inputFileName = 'tempfile.xlsx';
file_put_contents($inputFileName, $file);
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);