|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig; |
| 6 | + |
| 7 | +use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; |
| 8 | + |
| 9 | +class SumProduct2Test extends AllSetupTeardown |
| 10 | +{ |
| 11 | + public function testSUMPRODUCT(): void |
| 12 | + { |
| 13 | + $file = 'tests/data/Reader/XLSX/issue.3909b.xlsx'; |
| 14 | + $reader = new XlsxReader(); |
| 15 | + $spreadsheet = $reader->load($file); |
| 16 | + $sheet = $spreadsheet->getActiveSheet(); |
| 17 | + self::assertSame('=SUMPRODUCT(((calNames=I3)*(calTiers=$K$2))*calHours)', $sheet->getCell('K3')->getValue()); |
| 18 | + self::assertSame(40, $sheet->getCell('K3')->getCalculatedValue()); |
| 19 | + self::assertSame(4, $sheet->getCell('L3')->getCalculatedValue()); |
| 20 | + self::assertSame(40, $sheet->getCell('M3')->getCalculatedValue()); |
| 21 | + self::assertSame(4, $sheet->getCell('N3')->getCalculatedValue()); |
| 22 | + self::assertSame(40, $sheet->getCell('K4')->getCalculatedValue()); |
| 23 | + self::assertSame(0, $sheet->getCell('L4')->getCalculatedValue()); |
| 24 | + self::assertSame(40, $sheet->getCell('M4')->getCalculatedValue()); |
| 25 | + self::assertSame(0, $sheet->getCell('N4')->getCalculatedValue()); |
| 26 | + self::assertSame(24, $sheet->getCell('K5')->getCalculatedValue()); |
| 27 | + self::assertSame(0, $sheet->getCell('L5')->getCalculatedValue()); |
| 28 | + self::assertSame(24, $sheet->getCell('M5')->getCalculatedValue()); |
| 29 | + self::assertSame(0, $sheet->getCell('N5')->getCalculatedValue()); |
| 30 | + self::assertSame('=SUMPRODUCT(calHours*((calNames=I3)*(calTiers=$K$2)))', $sheet->getCell('I14')->getValue()); |
| 31 | + self::assertSame(40, $sheet->getCell('I14')->getCalculatedValue()); |
| 32 | + $spreadsheet->disconnectWorksheets(); |
| 33 | + } |
| 34 | +} |
0 commit comments