Commit Graph

3211 Commits

Author SHA1 Message Date
MarkBaker 3ae5a3fae3 Additional unit tests for BColumnAndRow methods, to verify that they still work as expected 2022-04-02 21:37:05 +02:00
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
Mark Baker 8885c4eeef
Merge pull request #2713 from PHPOffice/Filter-return-result-array-indexes
Bugfix to returned column indexes for FILTER() by row
2022-03-24 22:24:39 +01:00
MarkBaker 2ab582a707 Bugfix to returned column indexes for FILTER() by row 2022-03-24 22:12:08 +01:00
Mark Baker 11edcc9f96
Merge pull request #2711 from PHPOffice/LookupRef-Sort-Functions
Implementation of the SORT() and SORTBY() Lookup/Reference functions
2022-03-24 18:30:41 +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 6a349ccf5a
Scrutinizer Faulty Analysis (#2704)
Despite typehint, Scrutinizer assigns union type to a variable, resulting in subsequent faulty analysis of a method call invoked on that variable. Adding a bogus routine that will never actually be called to one module eliminates 8 Scrutinizer errors.
2022-03-21 14:29:57 -07: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
oleibman 2482203c3e
Resolve Scrutinizer Reports for Samples (#2691)
These are handled about 50-50 between code changes when reasonable, and annotations when not. No source code is changed.
2022-03-21 13:17:25 -07:00
Mark Baker 0ce56b1655
Merge pull request #2707 from PHPOffice/LookupRef-Filter-Function
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:18:15 +01: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 1642ee4eb1
Merge pull request #2702 from PHPOffice/Xls-Reader-CF-Styling
Support fill style and color for reading CF Formats
2022-03-19 19:57:52 +01:00
MarkBaker 0a9d15407f Suport fill style and color for reading CF Formats 2022-03-19 19:47:14 +01:00
Mark Baker be734cf922
Merge pull request #2696 from PHPOffice/Xls-Reader-Conditional-Formatting
Xls Reader: initial work on reading conditional formatting
Currently the ranges and CF Rules are read, but only the most basic style information for the font (size, weight and colour)

This will be expanded with future PRs
2022-03-19 16:37:42 +01:00
Mark Baker 23e2d702ff
Merge branch 'master' into Xls-Reader-Conditional-Formatting 2022-03-19 16:21:14 +01:00
MarkBaker be8c444951 More minor tweaks 2022-03-19 16:15:48 +01:00
MarkBaker aea156ff76 Minor tweaks 2022-03-19 16:03:17 +01:00
MarkBaker 3803658897 Some basic reading of font style information for CF Styles 2022-03-19 15:43:07 +01:00
MarkBaker 3767917ee5 Stubs for reading style information for Conditional Formatting 2022-03-19 14:48:50 +01:00
Mark Baker 1bd5369295
Merge pull request #2667 from kbond/simple-cache-2
Allow `psr/simple-cache` 2.x
2022-03-19 12:43:42 +01:00
Mark Baker 0e8c470ca6
Merge branch 'master' into simple-cache-2 2022-03-19 12:27:52 +01:00
Mark Baker 7e9edf5907
Merge pull request #2698 from PHPOffice/Xls-Reader-DataValidations-Refactoring
Move DataValidation switch statements into a dedicated helper class
2022-03-19 12:18:34 +01:00
MarkBaker c73bb612e0 Unit tests for Xls Reader DataValidation 2022-03-19 12:04:14 +01:00
Mark Baker d93f1b2800
Merge branch 'master' into simple-cache-2 2022-03-18 23:05:33 +01:00
MarkBaker 2dc9fc6bb7 Move DataValidation switch statements into a dedicated helper class 2022-03-18 22:38:24 +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
Mark Baker 0e7ee37ea6
Merge pull request #2695 from PHPOffice/Error-Handling-Spill-Calc
Add basic support for Error functions when the error is #SPILL! or #CALC!
2022-03-18 17:59:58 +01:00
MarkBaker 21b784f200 Add basic support for Error functions when the error is #SPILL! or #CALC! 2022-03-18 17:44:26 +01:00
Mark Baker dae5dfd6b6
Merge pull request #2694 from PHPOffice/Implementation-of-UNIQUE()-Function
Fix scrutinizer issue complaint
2022-03-18 15:20:08 +01:00
MarkBaker 75e45057f3 Fix scrutinizer issue complaint 2022-03-18 15:07:13 +01:00
Mark Baker 4847e05212
Merge pull request #2692 from PHPOffice/Implementation-of-UNIQUE()-Function
Initial work implementing the new UNIQUE() Lookup/Reference array function
2022-03-18 14:40:52 +01:00
MarkBaker c8cf193301 Initial work implementing the new UNIQUE() Lookup/Reference array function 2022-03-18 14:18:37 +01:00
Mark Baker 576fbc43c9
Merge pull request #2690 from PHPOffice/UnitTests_ReferenceHelper-DataValidation
More unit testing for inserting/deleting rows/columns with DataValida…
2022-03-17 16:05:45 +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 178f748bc2
Merge pull request #2689 from PHPOffice/Issue-2678_Update-CF-Ranges-and-Conditions-on-Insert/Delete
Fix issues with updating Conditional Formatting when inserting/deleting rows/columns
2022-03-17 12:05:18 +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
oleibman a8e179d5d9
Scrutinizer Complains Some Samples Class Name Conflict with Jpgraph (#2684)
Jpgraph does not use namespaces. Neither do the Samples members of this project. As a result, Scrutinizer complains about 13 cases of `use PhpOffice\PhpSpreadsheet\Chart\Legend;`, since this theoretically could cause the use of two different Legend classes in the empty namespace. It suggests using a class alias for Legend, which this PR does in every applicable case. It is a regrettable problem, but it is easy to fix.
2022-03-16 15:59:53 -07:00
oleibman f2f626e02c
Tweak to php-cs-fixer Parameters (#2683)
For a recent change, I removed some errors from Phpstan baseline and instead added annotations in the source members. I did this work incrementally, and was surprised when php-cs-fixer required a change from `// @phpstan-ignore-next-line` to `/** @phpstan-ignore-next-line */`. No problem thinks I, and continue to modify several members using the new convention until php-cs-fixer required a change from `/** @phpstan-ignore-next-line */` to `// @phpstan-ignore-next-line`??? I did as directed, and continued to be surprised for the rest of that ticket.

Having had time to research, the problem is due to two options in the php-cs-fixer config file `'comment_to_phpdoc' => true` and `'phpdoc_to_comment' => true`. It seems that php-cs-fixer is treating these annotations the same as doc-blocks, expecting `/**` before a `structural element`, and `//` otherwise. For the statements where I had questions, it expects `/**` before a statement which you might be able to precede with `/** @var`, and `//` where you would not be able to precede it with `/** @var`. However, in this case, what it is doing is forcing what appear to be inconsistencies between otherwise identical statements, whereas php-cs-fixer is supposed to be supporting consistent syntax throughout the project. This PR changes both options to false, allowing (but not requiring) a consistent syntax for these examples. It contains an example of a change from each format to the other, changes which php-cs-fixer would previously have flagged.

An added bonus for this change is that Scrutinizer annotations can now be added to the code; these were often rejected by php-cs-fixer. These should, of course, be used very conservatively, but there are cases where Scrutinizer's analysis is either faulty or not helpful. This PR takes advantage of the change by adding annotations to eliminate the two existing problems which Scrutinizer classifies as 'Security', problems for which there is no sensible way to satisfy Scrutinizer's complaint.

No executable code is changed by this PR.
2022-03-16 15:34:40 -07:00
Mark Baker 78c27c03ca
Merge pull request #2687 from PHPOffice/Bugfix_Support-Row/Column-Ranges-in-INDIRECT()-Function
Allow `INDIRECT()` to accept row/column ranges as well as cell ranges
2022-03-16 23:16:50 +01:00
MarkBaker ec15c7a6de more minor tweaks 2022-03-16 23:03:19 +01:00
Mark Baker 0b9207a522
Merge pull request #2686 from PHPOffice/Additional-Validations-for-Lookup-Arrays
Validate that lookup arrays are actually arrays
2022-03-16 21:44:24 +01:00
MarkBaker 4881e2ae9e Validte that lookup arrays are actually arrays 2022-03-16 21:30:19 +01:00
Mark Baker 4c1d953897
Merge pull request #2685 from PHPOffice/Refactoring-ReferenceHelper-allow-absolute-cellreference-updates
Provide $includeAbsoluteReferences option for the CellReferenceHelper when updating cell addresses
2022-03-16 19:25:43 +01:00
MarkBaker 4bc3ed9cc1 Provide $includeAbsoluteReferences option for the CellReferenceHelper when updating cell addresses 2022-03-16 19:14:50 +01:00