diff --git a/Documentation/Examples/Calculations/Database/DMAX.php b/Documentation/Examples/Calculations/Database/DMAX.php new file mode 100644 index 00000000..c416e0b1 --- /dev/null +++ b/Documentation/Examples/Calculations/Database/DMAX.php @@ -0,0 +1,90 @@ + + + + + +PHPExcel Calculation Examples + + + + +

PHPExcel Calculation Example

+

Database Formulae

+

DMAX

+getActiveSheet(); + +// Add some data +$database = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ), + array( 'Apple', 18, 20, 14, 105.00 ), + array( 'Pear', 12, 12, 10, 96.00 ), + array( 'Cherry', 13, 14, 9, 105.00 ), + array( 'Apple', 14, 15, 10, 75.00 ), + array( 'Pear', 9, 8, 8, 76.80 ), + array( 'Apple', 8, 9, 6, 45.00 ), + ); +$criteria = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ), + array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ), + array( '="=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)'); + + +echo '
'; + + +echo '

Database

'; + +$databaseData = $worksheet->rangeToArray('A4:E10',null,true,true,true); +var_dump($databaseData); + + +echo '
'; + + +// Test the formulae +echo '

Criteria

'; + +echo 'ALL' . '

'; + +echo $worksheet->getCell("A12")->getValue() .'
'; +echo 'DMAX() Result is ' . $worksheet->getCell("B12")->getCalculatedValue() .'

'; + +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A2',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A13")->getValue() .'
'; +echo 'DMAX() Result is ' . $worksheet->getCell("B13")->getCalculatedValue(); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Calculations/Database/DMIN.php b/Documentation/Examples/Calculations/Database/DMIN.php new file mode 100644 index 00000000..4b26f79b --- /dev/null +++ b/Documentation/Examples/Calculations/Database/DMIN.php @@ -0,0 +1,90 @@ + + + + + +PHPExcel Calculation Examples + + + + +

PHPExcel Calculation Example

+

Database Formulae

+

DMIN

+getActiveSheet(); + +// Add some data +$database = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ), + array( 'Apple', 18, 20, 14, 105.00 ), + array( 'Pear', 12, 12, 10, 96.00 ), + array( 'Cherry', 13, 14, 9, 105.00 ), + array( 'Apple', 14, 15, 10, 75.00 ), + array( 'Pear', 9, 8, 8, 76.80 ), + array( 'Apple', 8, 9, 6, 45.00 ), + ); +$criteria = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ), + array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ), + array( '="=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)'); + + +echo '
'; + + +echo '

Database

'; + +$databaseData = $worksheet->rangeToArray('A4:E10',null,true,true,true); +var_dump($databaseData); + + +echo '
'; + + +// Test the formulae +echo '

Criteria

'; + +echo 'ALL' . '

'; + +echo $worksheet->getCell("A12")->getValue() .'
'; +echo 'DMIN() Result is ' . $worksheet->getCell("B12")->getCalculatedValue() .'

'; + +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A2',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A13")->getValue() .'
'; +echo 'DMIN() Result is ' . $worksheet->getCell("B13")->getCalculatedValue(); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Calculations/Database/DSTDEV.php b/Documentation/Examples/Calculations/Database/DSTDEV.php new file mode 100644 index 00000000..97de5c8d --- /dev/null +++ b/Documentation/Examples/Calculations/Database/DSTDEV.php @@ -0,0 +1,91 @@ + + + + + +PHPExcel Calculation Examples + + + + +

PHPExcel Calculation Example

+

Database Formulae

+

DSTDEV

+getActiveSheet(); + +// Add some data +$database = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ), + array( 'Apple', 18, 20, 14, 105.00 ), + array( 'Pear', 12, 12, 10, 96.00 ), + array( 'Cherry', 13, 14, 9, 105.00 ), + array( 'Apple', 14, 15, 10, 75.00 ), + array( 'Pear', 9, 8, 8, 76.80 ), + array( 'Apple', 8, 9, 6, 45.00 ), + ); +$criteria = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ), + array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ), + array( '="=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)'); + + +echo '
'; + + +echo '

Database

'; + +$databaseData = $worksheet->rangeToArray('A4:E10',null,true,true,true); +var_dump($databaseData); + + +echo '
'; + + +// Test the formulae +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A12")->getValue() .'
'; +echo 'DSTDEV() Result is ' . $worksheet->getCell("B12")->getCalculatedValue() .'

'; + +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A13")->getValue() .'
'; +echo 'DSTDEV() Result is ' . $worksheet->getCell("B13")->getCalculatedValue(); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Calculations/Database/DSTDEVP.php b/Documentation/Examples/Calculations/Database/DSTDEVP.php new file mode 100644 index 00000000..96cd77b0 --- /dev/null +++ b/Documentation/Examples/Calculations/Database/DSTDEVP.php @@ -0,0 +1,91 @@ + + + + + +PHPExcel Calculation Examples + + + + +

PHPExcel Calculation Example

+

Database Formulae

+

DSTDEVP

+getActiveSheet(); + +// Add some data +$database = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ), + array( 'Apple', 18, 20, 14, 105.00 ), + array( 'Pear', 12, 12, 10, 96.00 ), + array( 'Cherry', 13, 14, 9, 105.00 ), + array( 'Apple', 14, 15, 10, 75.00 ), + array( 'Pear', 9, 8, 8, 76.80 ), + array( 'Apple', 8, 9, 6, 45.00 ), + ); +$criteria = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ), + array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ), + array( '="=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)'); + + +echo '
'; + + +echo '

