Skip to content

Commit

Permalink
Merge branch 'master' into brkupxlsr2
Browse files Browse the repository at this point in the history
  • Loading branch information
oleibman committed Aug 12, 2024
2 parents c88c1b7 + f7c183b commit addc83b
Show file tree
Hide file tree
Showing 84 changed files with 3,526 additions and 181 deletions.
25 changes: 9 additions & 16 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$config
->setRiskyAllowed(true)
->setFinder($finder)
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect(null, 600))
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer' . preg_replace('~\W~', '-', __DIR__))
->setRules([
'align_multiline_comment' => true,
Expand All @@ -19,18 +19,17 @@
'backtick_to_shell_exec' => true,
'binary_operator_spaces' => true,
'blank_line_after_namespace' => true,
'blank_lines_before_namespace' => ['max_line_breaks' => 2, 'min_line_breaks' => 2], // we want 1 blank line before namespace
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => true,
'braces' => true,
'cast_spaces' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one', 'property' => 'one']], // const are often grouped with other related const
'class_definition' => false, // phpcs disagree
'class_keyword_remove' => false, // Deprecated, and ::class keyword gives us better support in IDE
'combine_consecutive_issets' => true,
'combine_consecutive_unsets' => true,
'combine_nested_dirname' => true,
'comment_to_phpdoc' => false, // interferes with annotations
'compact_nullable_typehint' => true,
'compact_nullable_type_declaration' => true,
'concat_space' => ['spacing' => 'one'],
'constant_case' => true,
'date_time_immutable' => false, // Break our unit tests
Expand All @@ -47,7 +46,6 @@
'encoding' => true,
'ereg_to_preg' => true,
'error_suppression' => false, // it breaks \PhpOffice\PhpSpreadsheet\Helper\Handler
'escape_implicit_backslashes' => true,
'explicit_indirect_variable' => false, // I feel it makes the code actually harder to read
'explicit_string_variable' => false, // I feel it makes the code actually harder to read
'final_class' => false, // We need non-final classes
Expand All @@ -59,7 +57,6 @@
'fully_qualified_strict_types' => true,
'function_declaration' => true,
'function_to_constant' => true,
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ['access', 'category', 'copyright']],
'general_phpdoc_tag_rename' => true,
'global_namespace_import' => true,
Expand Down Expand Up @@ -93,15 +90,13 @@
'native_constant_invocation' => false, // Micro optimization that look messy
'native_function_casing' => true,
'native_function_invocation' => false, // I suppose this would be best, but I am still unconvinced about the visual aspect of it
'native_function_type_declaration_casing' => true,
'new_with_braces' => true,
'new_with_parentheses' => ['anonymous_class' => true, 'named_class' => true],
'no_alias_functions' => true,
'no_alias_language_construct_call' => true,
'no_alternative_syntax' => true,
'no_binary_string' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
'no_break_comment' => true,
'no_closing_tag' => true,
'no_empty_comment' => true,
Expand All @@ -121,16 +116,14 @@
'no_space_around_double_colon' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => true,
'no_spaces_inside_parenthesis' => true,
'no_superfluous_elseif' => false, // Might be risky on a huge code base
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_comma_in_singleline' => ['elements' => ['arguments', 'array_destructuring', 'array', 'group_import']],
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_trailing_whitespace_in_string' => false, // Too dangerous
'no_unneeded_control_parentheses' => true,
'no_unneeded_curly_braces' => true,
'no_unneeded_braces' => true,
'no_unneeded_final_method' => true,
'no_unreachable_default_argument_value' => true,
'no_unset_cast' => true,
Expand Down Expand Up @@ -175,7 +168,6 @@
'phpdoc_align' => false, // Waste of time
'phpdoc_annotation_without_dot' => true,
'phpdoc_indent' => true,
//'phpdoc_inline_tag' => true,
'phpdoc_line_span' => false, // Unfortunately our old comments turn even uglier with this
'phpdoc_no_access' => true,
'phpdoc_no_alias_tag' => true,
Expand Down Expand Up @@ -215,20 +207,20 @@
'simplified_if_return' => false, // Even if technically correct we prefer to be explicit
'simplified_null_return' => false, // Even if technically correct we prefer to be explicit
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_line_comment_style' => true,
'single_line_throw' => false, // I don't see any reason for having a special case for Exception
'single_quote' => true,
'single_space_after_construct' => true,
'single_trait_insert_per_statement' => true,
'space_after_semicolon' => true,
'spaces_inside_parentheses' => ['space' => 'none'],
'standardize_increment' => true,
'standardize_not_equals' => true,
'static_lambda' => false, // Risky if we can't guarantee nobody use `bindTo()`
'strict_comparison' => false, // No, too dangerous to change that
'string_implicit_backslashes' => false, // was escape_implicit_backslashes, too confusing
'strict_param' => false, // No, too dangerous to change that
'string_length_to_empty' => true,
'string_line_ending' => true,
Expand All @@ -240,6 +232,7 @@
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => true,
'trim_array_spaces' => true,
'type_declaration_spaces' => ['elements' => ['function', 'property']], // was function_typehint_space
'types_spaces' => true,
'unary_operator_spaces' => true,
'use_arrow_functions' => true,
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com)
and this project adheres to [Semantic Versioning](https://semver.org).

## TBD - 3.0.0

### Dynamic Arrays

- Support for Excel dynamic arrays is added. It is an opt-in feature, so our hope is that there will be no BC breaks, but it is a very large change. Full support is added for Xlsx. It is emulated as Ctrl-Shift-Enter arrays for Ods read and write and Excel2003 and Gnumeric read. Html/Pdf and Csv writers will populate cells on output if they are the result of array formulas. No support is added for Xls or Slk.

### Added

- Excel Dynamic Arrays. [Issue #3901](https://github.com/PHPOffice/PhpSpreadsheet/issues/3901) [Issue #3659](https://github.com/PHPOffice/PhpSpreadsheet/issues/3659) [Issue #1834](https://github.com/PHPOffice/PhpSpreadsheet/issues/1834) [PR #3962](https://github.com/PHPOffice/PhpSpreadsheet/pull/3962)

### Changed

- Nothing yet.

### Deprecated

- Nothing yet.

### Moved

- Nothing yet.

### Fixed

- Nothing yet.

## 2024-08-07 - 2.2.2

### Added
Expand Down
24 changes: 17 additions & 7 deletions docs/references/features-cross-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@
<td style="text-align: center; color: red;">✖</td>
</tr>
<tr>
<td style="padding-left: 1em;">Array</td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: red;">✖</td>
<td style="padding-left: 1em;">Array Formula</td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center;">N/A</td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center;">N/A</td>
</tr>
<tr>
<td style="padding-left: 1em;">Rich Text</td>
Expand Down Expand Up @@ -1005,6 +1005,7 @@
5. <span id="footnote5">Xlsx macros can be read and written; their values can be retrieved and changed, but only in a binary form which is unlikely to be useful</span>
6. <span id="footnote6">There is very limited support for reading styles from an Ods spreadsheet. Writing styles has better support, although Number Format is incomplete.</span>
7. <span id="footnote7">In most cases, Html reader processes only inline styles; styles provided by Css classes may be ignored.</span>
8. <span id="footnote8">Code must [opt in](../topics/recipes.md#array-formulas) to array output.</span>

## Writers

Expand Down Expand Up @@ -1175,6 +1176,15 @@
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: red;">✖</td>
</tr>
<tr>
<td style="padding-left: 0.5em;"><strong>Array Formula<a href="#footnote8"><sup>8</sup></a></strong></td>
<td style="text-align: center; color: red;">✖</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center; color: green;">✔</td>
<td style="text-align: center; color: green;">✔</td>
</tr>
<tr>
<td style="padding-left: 0.5em;"><strong>Rows and Column Properties</strong></td>
<td></td>
Expand Down
11 changes: 8 additions & 3 deletions docs/references/function-list-by-category.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ CHAR | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Charac
CLEAN | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Trim::nonPrintable
CODE | \PhpOffice\PhpSpreadsheet\Calculation\TextData\CharacterConvert::code
CONCAT | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Concatenate::CONCATENATE
CONCATENATE | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Concatenate::CONCATENATE
CONCATENATE | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Concatenate::actualCONCATENATE
DBCS | **Not yet Implemented**
DOLLAR | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Format::DOLLAR
EXACT | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Text::exact
Expand Down Expand Up @@ -586,5 +586,10 @@ WEBSERVICE | \PhpOffice\PhpSpreadsheet\Calculation\Web\Service::we

Excel Function | PhpSpreadsheet Function
-------------------------|--------------------------------------
ANCHORARRAY | **Not yet Implemented**
SINGLE | **Not yet Implemented**

## CATEGORY_MICROSOFT_INTERNAL

Excel Function | PhpSpreadsheet Function
-------------------------|--------------------------------------
ANCHORARRAY | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::anchorArray
SINGLE | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::single
6 changes: 3 additions & 3 deletions docs/references/function-list-by-name.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ADDRESS | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpread
AGGREGATE | CATEGORY_MATH_AND_TRIG | **Not yet Implemented**
AMORDEGRC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial\Amortization::AMORDEGRC
AMORLINC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial\Amortization::AMORLINC
ANCHORARRAY | CATEGORY_UNCATEGORISED | **Not yet Implemented**
ANCHORARRAY | CATEGORY_MICROSOFT_INTERNAL | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::anchorArray
AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::logicalAnd
ARABIC | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Arabic::evaluate
AREAS | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented**
Expand Down Expand Up @@ -89,7 +89,7 @@ COMBIN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpread
COMBINA | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Combinations::withRepetition
COMPLEX | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering\Complex::COMPLEX
CONCAT | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Concatenate::CONCATENATE
CONCATENATE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Concatenate::CONCATENATE
CONCATENATE | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Concatenate::actualCONCATENATE
CONFIDENCE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical\Confidence::CONFIDENCE
CONFIDENCE.NORM | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical\Confidence::CONFIDENCE
CONFIDENCE.T | CATEGORY_STATISTICAL | **Not yet Implemented**
Expand Down Expand Up @@ -510,7 +510,7 @@ SHEET | CATEGORY_INFORMATION | **Not yet Implemente
SHEETS | CATEGORY_INFORMATION | **Not yet Implemented**
SIGN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Sign::evaluate
SIN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig\Sine::sin
SINGLE | CATEGORY_UNCATEGORISED | **Not yet Implemented**
SINGLE | CATEGORY_MICROSOFT_INTERNAL | \PhpOffice\PhpSpreadsheet\Calculation\Internal\ExcelArrayPseudoFunctions::single
SINH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Trig\Sine::sinh
SKEW | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical\Deviations::skew
SKEW.P | CATEGORY_STATISTICAL | **Not yet Implemented**
Expand Down
22 changes: 20 additions & 2 deletions docs/topics/calculation-engine.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ formula calculation capabilities. A cell can be of a value type
which can be evaluated). For example, the formula `=SUM(A1:A10)`
evaluates to the sum of values in A1, A2, ..., A10.

Calling `getValue()` on a cell that contains a formula will return the formula itself.

To calculate a formula, you can call the cell containing the formula’s
method `getCalculatedValue()`, for example:

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

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

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:
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.

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:

```php
$spreadsheet->getActiveSheet()->getCell('E11')->isFormula();
```
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.

For more details on working with array formulas, see the [the recipes documentationn](./recipes.md/#array-formulas).

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:

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

#### Array arguments for Function Calls in Formulas

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.
In these cases, the result may be a single value rather than an array; or it may be a `#VALUE!` error.

#### Operator precedence

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

#### PHP `DateTime` Objects
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit addc83b

Please sign in to comment.