ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
18extendedcalculation.php
Go to the documentation of this file.
1 <?php
29 error_reporting(E_ALL);
30 ini_set('display_errors', TRUE);
31 ini_set('display_startup_errors', TRUE);
32 date_default_timezone_set('Europe/London');
33 
34 define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
35 
36 date_default_timezone_set('Europe/London');
37 
39 require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
40 
41 
42 // List functions
43 echo date('H:i:s') . " List implemented functions\n";
45 print_r($objCalc->listFunctionNames());
46 
47 // Create new PHPExcel object
48 echo date('H:i:s') . " Create new PHPExcel object\n";
50 
51 // Add some data, we will use some formulas here
52 echo date('H:i:s') . " Add some data\n";
53 $objPHPExcel->getActiveSheet()->setCellValue('A14', 'Count:');
54 
55 $objPHPExcel->getActiveSheet()->setCellValue('B1', 'Range 1');
56 $objPHPExcel->getActiveSheet()->setCellValue('B2', 2);
57 $objPHPExcel->getActiveSheet()->setCellValue('B3', 8);
58 $objPHPExcel->getActiveSheet()->setCellValue('B4', 10);
59 $objPHPExcel->getActiveSheet()->setCellValue('B5', True);
60 $objPHPExcel->getActiveSheet()->setCellValue('B6', False);
61 $objPHPExcel->getActiveSheet()->setCellValue('B7', 'Text String');
62 $objPHPExcel->getActiveSheet()->setCellValue('B9', '22');
63 $objPHPExcel->getActiveSheet()->setCellValue('B10', 4);
64 $objPHPExcel->getActiveSheet()->setCellValue('B11', 6);
65 $objPHPExcel->getActiveSheet()->setCellValue('B12', 12);
66 
67 $objPHPExcel->getActiveSheet()->setCellValue('B14', '=COUNT(B2:B12)');
68 
69 $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Range 2');
70 $objPHPExcel->getActiveSheet()->setCellValue('C2', 1);
71 $objPHPExcel->getActiveSheet()->setCellValue('C3', 2);
72 $objPHPExcel->getActiveSheet()->setCellValue('C4', 2);
73 $objPHPExcel->getActiveSheet()->setCellValue('C5', 3);
74 $objPHPExcel->getActiveSheet()->setCellValue('C6', 3);
75 $objPHPExcel->getActiveSheet()->setCellValue('C7', 3);
76 $objPHPExcel->getActiveSheet()->setCellValue('C8', '0');
77 $objPHPExcel->getActiveSheet()->setCellValue('C9', 4);
78 $objPHPExcel->getActiveSheet()->setCellValue('C10', 4);
79 $objPHPExcel->getActiveSheet()->setCellValue('C11', 4);
80 $objPHPExcel->getActiveSheet()->setCellValue('C12', 4);
81 
82 $objPHPExcel->getActiveSheet()->setCellValue('C14', '=COUNT(C2:C12)');
83 
84 $objPHPExcel->getActiveSheet()->setCellValue('D1', 'Range 3');
85 $objPHPExcel->getActiveSheet()->setCellValue('D2', 2);
86 $objPHPExcel->getActiveSheet()->setCellValue('D3', 3);
87 $objPHPExcel->getActiveSheet()->setCellValue('D4', 4);
88 
89 $objPHPExcel->getActiveSheet()->setCellValue('D5', '=((D2 * D3) + D4) & " should be 10"');
90 
91 $objPHPExcel->getActiveSheet()->setCellValue('E1', 'Other functions');
92 $objPHPExcel->getActiveSheet()->setCellValue('E2', '=PI()');
93 $objPHPExcel->getActiveSheet()->setCellValue('E3', '=RAND()');
94 $objPHPExcel->getActiveSheet()->setCellValue('E4', '=RANDBETWEEN(5, 10)');
95 
96 $objPHPExcel->getActiveSheet()->setCellValue('E14', 'Count of both ranges:');
97 $objPHPExcel->getActiveSheet()->setCellValue('F14', '=COUNT(B2:C12)');
98 
99 // Calculated data
100 echo date('H:i:s') . " Calculated data\n";
101 echo 'Value of B14 [=COUNT(B2:B12)]: ' . $objPHPExcel->getActiveSheet()->getCell('B14')->getCalculatedValue() . "\r\n";
102 
103 
104 // Echo memory peak usage
105 echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";
106 
107 // Echo done
108 echo date('H:i:s') . " Done" , EOL;
const EOL
$objCalc
PHPExcel.
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static getInstance(PHPExcel $workbook=NULL)
Get an instance of this class.