Commit Graph

3708 Commits

Author SHA1 Message Date
MarkBaker a7259de437 Explicitly prevent serialization of the Spreadsheet object 2022-11-22 00:12:09 +01:00
MarkBaker 8955859925 Update FAQ 2022-11-21 21:15:49 +01:00
Mark Baker b6f9ef17fe Merge pull request #3198 from PHPOffice/Github-CI_PHP-7.3-Issue
See if reintroducing PHP 7.3 in the matrix fixes the CI Workflow issue
2022-11-21 15:45:25 +01:00
MarkBaker 596a00bf69 This is going to be a real pain 2022-11-21 15:16:36 +01:00
MarkBaker 575a1efb2b Heaven only knows why the CI pipelines are complaining about a PHP 7.3 issue; all references to PHP 7.3 should have been removed from the workflows
Re-introducing 7.3 now, just to try and ensure that all checks pass, so that the 7.3 weirdness won't be a blocker for merging
2022-11-21 15:11:30 +01:00
Mark Baker 8b9b32d647 Merge pull request #3197 from PHPOffice/BugFix_Default-arguments-for-TEXTJOIN
Support null and empty values in TEXTJOIN()
2022-11-21 15:02:45 +01:00
MarkBaker 9f6bbd71b6 BugFix - Support null values in TEXTJOIN() text values as well as empty strings
Allow default values for TEXTJOIN() delimiter and ignore_empty... even though the official MS documentation lists them as required arguments, they are actually optional
2022-11-21 14:35:42 +01:00
Mark Baker f1be181858 Merge pull request #3194 from PHPOffice/ConditionalFormatting_Eliminate-duplicate-setter-code
Eliminate duplicate call to set Conditional Styles in the model when loading an Xls file
2022-11-20 21:59:59 +01:00
Mark Baker db1988e976 Merge branch 'master' into ConditionalFormatting_Eliminate-duplicate-setter-code 2022-11-20 21:47:18 +01:00
Mark Baker 1429999f0b Merge pull request #3193 from PHPOffice/Issue-2871_Merge-Cells-Bugfix-and-Performance
Eliminate call to getFormattedValue() when not required
2022-11-20 21:46:55 +01:00
MarkBaker bc3903a751 Eliminate call to getFormattedValue() when not required 2022-11-20 10:04:49 +01:00
MarkBaker 2e356821b3 Eliminate duplicate call to set Conditional Styles in the model when loading an Xls file 2022-11-18 10:41:22 +01:00
Adrien Crivelli 8f40b9841a Update GitHub Actions 2022-11-17 14:35:42 +01:00
Mark Baker 26cb1c1bcf Merge pull request #3163 from fox34/chart-write-y-axis-line-styles
Chart: Correctly handle axis line styles
2022-11-17 10:46:38 +01:00
fox34 95d929441c Test different colors for different axis 2022-11-15 11:35:07 +01:00
fox34 8714b2e728 Also verify x-axis line color 2022-11-14 17:14:17 +01:00
fox34 4e6ac96e07 Remove unused imports 2022-11-14 16:51:41 +01:00
fox34 97c1a421ff Removing whitespace at end of line 2022-11-14 16:45:05 +01:00
fox34 d9d2484341 Formatting: Indent empty lines 2022-11-14 16:41:49 +01:00
fox34 18714e3ba2 Read axis line styles correctly 2022-11-14 16:39:34 +01:00
fox34 894b78eb2f Merge branch 'master' into chart-write-y-axis-line-styles 2022-11-14 16:05:21 +01:00
fox34 c2cdc36bb3 Create PR3163Test.php 2022-11-14 16:04:13 +01:00
fox34 e6d5616e2b Include PR in Changelog 2022-11-12 10:05:42 +01:00
Mark Baker c928bfd048 Merge pull request #3164 from PHPOffice/CalcEngine-Refactor_Formatted-Numbers
Refactoring for checks on strings containing formatted numeric values
2022-11-11 17:19:05 +01:00
MarkBaker 6a50973a8b Update Change Log 2022-11-11 12:28:26 +01:00
MarkBaker d7a2315c8e Additional unit tests 2022-11-11 12:28:26 +01:00
MarkBaker f5beafd845 Refactoring for checks on strings containing formatted numeric values when used in mathematical operations in the Calculation Engine 2022-11-11 12:28:26 +01:00
fox34 f574456ff0 Update CHANGELOG.md 2022-11-10 13:37:01 +01:00
fox34 ff10c83e09 Write line styles for chart y-axis
Bugfix: Also write line styles for y-axis of charts
2022-11-10 13:34:51 +01:00
Mark Baker 6f71efcb58 Merge pull request #3156 from fdjohnston/master
Convert percentages stored as strings to numerics in formula calculations
2022-11-10 12:10:03 +01:00
Mark Baker 04fb3bb37a Merge branch 'master' into master 2022-11-10 10:55:29 +01:00
Mark Baker 8a06e1b846 Merge pull request #3160 from PHPOffice/Version_PHP74_Minimum
Drop support for PHP 7.3
2022-11-10 10:31:59 +01:00
MarkBaker 6f3f450101 Improve readability 2022-11-10 10:11:07 +01:00
MarkBaker 64a197ee42 Styling fixes 2022-11-10 09:45:01 +01:00
MarkBaker 2ee4542c75 Add PHP 8.2 to "must pass", and "nightly" to "allow fail" 2022-11-10 04:22:54 +01:00
MarkBaker 36c25b4427 Drop support for PHP 7.3 2022-11-09 22:55:31 +01:00
fjohnston@avatarasoftware.com bb845fae23 Further Simplification
As was pointed out, the entire `pow` piece, as well as extracting exponent and exponent sign, was not necessary as casting to `float` will correctly handle scientific notation in a string.
Also added case-insensitive flag to the regexp to handle upper and lower case `e`.
2022-11-09 14:57:28 -05:00
fjohnston@avatarasoftware.com 0b350b144b Slight optimization: Only use pow if exponent is greater than zero
Originally thought I was being clever by using zero in `pow` to get 1, however after thinking about it all day I think it's probably better to avoid the call to `pow` if the exponent is zero; one less function call that has to be made.

