initial commit of SVN release repo
This commit is contained in:
56
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DAVERAGE.php
vendored
Normal file
56
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DAVERAGE.php
vendored
Normal 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());
|
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DCOUNT.php
vendored
Normal file
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DCOUNT.php
vendored
Normal 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());
|
52
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DGET.php
vendored
Normal file
52
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DGET.php
vendored
Normal 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());
|
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DMAX.php
vendored
Normal file
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DMAX.php
vendored
Normal 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());
|
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DMIN.php
vendored
Normal file
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DMIN.php
vendored
Normal 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());
|
52
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DPRODUCT.php
vendored
Normal file
52
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DPRODUCT.php
vendored
Normal 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());
|
56
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DSTDEV.php
vendored
Normal file
56
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DSTDEV.php
vendored
Normal 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());
|
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DSTDEVP.php
vendored
Normal file
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DSTDEVP.php
vendored
Normal 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());
|
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DVAR.php
vendored
Normal file
55
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DVAR.php
vendored
Normal 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());
|
56
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DVARP.php
vendored
Normal file
56
inc/vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DVARP.php
vendored
Normal 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());
|
Reference in New Issue
Block a user