1. Go to this page and download the library: Download lekoala/spread-compat library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lekoala / spread-compat example snippets
// Override the default when you specifically need another adapter
SpreadCompat::$preferredXlsxAdapter = SpreadCompat::XLSWRITER;
$data = iterator_to_array(SpreadCompat::read('myfile.csv'));
// or
foreach(SpreadCompat::read('myfile.xlsx') as $row) {
// Do something
}
// or even
foreach(SpreadCompat::read('myfile.ods') as $row) {
// Do something
}
// Rows are read lazily
foreach (SpreadCompat::read('large.xlsx') as $row) {
// Do something
}
// Rows are written lazily
SpreadCompat::write($rowsGenerator, 'large.csv');