1. Go to this page and download the library: Download mnb/mnb-phpexcel-xlsx 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/ */
$session = Xlsx::read('report.xlsx');
$session->sheet(1); // first worksheet
$session->sheet('Data'); // worksheet by name
$session->sheetNames(); // inspect available names
$session = Xlsx::read('report.xlsx');
if (!$session->hasSheet('Orders')) {
$session = $session->activeSheet();
} else {
$session = $session->sheet('Orders');
}
echo $session->activeSheetName();
print_r($session->activeSheetInfo());
$data = $session->withHeaderRow(1);
if ($data->isEmpty()) {
// The worksheet has zero data rows after the header/options are applied.
return;
}
$data->assertHasRows();
foreach ($data->rows() as $row) {
// Process data.
}