I am new to PHP libraries and am trying to get openspout installed so I can read Excel files in PHP. I have installed it with composer and that seems fine. I have then written a very basic PHP script based on the documentation:
open(‘uploads/DATA-2024-06-23.xlsx’);
foreach ($reader->getSheetIterator() as $sheet) {
foreach ($sheet->getRowIterator() as $row) {
$cells = $row->getCells();
print “
$cells”;
}
}
$reader->close();
?>
PHP Version is 7.4.33.
When I run it, I get the following:
[27-Jun-2024 03:39:36 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function OpenSpoutReaderXLSXReader::__construct(), 0 passed in /home/customer/www/website/public_html/excel_test.php on line 6 and exactly 4 expected in /home/customer/vendor/openspout/openspout/src/Reader/XLSX/Reader.php:31
Stack trace:
#0 /home/customer/www/website/public_html/excel_test.php(6): OpenSpoutReaderXLSXReader->__construct()
#1 {main}
thrown in /home/customer/vendor/openspout/openspout/src/Reader/XLSX/Reader.php on line 31
Any advice as to what I am doing wrong would be greatly appreciated!
user25755552 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.