I'm having trouble loading an excel spreadsheet using PHPspreadsheet. I receive the following error...
Fatal error: Uncaught PhpOffice\PhpSpreadsheet\Reader\Exception: Could not open "GradeTrackingv2.xlsx" for reading. in /Applications/XAMPP/xamppfiles/htdocs/excelTest/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php:151 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/excelTest/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/IOFactory.php(133): PhpOffice\PhpSpreadsheet\Shared\File::assertFile('GradeTrackingv2...') #1 /Applications/XAMPP/xamppfiles/htdocs/excelTest/grades.php(33): PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile('GradeTrackingv2...') #2 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/excelTest/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php on line 151
This is the code in my PHP file....
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
$inputFileName = "GradeTrackingv2.xlsx";
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile($inputFileName);
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(TRUE);
$spreadsheet = $reader->load($inputFileName);
$spreadsheet = $spreadsheet->getActiveSheet();
$data_array = $spreadsheet->toArray();
I think it has something to do with my original file being copied from OneDrive. My original excel file lives in OneDrive and this is where I use it. I want to be able to copy this to my server periodically so its contents can be viewed by students. I'm working in xampp at the moment and if I copy the file from OneDrive to the htdocs folder I get the above error. If I create a spreadsheet in the htdocs folder and copy the contents of the excel into the new xlsx file it can be read. This isn't ideal, as it is quite time consuming, I'd just like to copy the file for convenience. Hope that makes sense.