3975 Commits

Author SHA1 Message Date
MarkBaker 15a42d0d6b Prepare Change Log for next release 2023-02-25 13:33:05 +01:00
MarkBaker c4d3b209cc Merge branch 'master' into release 2023-02-25 13:31:32 +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
Mark Baker a241792b35 Merge pull request #3376 from PHPOffice/AdvancedValueBinder-Localisation
Advanced value binder localisation and Improvements
2023-02-17 13:58:02 +01:00
MarkBaker 22aa65d802 Additional unit tests 2023-02-17 13:31:45 +01:00
MarkBaker f9ef1e0e7d Additional unit tests 2023-02-17 13:29:21 +01:00
MarkBaker 6ca7ec5d5b Make boolean check case-insensitive 2023-02-17 13:14:20 +01:00
MarkBaker 5072ffb23a Improve support for locale settings and currency identification in the Advanced Value Binder 2023-02-17 12:37:18 +01:00
Mark Baker d49bc40573 Merge pull request #3374 from PHPOffice/CalcEngine_Formatted-Number-Localisation
Improve support for locale settings in the Calculation Engine formatted number matcher
2023-02-17 08:16:58 +01:00
MarkBaker 3d7964f568 Improve support for locale settings in the Calculation Engine formatted number matcher 2023-02-17 08:03:28 +01:00
Mark Baker d029042429 Merge pull request #3373 from PHPOffice/CalcEngine_Formatted-Currency-Expand-Currency-Range
Allow a range of different potential currency codes in the currency matcher regexp
2023-02-17 06:43:42 +01:00
Mark Baker 3dd486208b Merge branch 'master' into CalcEngine_Formatted-Currency-Expand-Currency-Range 2023-02-17 06:37:44 +01:00
MarkBaker 4aaf1f61b9 Allow a range of different potential currency codes (including the locale code) in the currency matcher regexp
(dollar, euro, pound sterling and yen)
2023-02-17 06:16:10 +01:00
oleibman 9e1378d806 Resolve Phpstan Messages - Statistical/Trend and Shared/Trend (#3362)
* Resolve Phpstan Messages - Statistical/Trend and Shared/Trend

Reduce number of Phpstan messages by addressing their issues. The changes in this PR are all to doc blocks; no executable code is changed.

* Scrutinizer

1 mystifying "new" error (matches "old" error), 2 updated doc blocks.
2023-02-16 19:18:02 -08:00
oleibman df9e0da514 Additional Functions Coverage for Reader Xls (#3371)
PR #3340 increased coverage in Reader Xls for most functions. Some of the omissions from that PR (see below) were intended from the start. However, the set of (BINOMDIST, EXPONDIST, GAMMADIST, NORMDIST, POISSON, WEIBULL, and FIXED) were not intended to be omitted; they just did not seem to work. Having had time to research, it appears that the problem is not those functions themselves, but rather the use of Boolean constants as function arguments (see issue #3369). Knowing that, it is possible to add those missing functions back in, just taking care to use `0` or `1` or `TRUE()` or `FALSE()` rather than boolean constants as arguments. No update to source or test code; just adding a few new cells to an Xls spreadsheet.

Functions still omitted because they return array results:
- GROWTH
- LINEST
- LOGEST
- MINVERSE
- MMULT
- TRANSPOSE
- TREND

Functions still omitted because they are not implemented in PhpSpreadsheet:
- BAHTTEXT
- CELL
- FREQUENCY
- GETPIVOTDATA
2023-02-15 22:21:15 -08:00
oleibman 8df86e4236 Add Tests for Shared XmlWriter (#3365)
Fill in some very minor coverage gaps.
2023-02-14 21:38:06 -08:00
Mark Baker 5405eafcec Merge pull request #3361 from PHPOffice/Cell-SetValue-Binder-Override
Allow override of the Value Binder when setting a Cell value
2023-02-14 10:28:59 +01:00
MarkBaker b40e131b78 Allow override of the Value Binder when setting a Cell value 2023-02-14 10:13:35 +01:00