Skip to content

Commit 2c9e2e2

Browse files
committed
Spill Operator
Spill operator now works both as trailing `#` and ARRAYANCHOR function. `#` is converted to ARRAYANCHOR when writing. I do not think it is important to convert the other way when reading. Documentation updates have started, but are a work in progress. SINGLE function is implemented. I believe it works correctly when referring to a cell, but not when referring to a cell range. No attempt is yet made to convert leading `@` to and from SINGLE; I haven't figured out how to do so without interfering with `@` in structured references. ISREF has problems. At least one of its tests was wrong, and many of those that were right were so accidentally. The code is changed, quite kludgily, so that almost all the tests are now deliberately correct. One very complicated test is incorrect; for now, I will skip it, and will open an issue when this PR is merged.
1 parent 8609b78 commit 2c9e2e2

23 files changed

+464
-34
lines changed

docs/references/function-list-by-category.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,5 +586,10 @@ WEBSERVICE | \PhpOffice\PhpSpreadsheet\Calculation\Web\Service::we
586586

587587
Excel Function | PhpSpreadsheet Function
588588
-------------------------|--------------------------------------
589-
ANCHORARRAY | **Not yet Implemented**
590-
SINGLE | **Not yet Implemented**
589+
590+
## CATEGORY_MICROSOFT_INTERNAL
591+
592+
Excel Function | PhpSpreadsheet Function
593+
-------------------------|--------------------------------------
594+
ANCHORARRAY | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::anchorArray
595+
SINGLE | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::single

docs/references/function-list-by-name.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ADDRESS | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpread
1515
AGGREGATE | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
1616
AMORDEGRC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial\Amortization::AMORDEGRC
1717
AMORLINC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial\Amortization::AMORLINC
18-
ANCHORARRAY | CATEGORY_UNCATEGORISED | **Not yet Implemented**
18+
ANCHORARRAY | CATEGORY_MICROSOFT_INTERNAL | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::anchorArray
1919
AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::logicalAnd
2020
ARABIC | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Arabic::evaluate
2121
AREAS | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
@@ -510,7 +510,7 @@ SHEET | CATEGORY_INFORMATION | **Not yet Implemente
510510
SHEETS | CATEGORY_INFORMATION | **Not yet Implemented**
511511
SIGN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Sign::evaluate
512512
SIN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig\Sine::sin
513-
SINGLE | CATEGORY_UNCATEGORISED | **Not yet Implemented**
513+
SINGLE | CATEGORY_MICROSOFT_INTERNAL | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::single
514514
SINH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig\Sine::sinh
515515
SKEW | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical\Deviations::skew
516516
SKEW.P | CATEGORY_STATISTICAL | **Not yet Implemented**

docs/topics/calculation-engine.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ formula calculation capabilities. A cell can be of a value type
1010
which can be evaluated). For example, the formula `=SUM(A1:A10)`
1111
evaluates to the sum of values in A1, A2, ..., A10.
1212

13+
Calling `getValue()` on a cell that contains a formula will return the formula itself.
14+
1315
To calculate a formula, you can call the cell containing the formula’s
1416
method `getCalculatedValue()`, for example:
1517

@@ -22,7 +24,18 @@ with PhpSpreadsheet, it evaluates to the value "64":
2224

2325
![09-command-line-calculation.png](./images/09-command-line-calculation.png)
2426

25-
When writing a formula to a cell, formulae should always be set as they would appear in an English version of Microsoft Office Excel, and PhpSpreadsheet handles all formulae internally in this format. This means that the following rules hold:
27+
Calling `getCalculatedValue()` on a cell that doesn't contain a formula will simply return the value of that cell; but if the cell does contain a formula, then PhpSpreadsheet will evaluate that formula to calculate the result.
28+
29+
There are a few useful mehods to help identify whether a cell contains a formula or a simple value; and if a formula, to provide further information about it:
30+
31+
```php
32+
$spreadsheet->getActiveSheet()->getCell('E11')->isFormula();
33+
```
34+
will return a boolean true/false, telling you whether that cell contains a formula or not, so you can determine if a call to `getCalculatedVaue()` will need to perform an evaluation.
35+
36+
For more details on working with array formulas, see the [the recipes documentationn](./recipes.md/#array-formulas).
37+
38+
When writing a formula to a cell, formulas should always be set as they would appear in an English version of Microsoft Office Excel, and PhpSpreadsheet handles all formulas internally in this format. This means that the following rules hold:
2639

2740
- Decimal separator is `.` (period)
2841
- Function argument separator is `,` (comma)
@@ -91,6 +104,11 @@ formula calculation is subject to PHP's language characteristics.
91104
Not all functions are supported, for a comprehensive list, read the
92105
[function list by name](../references/function-list-by-name.md).
93106

107+
#### Array arguments for Function Calls in Formulas
108+
109+
While most of the Excel function implementations now support array arguments, there are a few that should accept arrays as arguments but don't do so.
110+
In these cases, the result may be a single value rather than an array; or it may be a `#VALUE!` error.
111+
94112
#### Operator precedence
95113

96114
In Excel `+` wins over `&`, just like `*` wins over `+` in ordinary
@@ -161,7 +179,7 @@ number of seconds from the PHP/Unix base date. The PHP/Unix base date
161179
(0) is 00:00 UST on 1st January 1970. This value can be positive or
162180
negative: so a value of -3600 would be 23:00 hrs on 31st December 1969;
163181
while a value of +3600 would be 01:00 hrs on 1st January 1970. This
164-
gives PHP a date range of between 14th December 1901 and 19th January
182+
gives 32-bit PHP a date range of between 14th December 1901 and 19th January
165183
2038.
166184

167185
#### PHP `DateTime` Objects
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)