initial commit of SVN release repo

This commit is contained in:
Ryan Prather
2018-05-07 10:51:08 -04:00
committed by Ryan Prather
parent 2c25d5e577
commit 8c38a6cdb9
4369 changed files with 728576 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Returns the average of selected database entries.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The Average yield of Apple trees over 10\' in height');
$worksheet->setCellValue('B12', '=DAVERAGE(A4:E10,"Yield",A1:B2)');
$worksheet->setCellValue('A13', 'The Average age of all Apple and Pear trees in the orchard');
$worksheet->setCellValue('B13', '=DAVERAGE(A4:E10,3,A1:A3)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DAVERAGE() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DAVERAGE() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,55 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Counts the cells that contain numbers in a database.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The Number of Apple trees over 10\' in height');
$worksheet->setCellValue('B12', '=DCOUNT(A4:E10,"Yield",A1:B2)');
$worksheet->setCellValue('A13', 'The Number of Apple and Pear trees in the orchard');
$worksheet->setCellValue('B13', '=DCOUNT(A4:E10,3,A1:A3)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:B2', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DCOUNT() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DCOUNT() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,52 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Extracts a single value from a column of a list or database that matches conditions that you specify.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The height of the Apple tree between 10\' and 16\' tall');
$worksheet->setCellValue('B12', '=DGET(A4:E10,"Height",A1:F2)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$helper->log('ALL');
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,55 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Returns the maximum value from selected database entries.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The tallest tree in the orchard');
$worksheet->setCellValue('B12', '=DMAX(A4:E10,"Height",A4:E10)');
$worksheet->setCellValue('A13', 'The Oldest apple tree in the orchard');
$worksheet->setCellValue('B13', '=DMAX(A4:E10,3,A1:A2)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$helper->log('ALL');
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,55 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Returns the minimum value from selected database entries.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The shortest tree in the orchard');
$worksheet->setCellValue('B12', '=DMIN(A4:E10,"Height",A4:E10)');
$worksheet->setCellValue('A13', 'The Youngest apple tree in the orchard');
$worksheet->setCellValue('B13', '=DMIN(A4:E10,3,A1:A2)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$helper->log('ALL');
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DMIN() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DMIN() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,52 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Multiplies the values in a column of a list or database that match conditions that you specify.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The product of the yields of all Apple trees over 10\' in the orchard');
$worksheet->setCellValue('B12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$helper->log('ALL');
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,56 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Estimates the standard deviation based on a sample of selected database entries.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The estimated standard deviation in the yield of Apple and Pear trees');
$worksheet->setCellValue('B12', '=DSTDEV(A4:E10,"Yield",A1:A3)');
$worksheet->setCellValue('A13', 'The estimated standard deviation in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DSTDEV(A4:E10,2,A1:A3)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DSTDEV() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DSTDEV() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,55 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Calculates the standard deviation based on the entire population of selected database entries.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The standard deviation in the yield of Apple and Pear trees');
$worksheet->setCellValue('B12', '=DSTDEVP(A4:E10,"Yield",A1:A3)');
$worksheet->setCellValue('A13', 'The standard deviation in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DSTDEVP(A4:E10,2,A1:A3)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DSTDEVP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DSTDEVP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,55 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Estimates variance based on a sample from selected database entries.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The estimated variance in the yield of Apple and Pear trees');
$worksheet->setCellValue('B12', '=DVAR(A4:E10,"Yield",A1:A3)');
$worksheet->setCellValue('A13', 'The estimated variance in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DVAR(A4:E10,2,A1:A3)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DVAR() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DVAR() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,56 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Calculates variance based on the entire population of selected database entries,');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
['Apple', 18, 20, 14, 105.00],
['Pear', 12, 12, 10, 96.00],
['Cherry', 13, 14, 9, 105.00],
['Apple', 14, 15, 10, 75.00],
['Pear', 9, 8, 8, 76.80],
['Apple', 8, 9, 6, 45.00],
];
$criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
['="=Apple"', '>10', null, null, null, '<16'],
['="=Pear"', null, null, null, null, null],
];
$worksheet->fromArray($criteria, null, 'A1');
$worksheet->fromArray($database, null, 'A4');
$worksheet->setCellValue('A12', 'The variance in the yield of Apple and Pear trees');
$worksheet->setCellValue('B12', '=DVARP(A4:E10,"Yield",A1:A3)');
$worksheet->setCellValue('A13', 'The variance in height of Apple and Pear trees');
$worksheet->setCellValue('B13', '=DVARP(A4:E10,2,A1:A3)');
$helper->log('Database');
$databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
var_dump($databaseData);
// Test the formulae
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A12')->getValue());
$helper->log('DVARP() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
$helper->log('Criteria');
$criteriaData = $worksheet->rangeToArray('A1:A3', null, true, true, true);
var_dump($criteriaData);
$helper->log($worksheet->getCell('A13')->getValue());
$helper->log('DVARP() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());

View File

@ -0,0 +1,41 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Returns the serial number of a particular date.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$testDates = [[2012, 3, 26], [2012, 2, 29], [2012, 4, 1], [2012, 12, 25],
[2012, 10, 31], [2012, 11, 5], [2012, 1, 1], [2012, 3, 17],
[2011, 2, 29], [7, 5, 3], [2012, 13, 1], [2012, 11, 45],
[2012, 0, 0], [2012, 1, 0], [2012, 0, 1],
[2012, -2, 2], [2012, 2, -2], [2012, -2, -2],
];
$testDateCount = count($testDates);
$worksheet->fromArray($testDates, null, 'A1', true);
for ($row = 1; $row <= $testDateCount; ++$row) {
$worksheet->setCellValue('D' . $row, '=DATE(A' . $row . ',B' . $row . ',C' . $row . ')');
$worksheet->setCellValue('E' . $row, '=D' . $row);
}
$worksheet->getStyle('E1:E' . $testDateCount)
->getNumberFormat()
->setFormatCode('yyyy-mmm-dd');
// Test the formulae
for ($row = 1; $row <= $testDateCount; ++$row) {
$helper->log('Year: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
$helper->log('Month: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
$helper->log('Day: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
$helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
$helper->log('Excel DateStamp: ' . $worksheet->getCell('D' . $row)->getFormattedValue());
$helper->log('Formatted DateStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
$helper->log('');
}

View File

@ -0,0 +1,39 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Converts a date in the form of text to a serial number.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$testDates = ['26 March 2012', '29 Feb 2012', 'April 1, 2012', '25/12/2012',
'2012-Oct-31', '5th November', 'January 1st', 'April 2012',
'17-03', '03-2012', '29 Feb 2011', '03-05-07',
'03-MAY-07', '03-13-07',
];
$testDateCount = count($testDates);
for ($row = 1; $row <= $testDateCount; ++$row) {
$worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
$worksheet->setCellValue('B' . $row, '=DATEVALUE(A' . $row . ')');
$worksheet->setCellValue('C' . $row, '=B' . $row);
}
$worksheet->getStyle('C1:C' . $testDateCount)
->getNumberFormat()
->setFormatCode('yyyy-mmm-dd');
// Test the formulae
$helper->log('<strong>Warning: </strong>The PhpSpreadsheet DATEVALUE() function accepts a wider range of date formats than MS Excel DATEFORMAT() function.');
for ($row = 1; $row <= $testDateCount; ++$row) {
$helper->log('Date String: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
$helper->log('Formula: ' . $worksheet->getCell('B' . $row)->getValue());
$helper->log('Excel DateStamp: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
$helper->log('Formatted DateStamp' . $worksheet->getCell('C' . $row)->getFormattedValue());
$helper->log('');
}

View File

@ -0,0 +1,39 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Returns the serial number of a particular time.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$testDates = [[3, 15], [13, 15], [15, 15, 15], [3, 15, 30],
[15, 15, 15], [5], [9, 15, 0], [9, 15, -1],
[13, -14, -15], [0, 0, -1],
];
$testDateCount = count($testDates);
$worksheet->fromArray($testDates, null, 'A1', true);
for ($row = 1; $row <= $testDateCount; ++$row) {
$worksheet->setCellValue('D' . $row, '=TIME(A' . $row . ',B' . $row . ',C' . $row . ')');
$worksheet->setCellValue('E' . $row, '=D' . $row);
}
$worksheet->getStyle('E1:E' . $testDateCount)
->getNumberFormat()
->setFormatCode('hh:mm:ss');
// Test the formulae
for ($row = 1; $row <= $testDateCount; ++$row) {
$helper->log('Hour: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
$helper->log('Minute: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
$helper->log('Second: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
$helper->log('Formula: ' . $worksheet->getCell('D' . $row)->getValue());
$helper->log('Excel TimeStamp: ' . $worksheet->getCell('D' . $row)->getFormattedValue());
$helper->log('Formatted TimeStamp: ' . $worksheet->getCell('E' . $row)->getFormattedValue());
$helper->log('');
}

View File

@ -0,0 +1,35 @@
<?php
use PhpOffice\PhpSpreadsheet\Spreadsheet;
require __DIR__ . '/../../Header.php';
$helper->log('Converts a time in the form of text to a serial number.');
// Create new PhpSpreadsheet object
$spreadsheet = new Spreadsheet();
$worksheet = $spreadsheet->getActiveSheet();
// Add some data
$testDates = ['3:15', '13:15', '15:15:15', '3:15 AM', '3:15 PM', '5PM', '9:15AM', '13:15AM',
];
$testDateCount = count($testDates);
for ($row = 1; $row <= $testDateCount; ++$row) {
$worksheet->setCellValue('A' . $row, $testDates[$row - 1]);
$worksheet->setCellValue('B' . $row, '=TIMEVALUE(A' . $row . ')');
$worksheet->setCellValue('C' . $row, '=B' . $row);
}
$worksheet->getStyle('C1:C' . $testDateCount)
->getNumberFormat()
->setFormatCode('hh:mm:ss');
// Test the formulae
for ($row = 1; $row <= $testDateCount; ++$row) {
$helper->log('Time String: ' . $worksheet->getCell('A' . $row)->getFormattedValue());
$helper->log('Formula: ' . $worksheet->getCell('B' . $row)->getValue());
$helper->log('Excel TimeStamp: ' . $worksheet->getCell('B' . $row)->getFormattedValue());
$helper->log('Formatted TimeStamp: ' . $worksheet->getCell('C' . $row)->getFormattedValue());
$helper->log('');
}