2016-08-31 16:15:54 +00:00
|
|
|
<?php
|
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
|
2017-10-01 08:48:59 +00:00
|
|
|
require __DIR__ . '/../Header.php';
|
2016-08-31 16:15:54 +00:00
|
|
|
|
2017-10-01 08:48:59 +00:00
|
|
|
$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
|
2016-08-31 16:15:54 +00:00
|
|
|
$filename = $helper->getTemporaryFilename();
|
2017-05-17 22:02:17 +00:00
|
|
|
$writer = new Xlsx($sampleSpreadsheet);
|
2016-08-31 16:15:54 +00:00
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$writer->save($filename);
|
|
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|
|
|
|
|
|
|
|
$callStartTime = microtime(true);
|
2017-05-17 22:02:17 +00:00
|
|
|
$reader = IOFactory::createReader('Xlsx');
|
2016-08-31 16:15:54 +00:00
|
|
|
$spreadsheet = $reader->load($filename);
|
2016-10-06 11:39:10 +00:00
|
|
|
$helper->logRead('Xlsx', $filename, $callStartTime);
|
2016-08-31 16:15:54 +00:00
|
|
|
$helper->log('Iterate worksheets');
|
|
|
|
foreach ($spreadsheet->getWorksheetIterator() as $worksheet) {
|
|
|
|
$helper->log('Worksheet - ' . $worksheet->getTitle());
|
|
|
|
|
|
|
|
foreach ($worksheet->getRowIterator() as $row) {
|
|
|
|
$helper->log(' Row number - ' . $row->getRowIndex());
|
|
|
|
|
|
|
|
$cellIterator = $row->getCellIterator();
|
|
|
|
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
|
|
|
|
foreach ($cellIterator as $cell) {
|
2017-10-01 11:07:04 +00:00
|
|
|
if ($cell !== null) {
|
2016-08-31 16:15:54 +00:00
|
|
|
$helper->log(' Cell - ' . $cell->getCoordinate() . ' - ' . $cell->getCalculatedValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|