Commit Graph

3988 Commits

Author SHA1 Message Date
MarkBaker 79d817fcdf Update to ReadMe 2023-03-01 19:24:22 +01:00
Mark Baker 51026a4807 Merge pull request #3424 from PHPOffice/ReferenceHelper_Stricter-TypingCasting
Stricter typing for ReferenceHelper methods
2023-03-01 18:55:45 +01:00
Mark Baker 6d5af9338f Merge branch 'master' into ReferenceHelper_Stricter-TypingCasting 2023-03-01 18:50:25 +01:00
oleibman 1fc9728818 PhpStan 10.3 (#3425)
Address the usual collection of new messages. This will supersede PR #3417 and PR #3421.
2023-03-01 09:28:58 -08:00
MarkBaker 09acdab939 Stricter typing for ReferenceHelper methods; and performance improvements for cell sorting in ReferenceHelper callbacks
Scrutinizer can only be appeased by adding extra code to pre-define variables that don't need to be pre-defined, and that makes for additional code overhead in a routine that needs to be as performant as possible; so "scrutinizer be damned!"
2023-03-01 18:09:12 +01:00
dependabot[bot] 9a4c6a1d2b Bump squizlabs/php_codesniffer from 3.7.1 to 3.7.2 (#3420)
Bumps [squizlabs/php_codesniffer](https://github.com/squizlabs/PHP_CodeSniffer) from 3.7.1 to 3.7.2.
- [Release notes](https://github.com/squizlabs/PHP_CodeSniffer/releases)
- [Commits](https://github.com/squizlabs/PHP_CodeSniffer/compare/3.7.1...3.7.2)

---
updated-dependencies:
- dependency-name: squizlabs/php_codesniffer
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 08:33:32 -08:00
dependabot[bot] fe62c40048 Bump friendsofphp/php-cs-fixer from 3.14.3 to 3.14.4 (#3422)
Bumps [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) from 3.14.3 to 3.14.4.
- [Release notes](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases)
- [Changelog](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.14.3...v3.14.4)

---
updated-dependencies:
- dependency-name: friendsofphp/php-cs-fixer
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 07:10:11 -08:00
dependabot[bot] 99dbf040cf Bump mitoteam/jpgraph from 10.2.4 to 10.2.5 (#3419)
Bumps [mitoteam/jpgraph](https://github.com/mitoteam/jpgraph) from 10.2.4 to 10.2.5.
- [Release notes](https://github.com/mitoteam/jpgraph/releases)
- [Commits](https://github.com/mitoteam/jpgraph/compare/10.2.4...10.2.5)

---
updated-dependencies:
- dependency-name: mitoteam/jpgraph
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 06:52:45 -08:00
dependabot[bot] 8b62e799ec Bump phpunit/phpunit from 9.6.3 to 9.6.4 (#3418)
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.3 to 9.6.4.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/main/ChangeLog-9.6.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.6.3...9.6.4)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-01 06:43:00 -08:00
Mark Baker 717a44ae1d Merge pull request #3413 from PHPOffice/Issue-3412_Date-Format-with_decimals-interpreted-as-Number-Format
Modify Date/Time check in the NumberFormatter for decimal/fractional times
2023-02-28 12:56:05 +01:00
MarkBaker c71aedeb56 Modify Date/Time check in the NumberFormatter so that masks with a decimal/fractional time aren't misinterpreted as number masks, while still ensuring that durations are interpreted as date/time masks, and locale currency masks are still treated as numbers
A date/time with a decimal time shouldn't have a digit placeholder __before__ the decimal point, only after
2023-02-28 12:34:00 +01:00
MarkBaker d01577dfeb Update Change log 2023-02-27 17:28:35 +01:00
Mark Baker e87e0b44b9 Merge pull request #3407 from PHPOffice/Fix-docs-typo
Documentation updates
2023-02-27 17:28:00 +01:00
MarkBaker e24b9a542d Documentation updates 2023-02-27 17:07:45 +01:00
Mark Baker e1c66a5d31 Merge pull request #3402 from PHPOffice/Issue-3368_Absolute-Cell-References-on-Insert-Delete
Absolute References in Cell Formulae should always be updated when inserting/deleting rows/columns
2023-02-27 16:44:02 +01:00
MarkBaker 2daef6d2f2 Issue 3368 - Absolute References in Defined Names should always be updated when inserting/deleting rows/columns
Note: If we delete the entire range that is referenced by a Named Formula, MS Excel sets the value to #REF! PhpSpreadsheet still only does a basic adjustment, so the Named Formula will still reference Cells.
2023-02-27 15:40:56 +01:00
MarkBaker 09fc1eb9e7 Issue 3368 - Absolute References in Cell Formulae should always be updated when inserting/deleting rows/columns 2023-02-26 01:21:37 +01:00
MarkBaker 03275330e6 Prepare Change Log for next release 2023-02-25 13:31:04 +01:00
MarkBaker 6e81cf39bb Update Change Log for release 1.28.0 2023-02-25 13:24:49 +01:00
Mark Baker 69e942a9b7 Merge pull request #3401 from PHPOffice/NumberFormatter-Improved-Fractions
Allow use of # and 0 digit placeholders in fraction masks
2023-02-25 13:11:20 +01:00
MarkBaker 0ebbb3297d Allow use of # and 0 digit placeholders in fraction masks 2023-02-25 12:48:53 +01:00
oleibman 324e19035f Xls Reader Conditional Styles (#3400)
The code currently allocates the style object as a non-conditional style, leading to corruption when the spreadsheet is written out.

That being said, Font Color is the only Conditional Formatting I have gotten to work for Xls for read or write. Use of other styles will essentially continue to be ignored, but will at least no longer result in corrupt spreadsheets.
2023-02-24 18:11:38 -08:00
Mark Baker 006e5ddf9a Merge pull request #3399 from PHPOffice/Issue-3395_AutoFit-AutoFilter-Header-Centre-Aligned
Allow for Table AutoFilter Header Center Alignment for AutoFit column sizing
2023-02-24 21:44:58 +01:00
MarkBaker 6409af4dcc When a Worksheet has an AutoFilter, make allowance for Center Alignment in the filter heading when calculating AutoFit column widths. 2023-02-24 21:24:46 +01:00
oleibman 4e2bca19ff Update Change Log (#3398)
Add some recent changes.
2023-02-24 07:48:47 -08:00
oleibman ab420f4499 Coerce Bool to Int for Mathematical Operators on Arrays (#3392)
* Coerce Bool to Int for Unary Operation on Arrays

Fix #3389. It seems some functionality was left behind when JAMA was eliminated (PR #3260). In particular, it is apparently a known trick to use double negation on boolean values as arguments to functions like SUMPRODUCT.

* Fix 3396

Treat booleans in arrays as int for mathematical operators as well.

* Edge Case

When array operand was neither numeric nor boolean, PhpSpreadsheet had always been evaluating the operand as #NUM!. It will now propagate an error string like #DIV/0!, and treat non-error strings as #VALUE!, consistent with Excel.
2023-02-23 23:11:22 -08:00
oleibman 6925b7f621 Conditional Formatting Improvements for Xlsx (#3372)
* WIP Conditional Formatting Improvements for Xlsx

Fix #3370. Conditional styles are always generated with 5 borders (right, left, top, bottom, diagonal) even though the border style is none in each case. For the spreadsheet in question, top and bottom were inappropriate and interfered with the desired formatting. A new border style, BORDER_OMIT is added which will cause the Xlsx Writer to not generate that style. All conditional borders will be initialized with that value. Any border included in the Xml will, of course, change it to the specified type.

Fix #3202. User wants a condition to use "No format set" as you can in Excel. A new boolean property `$noFormatSet`, along with setter and getter, is added to Style/Conditional. It is initialized to false. User can call setter to change it. More importantly for the issue in question, if the Xlsx Reader encounters a `cfRule` tag which does not have a `dxfId` attribute (i.e. no style is associated with the rule), it will set noFormatSet to true. Similarly, the Xlsx writer will not generate a `dfxId` tag when noFormatSet is true.

This change is applicable only to Xlsx. Html, Csv, and Ods do not have support for Conditional Formatting. Limited support was added to Xls with PR #2696 in April 2022 and PR #2702 about a month later. However, with the current release code, Xls equivalents of the two new test spreadsheets in this PR are too complicated to be handled correctly by PhpSpreadsheet - loading and then saving them as Xls results in Excel complaining of corruption, and the results don't meet expectations. Since I have no idea how BIFF works, and since the problems with those spreadsheets are not caused by this PR, I am not planning to address those problems at this time.

* Update Documentation, Write Alignment and Font Less Often

It doesn't cause any particular harm except for small increases in file size and run time, but Alignment tags are written even when (a) all its attributes are null for Conditional Formatting, and (b) when the xml specifically indicates that Alignment should not be applied. Similarly, Font is written even when all its attributes are null for Conditional Formatting.

There are some errors in the Conditional Formatting documentation. Specifying a solid fill color in a Conditional Style requires the use of endColor, not StartColor. The discussion of Order of Evaluating is not entirely accurate. I have changed it to what I believe is an accurate explanation of how Excel works; and also added a mention that other spreadsheet programs might not work the same way, adding a couple of illustrations of the difference. The description of the multiple conditions did not quite match the diagram. 'Stop if true' was a blank paragraph; it is now described, and the new 'No format set' option is described in that paragraph since (I think) it would be used most often in conjunction with 'Stop if true'.

* Xlsx Writer Allow StartColor for Conditional Solid Fill

To set a solid fill in a non-conditional style, you set StartColor (xml will use that value as fgColor and a default value as bgColor). If you instead set EndColor (xml will use that value as bgColor and a default value as fgColor), the styling will not work as expected.

However, for conditional styles, if you set StartColor (xml will use that value as fgColor and not specify bgColor), the styling will not work as expected. If you instead set EndColor (xml will use that value as bgColor and not specify fgColor), the styling will work as expected.

Together, this means that you need to use different methods for non-conditional style fill than for conditional style fill. This isn't a big problem, but it is a bit weird. This PR changes Xlsx Writer so that if (a) fill is olid and (b) startColor is specified and (c) endColor is null, the xml will be written as bgColor without specifying fgColor. This means that you can set StartColor for both conditional and non-conditional and get the expected styling. You may, of course, continue to specify EndColor instead for conditional.

* Fix Some (Not Many) Xls Problems

I will open an issue for the (pre-existing) remainder.
2023-02-23 22:28:22 -08:00
oleibman 378beac8f2 Xls Writer Parser Handle Boolean Literals as Function Arguments (#3391)
Fix #3369. The parser had failed to account for `TRUE` and `FALSE` when supplied as arguments to a function.

I had hoped to be able to do something about its inability to handle defined names as well. I failed. I think another section might need to be added to the Writer output which specifies the defined names. I haven't yet located any suitable documentation.
2023-02-23 10:54:54 -08:00
Mark Baker 014a120b4e Merge pull request #3394 from PHPOffice/NumberFormat_decimal-placing-with-question-mark
Improved handling for ? placeholder in Number Format Masks
2023-02-22 20:41:40 +01:00
MarkBaker acdcb0b0a2 Refactoring and simplification of replacement code 2023-02-22 20:14:47 +01:00
MarkBaker f468e78b66 Improved handling for ? placeholder in Number Format Masks 2023-02-22 12:55:21 +01:00
Mark Baker 4cefd7a889 Merge pull request #3388 from PHPOffice/NumberFormat_Scaling-Unit-Tests
Additional unit tests for scaling values in Number Format Masks
2023-02-21 13:40:07 +01:00
MarkBaker e812b49bb6 Additional unit tests for scaling values in Number Format Masks 2023-02-21 13:20:23 +01:00
Mark Baker 3102822341 Merge pull request #3387 from PHPOffice/NumberFormat_Additional-Tests
Fix handling for a # symbol in quotes inside a number format mask
2023-02-21 04:00:39 +01:00
MarkBaker 5cf4e2cca1 Fix handling for a # symbol in quotes inside a number format mask 2023-02-21 03:17:08 +01:00
oleibman ac1172810e Another Xls Coverage Change (#3385)
I hadn't noticed some minor corruption in a file. It is fixed. Xls now supports BAHTTEXT as _xlfn.BAHTTEXT, not as an index to a list of built-in functions, so it is no longer suitable for this test and is removed from the spreadsheet. TRANSPOSE changes, e.g. A1:B2 to {1,2;3,4}, and the Xls Writer Parser has trouble with that, so its test is also removed from the test spreadsheet.
2023-02-20 12:15:22 -08:00
Mark Baker 41c1b348ed Merge pull request #3386 from PHPOffice/NumberFormatMask-Tweak
Adjust regexp for an explicit 0 for a decimals value when using Currency and Accounting locale masks
2023-02-20 20:41:22 +01:00
MarkBaker c70de6b660 Adjust regexp for an explicit 0 for a decimals value when using Currency and Accounting Number Format Wizards with a locale, to require at least one digit after a dot to ensure this is a decimal and not a text literal 2023-02-20 20:16:55 +01:00
Mark Baker de01e59ad0 Merge pull request #3384 from PHPOffice/NumberFormat-Wizards_Currency-Accounting-zero-decimals
Explicit 0 for a decimals value when using Currency and Accounting NumberFormat Wizards with a locale
2023-02-20 19:56:10 +01:00
MarkBaker 207d029c26 Allow use of an explicit 0 for a decimals value when using Currency and Accounting Number Format Wizards with a locale, to indicate whole currency units only, no minor units 2023-02-20 18:34:59 +01:00
oleibman 33eefe7c9d Resolve Phpstan Messages - FINALE - Shared/OLE (#3364)
* Resolve Phpstan Messages - FINALE - Shared/OLE

Reduce number of Phpstan messages by addressing their issues. This is the last of a series of related tickets to achieve that end. Only a handful of messages will be left in Phpstan baseline after this change is merged.

Shared/Ole.php and Shared/Ole/ChainedBlockStream.php were completely uncovered in the test suite. So I wrote some tests and found they didn't work at all. There were 2 problems. The first was that ChainedBlockStream checks for a mode of `r`, but Ole invokes it with mode `rb`. ChainedBlockStream will now just check the first character of the mode.

The second was a more interesting problem. Ole was reading "an *unsigned* long". However, what it should have been reading was "a 32-bit *signed* long". The irony of this mismatch is that, once the mode problem was corrected, 32-bit Php handled Ole and ChainedBlockStream correctly, but 64-bit Php did not. The code is corrected to work properly for both 32- and 64-bit.

* Scrutinizer

2 dead assignments - sufficient to just make calls which are expected to fail.
2023-02-20 06:40:02 -08:00
oleibman 28fb962cdb Complete Functions Coverage for Xls (except GETPIVOTDATA) (#3383)
Finish the work started in PR #3371 and PR #3340.
2023-02-20 06:07:12 -08:00
Mark Baker 15e1451b3d Merge pull request #3382 from PHPOffice/Issue-3381_Scientific-NumberFormat-Decimal-Precision
Issue 3381 - Fix decimal precision for Scientific Number Format Mask
2023-02-20 13:26:06 +01:00
MarkBaker c0b60fcb76 Issue 3381 - Fix decimal precision for Scientific Number Format Mask 2023-02-20 12:20:49 +01:00
Mark Baker 169a87a752 Merge pull request #3379 from PHPOffice/Issue-3378_Improve-NumberFormat-Mask-Date-Identifier
Adjust identifier for Date Format Masking to prevent it picking out c…
2023-02-18 21:13:08 +01:00
Mark Baker 5b105debdf Merge branch 'master' into Issue-3378_Improve-NumberFormat-Mask-Date-Identifier 2023-02-18 20:59:08 +01:00
MarkBaker 431bd5178e Adjust identifier for Date Format Masking to prevent it picking out currencies with locales containing the letters h, m, s, d and y as dates 2023-02-18 17:46:23 +01:00
oleibman 1f94687f1c Resolve Phpstan Messages - Writer Xls Worksheet (#3363)
Reduce number of Phpstan messages by addressing their issues.
2023-02-18 07:44:26 -08:00
Mark Baker 3beef1f559 Merge pull request #3377 from PHPOffice/AdvancedValueBinder_Additional-Minor-Tweaks
Adjust CURRENCY_USD and CURRENCY_EUR constants
2023-02-18 02:04:01 +01:00
MarkBaker 292dd9073f Adjust CURRENCY_USD and CURRENCY_EUR constants to rationalise and eliminate quoted currency symbols in favour of bracketed symbols 2023-02-18 01:39:29 +01:00