Files
PhpSpreadsheet/samples/Calculations/DateTime/NOW.php
T
oleibman 641f86dc80 Eliminate Some "Mixed" Variables in Samples
A continuation of PR #3859. Change code that would be flagged if we were to run Phpstan at level 9 (we currently run level 8). I may or may not follow up with source code (454 level-9 problems remain for src), but there is no reason to avoid the effort for samples.

No changes are made to src.
2024-01-20 16:39:23 -08:00

30 lines
706 B
PHP

<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$category = 'Date/Time';
$functionName = 'NOW';
$description = 'Returns the serial number of the current date and time';
$helper->titles($category, $functionName, $description);
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
$worksheet->setCellValue('A1', '=NOW()');
$worksheet->getStyle('A1')
->getNumberFormat()
->setFormatCode('yyyy-mm-dd hh:mm:ss');
// Test the formulae
$helper->log(
'Today is '
. $worksheet->getCell('A1')->getCalculatedValue()
. ' ('
. $worksheet->getCell('A1')->getFormattedValue()
. ')'
);