Database

'; + +$databaseData = $worksheet->rangeToArray('A4:E10',null,true,true,true); +var_dump($databaseData); + + +echo '
'; + + +// Test the formulae +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A12")->getValue() .'
'; +echo 'DSTDEVP() Result is ' . $worksheet->getCell("B12")->getCalculatedValue() .'

'; + +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A13")->getValue() .'
'; +echo 'DSTDEVP() Result is ' . $worksheet->getCell("B13")->getCalculatedValue(); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Calculations/Database/DVAR.php b/Documentation/Examples/Calculations/Database/DVAR.php new file mode 100644 index 00000000..13790694 --- /dev/null +++ b/Documentation/Examples/Calculations/Database/DVAR.php @@ -0,0 +1,91 @@ + + + + + +PHPExcel Calculation Examples + + + + +

PHPExcel Calculation Example

+

Database Formulae

+

DVAR

+getActiveSheet(); + +// Add some data +$database = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ), + array( 'Apple', 18, 20, 14, 105.00 ), + array( 'Pear', 12, 12, 10, 96.00 ), + array( 'Cherry', 13, 14, 9, 105.00 ), + array( 'Apple', 14, 15, 10, 75.00 ), + array( 'Pear', 9, 8, 8, 76.80 ), + array( 'Apple', 8, 9, 6, 45.00 ), + ); +$criteria = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ), + array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ), + array( '="=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)'); + + +echo '
'; + + +echo '

Database

'; + +$databaseData = $worksheet->rangeToArray('A4:E10',null,true,true,true); +var_dump($databaseData); + + +echo '
'; + + +// Test the formulae +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A12")->getValue() .'
'; +echo 'DVAR() Result is ' . $worksheet->getCell("B12")->getCalculatedValue() .'

'; + +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A13")->getValue() .'
'; +echo 'DVAR() Result is ' . $worksheet->getCell("B13")->getCalculatedValue(); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Calculations/Database/DVARP.php b/Documentation/Examples/Calculations/Database/DVARP.php new file mode 100644 index 00000000..a1512f33 --- /dev/null +++ b/Documentation/Examples/Calculations/Database/DVARP.php @@ -0,0 +1,91 @@ + + + + + +PHPExcel Calculation Examples + + + + +

PHPExcel Calculation Example

+

Database Formulae

+

DVARP

+getActiveSheet(); + +// Add some data +$database = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit' ), + array( 'Apple', 18, 20, 14, 105.00 ), + array( 'Pear', 12, 12, 10, 96.00 ), + array( 'Cherry', 13, 14, 9, 105.00 ), + array( 'Apple', 14, 15, 10, 75.00 ), + array( 'Pear', 9, 8, 8, 76.80 ), + array( 'Apple', 8, 9, 6, 45.00 ), + ); +$criteria = array( array( 'Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height' ), + array( '="=Apple"', '>10', NULL, NULL, NULL, '<16' ), + array( '="=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)'); + + +echo '
'; + + +echo '

Database

'; + +$databaseData = $worksheet->rangeToArray('A4:E10',null,true,true,true); +var_dump($databaseData); + + +echo '
'; + + +// Test the formulae +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A12")->getValue() .'
'; +echo 'DVARP() Result is ' . $worksheet->getCell("B12")->getCalculatedValue() .'

'; + +echo '

Criteria

'; + +$criteriaData = $worksheet->rangeToArray('A1:A3',null,true,true,true); +var_dump($criteriaData); + +echo $worksheet->getCell("A13")->getValue() .'
'; +echo 'DVARP() Result is ' . $worksheet->getCell("B13")->getCalculatedValue(); + + +?> + + \ No newline at end of file diff --git a/Documentation/Examples/Calculations/DateTime/TIME.php b/Documentation/Examples/Calculations/DateTime/TIME.php new file mode 100644 index 00000000..d6566cb7 --- /dev/null +++ b/Documentation/Examples/Calculations/DateTime/TIME.php @@ -0,0 +1,82 @@ + + + + + +PHPExcel Calculation Examples + + + + +

PHPExcel Calculation Example

+

Data/Time Formulae

+

TIME

+getActiveSheet(); + +// Add some data +$testDates = array( array(3,15), array(13,15), array(15,15,15), array(3,15,30), + array(15,15,15), array(5), array(9,15,0), array(9,15,-1), + array(13,-14,-15), array(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'); + + +echo '
'; + + +// Test the formulae +?> + + + + + + + + + + + + + '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + ?> +
Date ValueFormulaExcel TimeStampFormatted TimeStamp
HourMinuteSecond
' , $worksheet->getCell('A'.$row)->getFormattedValue() , '' , $worksheet->getCell('B'.$row)->getFormattedValue() , '' , $worksheet->getCell('C'.$row)->getFormattedValue() , '' , $worksheet->getCell('D'.$row)->getValue() , '' , $worksheet->getCell('D'.$row)->getFormattedValue() , '' , $worksheet->getCell('E'.$row)->getFormattedValue() , '
\ No newline at end of file