mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-21 10:33:39 +00:00
b3de003aa5
The samples have become unwieldy when running them from a browser. In particular, the drop-down lists are fixed size with no scrolling, and many of them are now just too large. I have moved all the Calculation samples up a level, and broken several categories (Basic, Chart, DateTime, Engineering, Financial, and Reader) into several pieces. Convert-Online (now found in the Engineering category) had a number of different problems which are now resolved. It is the only member with any significant code change.
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());
|
|
}
|
|
}
|
|
}
|
|
}
|