Commit Graph

801 Commits

Author SHA1 Message Date
MarkBaker f6fcc4de87 More unit testing for inserting/deleting rows/columns with DataValidation, ConditionalFormatting and PrintArea 2022-03-17 15:48:30 +01:00
Mark Baker 6a190d650c
Merge branch 'master' into Issue-2678_Update-CF-Ranges-and-Conditions-on-Insert/Delete 2022-03-17 11:52:57 +01:00
MarkBaker 6faf828db7 Fix issues with updating Conditional Formatting when inserting/deleting rows/columns
- Update existing ranges, expanding if necessary, rather than trying to clone for each individual cell
 - Update conditions, so that cell references and formulae are maintained correctly

Note that absolute as well as relative cell references should be updated in conditions
2022-03-17 11:37:15 +01:00
oleibman 9428552d94
Add editAs Property for 2-cell Anchor Drawings (#2674)
* Add editAs Property for 2-cell Anchor Drawings

This change builds on PR #2532 (@naotake51 as PR #2532), using ideas from PR #2237 (@AdamGaskins), which has had changes requested for several months. It covers a lot of the same ground as 2532. In Excel, two-cell anchor drawings can be edited as "twocell", "onecell", or "absolute". This PR adds support for those options, with a sample file that demonstrates the difference in addition to unit tests. Several other tests are added to improve the spotty coverage for Drawings.

There have been several other tickets referencing two cell anchors, including issue #1159 and PR #1160 (@sgarwood, who also added support for editAs), PR #643, and issue #126, all now closed but not necessarily entirely resolved. I will try to ensure that those tickets are addressed with this one.

And, in trying to make sure 1160 is covered, I stumbled upon a bug. If you use the same image resource to create two+ memory drawings, the MemoryDrawing destructor for the first will cause the rest to generate a very long warning message. This is not a problem for Php8+, only for Php7-. I have suppressed the message in the MemoryDrawing constructor. 1160 went stale due to an unresolved test error, but I don't think this was the problem. At any rate, its test works now.

* Scrutinizer

It reported 1 minor issue (fixed normally), and 2 major. One is fixed with a kludge. The other is a case where Scrutinizer's analysis is just wrong, and I can't figure out a kludge. But I was able to add an annotation (the first time I've managed to get one past phpcs/php-cs-fixer). We'll see.
2022-03-16 16:12:38 -07:00
MarkBaker ec15c7a6de more minor tweaks 2022-03-16 23:03:19 +01:00
MarkBaker 4881e2ae9e Validte that lookup arrays are actually arrays 2022-03-16 21:30:19 +01:00
MarkBaker 4bc3ed9cc1 Provide $includeAbsoluteReferences option for the CellReferenceHelper when updating cell addresses 2022-03-16 19:14:50 +01:00
MarkBaker bbe6b8082e Some additional unit tests for the ReferenceHelper
And a bugfix when deleting cells that contain hyperlinks (the hperlinks weren't being deleted, so were being "inherited" by whatever cell moved to that address)
2022-03-16 16:38:08 +01:00
MarkBaker 6f84780bb9 Some work on refactoring the ReferenceHelper to extract the logic for updating cell references. This is a preliminary step toward allowing updates to absolute cell references, required to update Conditional Formatting rules. 2022-03-16 14:07:13 +01:00
MarkBaker 750e42c024 More refactoring of the reference helper; and unit tests to validate insertion/removal of rows/columns from an autofilter range 2022-03-13 21:13:24 +01:00
oleibman 68158c8120
Phpstan Differences from Php7 to Php8, Again (#2665)
These changes have already been implemented twice, and been regressed twice. I'll try once more (with a different approach), then give up ...

As configured, Phpstan running under Php7 reports no errors. However, running under Php8, it reports 100 (!) errors. The vast majority of these are due to two reasons:
- renaming parameters in Php builtin functions in preparation for named parameters.
- using the new class GdImage rather than type resource as the argument type for many image-based functions.

Regardless of the cause, this will be a problem sooner or later. This PR is an attempt to get ahead of that problem. For source members, it mostly adds annotations or updates doc-blocks. Only 2 members have changes to executable code, and these are very minor - BitWise and Writer/Xlsx. For test members, all baseline errors are deleted and the code is fixed. Php7 and Php8 both report no errors with this configuration.
2022-03-11 23:28:30 -08:00
naotake51 572f4e94bd
Add two cell anchor drawing (#2532)
* Add two cell anhor drawing.

* Add "Support for two cell anchor drawing of images." to CHANGELOG.md

* Add pull-request link to "Support for two cell anchor drawing of images." of CHANGELOG.md
2022-03-09 19:21:47 -08:00
oleibman bd2e7b64a6
Handle Booleans in Conditional Styles (#2654)
You can set up a conditional style to, say, apply to cells equal to boolean values. For such conditions, the Excel XML specifies `TRUE` or `FALSE`. It is noteworthy that false matches empty cells as well as FALSE, but not 0; similarly TRUE does not match 1. The Xlsx Writer just casts these values to string, which will not work properly. The Xlsx Reader treats the values as strings, so it won't work properly either. This PR corrects both. Also the doc blocks in Style/Conditional allow bool in some places, but not in others; these are corrected but no executable code is changed there.
2022-03-09 18:30:57 -08:00
MarkBaker 044836b426 Unit test for the Calculation Engine debug log 2022-03-06 09:47:17 +01:00
MarkBaker dbf25f0721 Set Selected Cells for Worksheets in Gnumeric Loader 2022-03-05 19:24:21 +01:00
MarkBaker cba0e13b2a Escape double quotes in a string value unless it's an empty string value 2022-03-05 12:44:44 +01:00
Mark Baker dd981a3d77
Merge branch 'master' into CSV-Reader-Dataype-casting-improvements 2022-03-04 14:25:37 +01:00
oleibman e87be5e16d
Failing Test Requiring Too Much Precision (#2647)
The new array tests for IMCSC fail on my system because of a rounding error in the 14th (!) decimal position. This is not a real failure. Change the test to use only the first 8 decimal positions.
2022-03-04 00:11:04 -08:00
MarkBaker aad91f1d25 Merge branch 'master' into CSV-Reader-Dataype-casting-improvements
# Conflicts:
#	src/PhpSpreadsheet/Reader/Csv.php
2022-03-02 12:43:19 +01:00
MarkBaker f3d5028518 Work on setting up locale-aware formatted number conversion for the Csv Reader
Unit tests for locale-aware boolean conversion for Csv Reader
2022-03-02 08:53:29 +01:00
oleibman f575d2b8b2
Add Ability to Suppress Mac Line Ending Check for CSV Reader (#2623)
With the deprecation of `auto_detect_line_endings` in Php8.1, there have been some tickets (issue #2609 and PR #2438). Although the deprecation message is suppressed, users with a homegrown error handler may still see it. I am not very concerned about that symptom, but I imagine that there will be more similar tickets in future. This PR adds a new property/method to Reader/CSV to allow the user to avoid the deprecated code, at the negligible cost of being unable to read a CSV with Mac line endings even on a Php version that could support it.
2022-03-01 02:01:37 -08:00
oleibman 8258919d72
Phpstan Differences from Php7 to Php8 (#2631)
These changes were already implemented as PR #2428. They were, alas, regressed by PR #2585. If at first you don't succeed ...

As configured, Phpstan running under Php7 reports no errors. However, running under Php8, it reports 100 (!) errors. The vast majority of these are due to two reasons:
- renaming parameters in Php builtin functions in preparation for named parameters.
- using the new class GdImage rather than type resource as the argument type for many image-based functions.

Regardless of the cause, this will be a problem sooner or later. This PR is an attempt to get ahead of that problem. For source members, it tweaks only the Phpstan configuration files, without changing any PhpSpreadsheet code. For the small number of test members involved, the code is fixed. Php7 and Php8 both report no errors with this configuration.

Because this involves no changes to code, and because Phpstan baseline is a common cause of merge difficulties, I will probably merge this in a day or two, more quickly than I customarily do.
2022-03-01 01:53:12 -08:00
MarkBaker 99f488efc6 Resolve `translateSeparator()` method to handle separators (row and column) for array functions as well as for function argument separators; and cleanly handle nesting levels
Note that this method is used when translating Excel functions between en and other locale languages, as well as when converting formulae between different spreadsheet formats (e.g. Ods to Excel)

Nor is this a perfect solution, as there may still be issues when function calls have array arguments that themselves contain function calls; but it's still better than the current logic
2022-02-27 13:01:09 +01:00
MarkBaker 444d0fd77c Unit tests for merge ranges for Ods Reader/Writer 2022-02-26 22:51:15 +01:00
MarkBaker ef4029df63 Refactor ISO data type validation from cell to shared date; add extra checks for invalid dates; and appropriate unit tests 2022-02-26 14:13:12 +01:00
oleibman 9cf526a920
Reading Xlsx With Supplied Palette (#2595)
Fix #2499, which see for details of an obscure problem affecting both PhpSpreadsheet and Excel. Add support for palette contained in workbook styles. This seems to be a very rare occurrence, so allow it only when the palette contains exactly 64 entries. If there are other possibilities, we'll presumably have a new workbook to guide us how to handle them. Also add some tests for specification of indexed color without palette, another rarity (no in-range examples amongst our current files). Also change one private static array, initialized once at run-time and never changed, to a constant.
2022-02-23 22:09:22 -08:00
Thorsten Ho 0cb60a5098
Fix XLSX broken vertical align font style (#2619)
* Fix XLSX broken vertical align font style

* Add fix information to changelog

* Fix phpcs issues
2022-02-23 20:23:59 -08:00
Mark Baker 579145eb3c
Wrap actual file loading in protected methods, while just providing a stub `load()` method in the BaseReader abstract. This is to allow a wrapper in the file loader logic across all Readers, with a try/catch block that can be used to handle special loader settings. (#2620) 2022-02-23 21:31:57 +01:00
Mark Baker 16953e27d8
Adjust Cell Reference regexp in Calculation Engine to handle worksheet names containing quotes (#2617)
* Capture of worksheet name in Calculation Engine cell references modified to handle apostrophe and quote marks, and made non-greedy to avoid ensure that multiple quoted worksheet names in a formula aren't all captured in one go

* Split some of the unit tests into separate test classes
2022-02-22 15:55:59 +01:00
Mark Baker 3c57d9e291
Fix for issue #2614 (#2615)
* Fix for issue #2614

* Unit test (in ISREF() tests) that covers issue #2614
2022-02-22 09:06:10 +01:00
Mark Baker c9f948bd91
Initial work on implementing Array-enabled for the HLOOKUP() and VLOOKUP() functions (#2611)
* Initial work on implementing Array-enabled for the HLOOKUP() and VLOOKUP() functions

* In the MATCH() function, we should also use `evaluateArrayArgumentsIgnore()` because the lookupvalue and matchType arguments can be array arguments, but lookupArray is always a dataset matrix
2022-02-21 19:56:21 +01:00
Mark Baker db21d043fe
Implementation of the ISREF() information function (#2613) 2022-02-21 18:47:23 +01:00
Mark Baker 0ee4d96576
Array-enable the ISFORMULA() function (#2610)
Implement Array-enabled for  ERROR.TYPE() function
Extract ERROR.TYPE() function tests into separate test file
Extract error function tests into separate test files

And thus complete the implemented Information functions
2022-02-20 19:32:13 +01:00
Mark Baker 35b65bef8c
First steps toward array-enabling the information functions (#2608)
* First steps toward array-enabling the information functions

Also includes moving unit tests out from Functions and into a separate, dedicated Information folder

* Resolve issue with IF(), branch pruning and calculation cache (ensure that we don't convert the if condition to a bool before we've tested to see if it evaluates to an error)
More refactoring
2022-02-20 16:46:25 +01:00
oleibman 9893926ff9
Add Test For NULL=0 (#2607)
Fix #2523. This isn't actually a fix; the problem was reported and confirmed for 1.21, but had already been fixed in master (and remains fixed in 1.22). This PR just adds a unit test for the original problem.
2022-02-19 13:12:44 -08:00
Mark Baker 71927f5591
Issue 2551 array enable lookup ref functions (#2606)
* Start work on array-enabling the Lookup and Reference functions

Requires a new method (`evaluateArrayArgumentsSubsetFrom()`) in the `ArrayEnabled` Trait to handle functions where the arguments that need special array handling are trailing rather than leading arguments
2022-02-19 18:49:01 +01:00
Mark Baker c10d86eb9c
Start work on array-enabling the Lookup and Reference functions (#2602)
* Start work on array-enabling the Lookup and Reference functions

Requires a new method (`evaluateArrayArgumentsSubsetFrom()`) in the `ArrayEnabled` Trait to handle functions where the arguments that need special array handling are trailing rather than leading arguments
2022-02-19 18:36:50 +01:00
Mark Baker d5dc58d20e
Extract information functions (#2605)
* Split Information functions into a dedicated class and namespace and categorise as Value or Error
* Refactor all error functions into the new ExcelError class
2022-02-19 13:53:17 +01:00
Mark Baker 9c473682bc
Set precision for Database function unit tests, for RowColumnReference and Dimension Helper unit tests (#2604) 2022-02-18 21:37:26 +01:00
Mark Baker 0371ccb686
Convert all relevant Logical functions to support array arguments (#2600) 2022-02-18 02:56:23 +01:00
Mark Baker e580f10c46
Unit test some basic arra-formula chaining (#2599) 2022-02-17 19:37:40 +01:00
Mark Baker 03993bce05
The last big block of Engineering functions; those involving complex numbers (#2597) 2022-02-17 15:17:33 +01:00
Mark Baker ef839f56be
Get started with array-enabling the Engineering functions - Erf, Bessel, bitwise, comparisons Unit of Measure and Number base conversions first (#2594) 2022-02-16 18:32:07 +01:00
Mark Baker cdbe5c7c9b
Converting Statistical functions to be array-enabled (phase #2) (#2593) 2022-02-15 20:34:39 +01:00
Mark Baker f1cb75eaec
Start work on Array-enabling the Statistical functions (#2588) 2022-02-15 14:41:17 +01:00
Mark Baker e3b7cb5f9d
I'm ignoring SUMIF() and SUMIFS() for the moment; so this should complete all the applicable Math/Trig functions;so the subset SERIESSUM() function and RANDBETWEEN() should complete Math/Trig (#2586) 2022-02-13 12:50:05 +01:00
Mark Baker 8f3c52a3cf
Enable array-readiness for more Math/Trig functions (#2584)
* Enable array-readiness for more Math/Trig functions; CEILING() FLOOR() (and variants), TRUNC(), BASE() and the various Logarithms
* Minor refactoring
2022-02-12 20:47:47 +01:00
Mark Baker 5d88c6b534
Merge branch 'master' into Issue-2551_Enable-Array-Readiness-for-Functions-Maths 2022-02-12 17:11:45 +01:00
MarkBaker 75213f5ee1 Enable array-readiness for more Math/Trig functions 2022-02-12 16:56:06 +01:00
Orkhan Ahmadov 0eeba6dc0c
`ReferenceHelper@insertNewBefore` checks for missing coordinates before replacing values (#2541)
* ReferenceHelper@insertNewBefore now changes for missing columns before replacing and deleting columns

* Changelog updated

* Fixed code style

* Added assertion for all cells. Change bugfix implementation to use `createNewCell` on Worksheet

* Additional assertions
2022-02-12 07:08:11 -08:00