PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.7
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.7
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / samples / Calculations / DateTime / DATE.php

DATE.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.4.7, at vendor/phpoffice/phpspreadsheet/samples/Calculations/DateTime/DATE.php

42 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use PhpOffice\PhpSpreadsheet\Spreadsheet;
4
5 require __DIR__ . '/../../Header.php';
6
7 $helper->log('Returns the serial number of a particular date.');
8
9 // Create new PhpSpreadsheet object
10 $spreadsheet = new Spreadsheet();
11 $worksheet = $spreadsheet->getActiveSheet();
12
13 // Add some data
14 $testDates = [[2012, 3, 26], [2012, 2, 29], [2012, 4, 1], [2012, 12, 25],
15 [2012, 10, 31], [2012, 11, 5], [2012, 1, 1], [2012, 3, 17],
16 [2011, 2, 29], [7, 5, 3], [2012, 13, 1], [2012, 11, 45],
17 [2012, 0, 0], [2012, 1, 0], [2012, 0, 1],
18 [2012, -2, 2], [2012, 2, -2], [2012, -2, -2],
19 ];
20 $testDateCount = count($testDates);
21
22 $worksheet->fromArray($testDates, null, 'A1', true);
23
24 for ($row = 1; $row <= $testDateCount; ++$row) {
25 $worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
26 $worksheet->setCellValue('E' . $row, '=D' . $row);
27 }
28 $worksheet->getStyle('E1:E' . $testDateCount)
29 ->getNumberFormat()
30 ->setFormatCode('yyyy-mmm-dd');
31
32 // Test the formulae
33 for ($row = 1; $row <= $testDateCount; ++$row) {
34 $helper->log('Year: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
35 $helper->log('Month: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
36 $helper->log('Day: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
37 $helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
38 $helper->log('Excel DateStamp: ' . $worksheet->getCell('D' . $row)->getFormattedValue());
39 $helper->log('Formatted DateStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
40 $helper->log('');
41 }
42