Commit Graph

692 Commits

Author SHA1 Message Date
MarkBaker 6b4ffda5ae Add functionality to adjust CellRange by "modifying" the from/to CellAddress Value objects 2022-04-01 15:41:55 +02:00
MarkBaker 1849737abc Add functionality to shift RowRange and ColumnRange 2022-04-01 11:26:47 +02:00
MarkBaker 62238bc011 Initial work on deprecating `ByColumnAndRow` methods; and providing functionality to use the basic cellAddress methods to be used with a string cell address (e.g. `C5`); an array of columnId and rowId (e.g. `[3, 5]`) or a new CellAddress object.
Current implementation for all methods that take a single cell reference argument:
 - `setCellValue()`
 - `setCellValueExplicit()`
 - `getCell()`
 - `cellExists()`
 - `setBreak()`
 - `freezePane()`
 - `getComment()`

Also introducing a CellRange object to work with similar cases for methods that accept a cell range rather than simply a cell address; and RowRange/ColumnRange objects for those cases.

Still need to apply to methods that accept a cell range or single cell:
 - `mergeCells()`
 - `unmergeCells()`
 - `protectCells()`
 - `unprotectCells()`
 - `setAutoFilter()`

Then there's a few special cases that accept row and column ranges, not simply cell ranges; or a series of cell ranges.
2022-03-31 23:22:48 +02:00
MarkBaker 2ab582a707 Bugfix to returned column indexes for FILTER() by row 2022-03-24 22:12:08 +01:00
MarkBaker 9019523efc Additional unit testing
And a quick bugfix for cell ranges applied to both sort functions and to FILTER()
2022-03-24 17:51:06 +01:00
MarkBaker 7f00049fe8 Initial work on the SORT() and SORTBY() Lookup/Reference functions
The code could stil do with some cleaning up, and better optimisation for memory usage; but all tests are passing... that's for full multi-level sorting (including direction), and allowing for correct sorting of sting/numeric datatypes.
2022-03-24 12:21:27 +01:00
oleibman c112802023
Eliminate Most Scrutinizer Problems in Test Suite (#2699)
* Eliminate Most Scrutinizer Problems in Test Suite

Mostly minor code changes, with some annotations.

* Missed 2 php-cs-fixer Problems

They should be fixed now.
2022-03-21 13:58:42 -07:00
MarkBaker f3bb61f3e4 Initial work implementing the FILTER() Lookup/Reference function
Tighten up on vector formats; and provide a couple of helper methods for testing row/column vectors
2022-03-20 18:01:30 +01:00
Mark Baker 23e2d702ff
Merge branch 'master' into Xls-Reader-Conditional-Formatting 2022-03-19 16:21:14 +01:00
MarkBaker c73bb612e0 Unit tests for Xls Reader DataValidation 2022-03-19 12:04:14 +01:00
MarkBaker 45c08d6cd4 Initial work on reading conditional styles for the Xls Reader
Successfully reading the CF ranges and CF rules; not yet reading the styles
2022-03-18 21:09:32 +01:00
MarkBaker 75e45057f3 Fix scrutinizer issue complaint 2022-03-18 15:07:13 +01:00
MarkBaker c8cf193301 Initial work implementing the new UNIQUE() Lookup/Reference array function 2022-03-18 14:18:37 +01:00
MarkBaker f6fcc4de87 More unit testing for inserting/deleting rows/columns with DataValidation, ConditionalFormatting and PrintArea 2022-03-17 15:48:30 +01:00
MarkBaker 9b3c3f4adf Merge branch 'master' into Xls-Reader-Conditional-Formatting 2022-03-17 12:11:19 +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 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 cb5a451aaf Initial work on Reading Conditional Formatting from Xls files 2022-03-15 13:25:23 +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
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 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