PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.9.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.9.4
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 / Database / DPRODUCT.php

DPRODUCT.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.9.4, at vendor/phpoffice/phpspreadsheet/samples/Calculations/Database/DPRODUCT.php

53 lines 1.6 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('Multiplies the values in a column of a list or database that match conditions that you specify.');
8
9 // Create new PhpSpreadsheet object
10 $spreadsheet = new Spreadsheet();
11 $worksheet = $spreadsheet->getActiveSheet();
12
13 // Add some data
14 $database = [['Tree', 'Height', 'Age', 'Yield', 'Profit'],
15 ['Apple', 18, 20, 14, 105.00],
16 ['Pear', 12, 12, 10, 96.00],
17 ['Cherry', 13, 14, 9, 105.00],
18 ['Apple', 14, 15, 10, 75.00],
19 ['Pear', 9, 8, 8, 76.80],
20 ['Apple', 8, 9, 6, 45.00],
21 ];
22 $criteria = [['Tree', 'Height', 'Age', 'Yield', 'Profit', 'Height'],
23 ['="=Apple"', '>10', null, null, null, '<16'],
24 ['="=Pear"', null, null, null, null, null],
25 ];
26
27 $worksheet->fromArray($criteria, null, 'A1');
28 $worksheet->fromArray($database, null, 'A4');
29
30 $worksheet->setCellValue('A12', 'The product of the yields of all Apple trees over 10\' in the orchard');
31 $worksheet->setCellValue('B12', '=DPRODUCT(A4:E10,"Yield",A1:B2)');
32
33 $helper->log('Database');
34
35 $databaseData = $worksheet->rangeToArray('A4:E10', null, true, true, true);
36 var_dump($databaseData);
37
38 // Test the formulae
39 $helper->log('Criteria');
40
41 $helper->log('ALL');
42
43 $helper->log($worksheet->getCell('A12')->getValue());
44 $helper->log('DMAX() Result is ' . $worksheet->getCell('B12')->getCalculatedValue());
45
46 $helper->log('Criteria');
47
48 $criteriaData = $worksheet->rangeToArray('A1:A2', null, true, true, true);
49 var_dump($criteriaData);
50
51 $helper->log($worksheet->getCell('A13')->getValue());
52 $helper->log('DMAX() Result is ' . $worksheet->getCell('B13')->getCalculatedValue());
53