I am working on a project, in which XLS file needs to be uploaded to the server and extract its content. When I worked on my localhost it was working perfectly, but after I uploaded the project on the server, phpSpreadSheet
library started not working. I checked the error_log
file in the server and noticed that the following error has appeared.
PHP Parse error: syntax error, unexpected '.', expecting '&' or variable (T_VARIABLE) in 'vendor/markbaker/complex/classes/src/operations/add.php'
I think that I do not have any error in my code as the library was working in my localhost without errors.
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$reader->setReadDataOnly(TRUE);
$spreadsheet = $reader->load(strip_tags($file_path));
$worksheet = $spreadsheet->getActiveSheet();
$highestRow = $worksheet->getHighestRow();
$highestColumn = $worksheet->getHighestColumn();
$data = $worksheet->rangeToArray(
'A1:' . $highestColumn . '1',
NULL,TRUE,TRUE
);