585409a949
No code changes. The tests in all of these scripts write to at least one temporary file, which is then read and not used again. The file should be deleted to avoid filling up the disk system.
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XLsxReader;
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XLsxWriter;
|
|
|
|
require __DIR__ . '/../Header.php';
|
|
|
|
$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
|
|
$filename = $helper->getTemporaryFilename();
|
|
$writer = new XlsxWriter($sampleSpreadsheet);
|
|
$callStartTime = microtime(true);
|
|
$writer->save($filename);
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|
|
|
|
$callStartTime = microtime(true);
|
|
$reader = new XlsxReader();
|
|
$spreadsheet = $reader->load($filename);
|
|
$helper->logRead('Xlsx', $filename, $callStartTime);
|
|
unlink($filename);
|
|
$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) {
|
|
if ($cell !== null) {
|
|
$helper->log(' Cell - ' . $cell->getCoordinate() . ' - ' . $cell->getCalculatedValue());
|
|
}
|
|
}
|
|
}
|
|
}
|