PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Calculation / LookupRef / Formula.php

Formula.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Calculation/LookupRef/Formula.php

45 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\LookupRef;
4
5 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Calculation;
6 use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
7 use TablePress\PhpOffice\PhpSpreadsheet\Cell\Cell;
8 use TablePress\PhpOffice\PhpSpreadsheet\Shared\StringHelper;
9
10 class Formula
11 {
12 /**
13 * FORMULATEXT.
14 *
15 * @param mixed $cellReference The cell to check
16 * @param ?Cell $cell The current cell (containing this formula)
17 */
18 public static function text($cellReference = '', ?Cell $cell = null): string
19 {
20 if ($cell === null) {
21 return ExcelError::REF();
22 }
23
24 $worksheet = null;
25 $cellReference = StringHelper::convertToString($cellReference);
26 if (1 === preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellReference, $matches)) {
27 $cellReference = $matches[6] . $matches[7];
28 $worksheetName = trim($matches[3], "'");
29 $worksheet = (!empty($worksheetName))
30 ? $cell->getWorksheet()->getParentOrThrow()->getSheetByName($worksheetName)
31 : $cell->getWorksheet();
32 }
33
34 if (
35 $worksheet === null
36 || !$worksheet->cellExists($cellReference)
37 || !$worksheet->getCell($cellReference)->isFormula()
38 ) {
39 return ExcelError::NA();
40 }
41
42 return $worksheet->getCell($cellReference)->getValueString();
43 }
44 }
45