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 / TIME.php

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

40 lines 1.4 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 time.');
8
9 // Create new PhpSpreadsheet object
10 $spreadsheet = new Spreadsheet();
11 $worksheet = $spreadsheet->getActiveSheet();
12
13 // Add some data
14 $testDates = [[3, 15], [13, 15], [15, 15, 15], [3, 15, 30],
15 [15, 15, 15], [5], [9, 15, 0], [9, 15, -1],
16 [13, -14, -15], [0, 0, -1],
17 ];
18 $testDateCount = count($testDates);
19
20 $worksheet->fromArray($testDates, null, 'A1', true);
21
22 for ($row = 1; $row <= $testDateCount; ++$row) {
23 $worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
24 $worksheet->setCellValue('E' . $row, '=D' . $row);
25 }
26 $worksheet->getStyle('E1:E' . $testDateCount)
27 ->getNumberFormat()
28 ->setFormatCode('hh:mm:ss');
29
30 // Test the formulae
31 for ($row = 1; $row <= $testDateCount; ++$row) {
32 $helper->log('Hour: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
33 $helper->log('Minute: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
34 $helper->log('Second: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
35 $helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
36 $helper->log('Excel TimeStamp: ' . $worksheet->getCell('D' . $row)->getFormattedValue());
37 $helper->log('Formatted TimeStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
38 $helper->log('');
39 }
40