I didn't take the time to look into benchmarks of `pow` to the zero vs the ternary to multiply by 1, but my gut tells me this is likely slightly faster.
2022-11-09 14:27:16 -05:00
oleibman f3c181dffb Update Change Log 2022-11-08 (#3158)
Add several changes merged since last similar change 2022-10-20.
2022-11-08 23:28:44 -08:00
oleibman bbfaa0c336 Eliminate Some Scrutinizer 'Major' Problems Part 4 (#3154)
* Eliminate Some Scrutinizer 'Major' Problems Part 4

Mostly docblock changes and annotations. Some code changes. A few more of these to go still.

* Missed a Couple

Fix them now.
2022-11-08 18:04:48 -08:00
fjohnston@avatarasoftware.com ab7b3b10f9 Using Named Capture groups to handle edge cases
Implemented the suggested named capture groups (nice trick) in the regexp to pull out only the values we need to perform the calculation.  Making use of the null coalescing operator to keep things nice and clean.  Note that I did have to add the `PREG_UNMATCHED_AS_NULL` to `preg_match` to ensure PHP returned null (since null coalescing only works on null and not '') when a match wasn't found for a capture group.

Also extended the regular expression to handle scientific notation (both positive and negative, and positive and negative exponents) as well as a negative symbol before or after a leading percentage sign.
2022-11-08 12:32:15 -05:00
oleibman 8de218f575 Problems Formatting Very Small and Very Large Numbers (#3152)
* Problems Formatting Very Small and Very Large Numbers

Fix #3128 (author found a workaround but the problem remains). For some complex masks, when a cast of the cell value from float to string results in the use of scientific notation, the result of the formatting is unusable. I believe this PR solves the problem for numbers close to zero (Php cast from float to string uses scientific notation starting with 1E-5), and for a range of large numbers which are not handled correctly now.

However, I have not found a way to ensure that the results match Excel for very large numbers (1E18 or larger); this change at least ensures that the resulting string is an accurate rendition of the number (which is not the case now) even if doesn't match Excel. As an example, if you use the mask reported in the original issue `0 000.0` and enter a value of 1E90 into the cell, Excel will show it as 1 followed by 87 zeros, a space, 3 more zeros, decimal point and zero. I have not figured out how to get PhpSpreadsheet to do that; for now, it will just return the formatted value as 1 followed by 90 zeroes instead (I might have chosen to go with scientific notation instead). I will continue to think about those, but do not feel it is worth delaying the improvements in this ticket while I do so.

The affected section of code also truncated to the appropriate precision. It now rounds, as Excel does.

This seemed to be an area of code where problems might arise on 32-bit systems, and, indeed, I found something in the formatting code which had to be changed for 32-bit to work correctly. As long as I was doing that anyhow, I ran the full test suite, and found that Php8.1 had introduced some new stringencies which caused problems in a handful of places. All were found in Xls Reader, and all are corrected now.

* Remove Dead Assignment

Scrutinizer will be happy now.
2022-11-07 06:36:04 -08:00
Jokūbas e05e354e14 Fix ODS read filter on number-columns-repeated cell (#3149) 2022-11-06 09:43:50 -08:00
fjohnston@avatarasoftware.com dc5c6b9f12 Tightening up percentage check
As suggested, the initial check has been tightened up using a regular expression.
Expressing allows for leading and trailing spaces, leading and trailing percentage symbols, with spaces mixed throughout.
Added 57 permutations of leading and trailing spaces, leading and trailing percent symbols, decimals, and negatives.  All seem to be working.  I will also attach an Excel worksheet that verifies the behaviour of all 57 test cases aligns with Excel.
2022-11-06 12:31:49 -05:00
Mark Baker a5868a04e5 Merge pull request #3157 from PHPOffice/Feature_Images-from-string-or-streams
Feature - Create In-Memory Images from strings or streams
2022-11-06 16:21:41 +01:00
Mark Baker c5a07daa6f Merge branch 'master' into Feature_Images-from-string-or-streams 2022-11-06 16:03:30 +01:00
MarkBaker c3bab5c030 Update Documentation 2022-11-06 15:36:06 +01:00
MarkBaker 4a55c14f8d Update Change Log 2022-11-06 15:36:06 +01:00
oleibman fac0e46c91 MATCH Problems with Int/Float Compare and Wildcards (#3142)
* MATCH Problems with Int/Float Compare and Wildcards

Fix #3141. Function matchSmallestValue did not recognize that an integer could match a float. Adding test cases, it seems that matchFirstValue had the same problem. However, matchLargestValue seemed to handle things correctly - but see below.

In addition, the wildcard logic in matchFirstValue is faulty. It ignored tilde as a wildcard character. Although it would have been easy to just add that, I think it was wrong to determine on its own if a wildcard was in use. Just using the already available wildcard functions whenever comparing two strings is sufficient.

I note that Excel doesn't seem to follow its own rules for MATCH (https://support.microsoft.com/en-us/office/match-function-e8dffd45-c762-47d6-bf89-533f4a37673a?ns=excel&version=90&syslcid=1033&uilcid=1033&appver=zxl900&helpid=xlmain11.chm60112&ui=en-us&rs=en-us&ad=us). PhpSpreadsheet's results match Excel's, so no problem. However, when match_type is not zero, the match array is supposed to be sorted, so I would expect `#N/A` when it isn't; but that's not how Excel operates. I have no idea what Excel is doing. If `MATCH(2,{2,0,4,3},1)` isn't `#N/A` because of the unsorted array, then surely it should be `1` (item 1 of the array is the largest number less than or equal to the lookup value); but Excel and PhpSpreadsheet (before and after changes) return `2`. I have moved this example to be the first of the test cases.

One would think strings would behave similarly. But, no - see the second test case. This time Excel does look for an exact match. But the existing logic doesn't get the matching result in PhpSpreadsheet. It requires a whole new block of code, one which doesn't work correctly for numeric lookup value. Ugh.

LibreOffice doesn't always agree with Excel. It seems that it will use wildcard matching even when the match type is not zero (Excel documentation says wildcards are only for type zero, which is just as well because I don't really know what greater/less mean when wildcards are involved). I have not attempted to duplicate this behavior. For the record, Gnumeric agrees with Excel here.

* More Changes - LibreOffice

Add support for LibreOffice matching wildcard strings when type is not zero. Add support for type to be specified as integer other than 0/1/-1, or as float, or as numeric string; non-numeric string should case `#VALUE!` error.

I have found an example of undefined behavior (unsorted array where type is non-zero) where PhpSpreadsheet does not produce the same result as Excel. It is present as a new `incomplete` test case. I can fix it, but not without breaking other tests where the proper behavior is undefined. IMO, this is not a problem we should be concerned about.

Many test cases are added. Chances are I will add some more before merging this change.
2022-11-04 15:51:00 -07:00
MarkBaker b06d39658b Provide functionality allowing creation of an in-memory image from stream data, (note that it does create a temporary local file as part of the process) 2022-11-04 20:50:13 +01:00