Commit Graph

2656 Commits

Author SHA1 Message Date
xandros15 815dabae89 #984 add support notContainsText for conditional styles in xlsx 2021-04-30 15:22:07 +02:00
oleibman cc5c0205d5
Fix for Issue 2029 (Invalid Cell Coordinate A-1) (#2032)
* Fix for Issue 2029 (Invalid Cell Coordinate A-1)

Fix for #2021. When Html Reader encounters an embedded table, it tries to shift it up a row. It obviously should not attempt to shift it above row 1. @danmodini reported the problem, and suggests the correct solution. This PR implements that and adds a test case.

Performing some additional testing, I found that Html Reader cannot handle inline column width or row height set in points rather than pixels (and HTML writer with useInlineCss generates these values in points). It also doesn't handle border style when the border width (which it ignores) is omitted. Fixed and added tests.
2021-04-29 22:59:01 +02:00
Mark Baker e4973fa041
Start work on refactoring the last of the Excel Statistical functions (#2033)
* Refactoring the last of the Excel Statistical functions
2021-04-29 14:34:50 +02:00
Mark Baker 160ae59751
Resolve problem where underscore placeholder in a number format masks (#2038)
* Resolve problem where underscore placeholder in a number format mask was being replaced, but leaving the sizing character as part of the mask
2021-04-29 14:15:45 +02:00
Mark Baker 475874bed3
Initial implementation of the URLENCODE() web function (#2031)
* Initial implementation of the URLENCODE() web function
2021-04-28 17:10:36 +02:00
MarkBaker 451cb44613 Merge remote-tracking branch 'origin/master' 2021-04-28 14:20:53 +02:00
MarkBaker 44ebae9438 Fix a couple of now invalid callable references in the Calculation Engine lookup table 2021-04-28 14:20:32 +02:00
Mark Baker d118a7070b
Completion of refactoring for Excel Lookup and Reference functions (#2030)
* Completion of refactoring for Excel Lookup and Reference functions
* Fix LookupRef tests checking for cell existence
* Fix a couple of now invalid callable references in the Calculation Engine lookup table
2021-04-28 14:08:20 +02:00
Mark Baker 8d7be25823
Improve Range handling in the Calculation Engine for Row and Column ranges (#2028)
* Improve Range handling in the Calculation Engine for Row and Column ranges
2021-04-27 19:10:37 +02:00
Mark Baker 27eac4d649
Some refactoring improvements to parsing Style information in the Xls Reader (#2025)
* Some refactoring improvements to parsing Style information in the Xls Reader
2021-04-25 13:48:42 +02:00
Adrien Crivelli 4e2259c135
BREAKING `Worksheet::getRowDimension()` and `Worksheet::getColumnDimension()` cannot return null anymore
Both methods used to optionally return null if passed a
second argument. This second argument was removed entirely and the
method always returns a RowDimension or ColumnDimension respectively
(possibly creating it if needed).

This make the API more predictable and easier to do static analysis
with tools such as PHPStan.

If you relied on that second parameter, you should instead use the
`Worksheet::getRowDimensions()` or `Worksheet::getColumnDimensions()` and
check for existence yourself before calling the getters.
2021-04-25 17:02:36 +09:00
Adrien Crivelli 2e39ece373
BREAKING `Worksheet::getCellByColumnAndRow()` cannot return null anymore
`Worksheet::getCellByColumnAndRow()` used to optionnaly return null if passed a
second argument. This second argument was removed entirely and the
method always returns a Cell (possibly creating it if needed).

This make the API more predictable and easier to do static analysis
with tools such as PHPStan.

If you relied on that second parameter, you should instead use the
`Worksheet::cellExistsByColumnAndRow()` before calling `getCellByColumnAndRow()`.
2021-04-25 15:50:20 +09:00
oleibman 1e8ff9f852
DateTimeExcel - Change Names of funcWhatever to evaluate (#2015)
* DateTimeExcel - Change Names of funcWhatever to evaluate

Per discussions while MathTrig was being broken up, this would help standardize the code. This PR applies that standardization to the DateTimeExcel family of functions.

The deprecation messages in DateTime.php are changed to match the style used in PR #2005.

All Phpstan grandfathered errors (about 25) in DateTimeExcel are fixed and removed from baseline. A small number (about 5) of phpstan annotations in the source members in that directory are also fixed and eliminated.
2021-04-24 18:56:58 +02:00
oleibman a01a401228
MathTrig - Fix Phpstan Accomodations (#2020)
* MathTrig - Fix Phpstan Accomodations

This should be the last of my mass changes to MathTrig. All he Phpstan violations found in baseline which  are part of MathTrig are now fixed and removed from baseline. There were about 20 of these.
2021-04-24 18:12:17 +02:00
Mark Baker 557601f584
Xls writer improve styles (#2014)
* Extract 3 separate (duplicated) switch statements for mapping colours in conditional formatting rules into a single class
* Replace switch statement with an array map for colour lookup
* Eliminate duplicate colour map entries
* Apply some stricter type checking
* Extract Cell Data Validations
* Extract Error Code mappings
2021-04-24 17:10:09 +02:00
Mark Baker 3b8ef420ac
Issue 1967 conditional formatting data bar problems (#2012)
* Only store additional formatting objects for DataBars
* - Ensure that Xlsx Reader/Writer can still read DataBar Conditional Formatting, while ignoring IconTypes that are triggering errors
- Ensure that Xls Writer only writes CF Headers if there are non-DataBar CF Records that it needs to write
- Ensure that Xlsx Reader only reads SheetView data to retrieve currently selected cells after it has read CF Records that can otherwise change the currently selected cell
* Try to apply proper support for cell ranges in conditional formatting
2021-04-24 16:49:06 +02:00
Mark Baker 55a41e8cae
Eliminate a big chunck of duplicated code for reading styles (#2021)
* Eliminate a big chunk of duplicated code for reading styles
2021-04-24 16:20:27 +02:00
oleibman b05dc31850
MathTrig - Change Names of funcWhatever to evaluate (#2008)
* MathTrig - Change Names of funcWhatever to evaluate

Per discussions while MathTrig was being broken up, this would help standardize the code. That idea was adopted partway through the breakup. This PR applies that standardization to the earlier efforts. A similar effort is required for DateTime; that will come later. This PR replaces #2006.

The only 2 remaining funcWhatevers in MathTrig are both in SUM, which required two different methods depending on whether or not string parameters were to be ignored. It seems appropriate to leave those method names non-standardized in order to require a decision about which is to be used if they are invoked internally.

3 Phpstan grandfathered errors were eliminated as part of this change, and its baseline has changed accordingly.

Co-authored-by: Mark Baker <mark@lange.demon.co.uk>
2021-04-20 22:43:29 +02:00
oleibman c79a9a8e21
Improved Support for INDIRECT, ROW, and COLUMN Functions (#2004)
* Improved Support for INDIRECT, ROW, and COLUMN Functions

This should address issues #1913 and #1993. INDIRECT had heretofore not supported an optional parameter intended to support addresses in R1C1 format which was introduced with Excel 2010. It also had not supported the use of defined names as an argument. This PR is a replacement for #1995, which is currently in draft status and which I will close in a day or two.

The ROW and COLUMN functions also should support defined names. I have added that, and test cases, with the latest push. ROWS and COLUMNS already supported it correctly, but there had been no test cases. Because ROW and COLUMN can return arrays, and PhpSpreadsheet does not support dynamic arrays, I left the existing direct-call tests unchanged to demonstrate those capabilities.

The unit tests for INDIRECT had used mocking, and were sorely lacking (tested only error conditions). They have been replaced with normal, and hopefully adequate, tests. This includes testing globally defined names, as well as locally defined names, both in and out of scope.

The test case in 1913 was too complicated for me to add as a unit test. The main impediments to it are now removed, and its complex situation will, I hope, be corrected with this fix.

INDIRECT can also support a reference of the form Sheetname!localName when localName on its own would be out of scope. That functionality is added. It is also added, in theory, for ROW and COLUMN, however such a construction is rejected by the Calculation engine before passing control to ROW or COLUMN. It might be possible to change the engine to allow this, and I may want to look into that later, but it seems much too risky, and not nearly useful enough, to attempt to address that as part of this change.

Several unusual test cases (leading equals sign, not-quite-as-expected name definition in file, complex indirection involving concatenation and a dropdown list) were suggested by @MarkBaker and are included in this request.
2021-04-20 22:16:21 +02:00
oleibman aeccdb35e2
XLSX Reader and Empty Fill Tag (#2011)
Openpyxl can generate the xml tag `<patternFill/>`, possibly even as a default style. Excel has no problem with this, treating it as "fill none", but PhpSpreadsheet has a glitch because it treats it as "fill solid white". So, when PhpSpreadsheet loads and saves such a file, the result at first appears as if gridlines are disabled; in fact, the gridlines are merely invisible behind the cells with their solid white fill. This PR makes PhpSpreadsheet behave the same as Excel in this circumstance.

Co-authored-by: Mark Baker <mark@lange.demon.co.uk>
2021-04-20 17:20:59 +02:00
Mark Baker 6282035c96
Extract Property and Style readers from the XML Reader into separate classes (#2009)
* Extract Property and Style readers from the XML Reader into separate classes
2021-04-20 15:27:44 +02:00
oleibman 62f5135dc4
Merge pull request #1769 from tiagof/issue-907-absolute-path-in-Target
Handle absolute path in worksheets Target
2021-04-19 07:32:15 -07:00
Tiago Fernandes 107f707df6 Merge branch 'issue-907-absolute-path-in-Target' of https://github.com/tiagof/PhpSpreadsheet into issue-907-absolute-path-in-Target 2021-04-19 14:40:33 +01:00
Tiago Fernandes 142e7eea7a Fix style 2021-04-19 14:40:25 +01:00
Tiago Fernandes 11f8a02194
Merge branch 'master' into issue-907-absolute-path-in-Target 2021-04-19 14:32:20 +01:00
Tiago Fernandes ee4f10e85c Updated Changelog 2021-04-19 14:31:10 +01:00
Tiago Fernandes 559c0761df Remove unnecessary changes. Added test 2021-04-19 11:25:48 +01:00
Mark Baker caf11fe808
Refactoring to extract DocProperties Reader from Gnumeric Reader (#2007)
* Refactoring to extract DocProperties Reader from Gnumeric Reader
2021-04-18 20:09:04 +02:00
Mark Baker f49a951bea
Tag deprecations for MathTrig, and eliminate calls to the deprecated methods (#2005)
* Tag deprecations for MathTrig, and eliminate calls to the deprecated methods
2021-04-18 12:19:53 +02:00
jarrett jordaan 818b993f2e
Check array key exists before access in Xlsx.php (#1970)
When loading an xlsx file which has images that use a URL, there's a PHP Notice that is shown. 

Added a check for the existence of the array key for accessing.
2021-04-18 19:14:01 +09:00
Mark Baker edca1f573d
Use validation classes rather than traits for Engineering functions (#2001)
* Use validation classes rather than traits for Engineering functions

* Re-baseline phpstan
2021-04-13 17:24:45 +02:00
Mark Baker ddd07ee504
Use validation classes rather than traits for Statistical functions, … (#1999)
* Use validation classes rather than traits for Statistical functions, and some verification of nullable arguments
* Eliminate more of the issues resolved in phpstan baseline
2021-04-13 16:56:21 +02:00
Adrien Crivelli 33ec70668b
Shortcut for increased performance for the vast majority of simple cases 2021-04-13 11:33:37 +09:00
Adrien Crivelli d85eaacfa3
BREAKING `Worksheet::getCell()` cannot return null anymore
`Worksheet::getCell()` used to optionnaly return null if passed a
second argument. This second argument was removed entirely and the
method always returns a Cell (possibly creating it if needed).

This make the API more predictable and easier to do static analysis
with tools such as PHPStan.

If you relied on that second parameter, you should instead use the
`Worksheet::cellExists()` before calling `getCell()`.
2021-04-13 11:09:29 +09:00
Mark Baker a34695e0f9
Financial functions more rationalization (#1990)
* Additional unit tests and rationalisation for Financial Functions
* Providing a series of sample files for Financial functions
* Refactor the last of the existing Financial functions
* Some more unit tests with default assignments from null arguments

Co-authored-by: Adrien Crivelli <adrien.crivelli@gmail.com>
2021-04-12 22:08:58 +02:00
Adrien Crivelli 49f87de165
Reduce PHPStan error in tests 2021-04-12 11:10:23 +09:00
Adrien Crivelli 89aa7e6fcd
Introduce PHPstan baseline 2021-04-11 16:56:36 +09:00
Adrien Crivelli f9532231d2
PHPStan Level 3 2021-04-11 16:33:53 +09:00
MarkBaker 02f37d4f7e Consolidate use of constants
Remove link to deprecated method in favour of new method
2021-04-06 22:57:35 +02:00
oleibman 37ebc99a5a
Merge pull request #1869 from AkiraPenguin/master
Add "outputEncoding" property to Writer/Csv.php
2021-04-06 09:01:52 -07:00
Akira Taniguchi da28089c3c
Merge branch 'master' into master 2021-04-06 23:56:37 +09:00
Mark Baker bc18fb7e77
more extraction of Excel Financial functions (#1989)
* More Financial function extracts, this time looking at the Periodic Cashflow functions
* Initial extract of Constant Periodic Interest and Payment functions
2021-04-06 12:45:37 +02:00
Akira Taniguchi 551bbdf30f
Update CsvOutputEncodingTest.php 2021-04-06 18:53:21 +09:00
oleibman 063496dbe0
Merge pull request #1922 from ccrims0n/fix_excel_overwrite
Refactor xlsx writer
2021-04-05 22:43:29 -07:00
Vivek 93d858a064
Merge branch 'master' into fix_excel_overwrite 2021-04-06 08:19:44 +05:30
Akira Taniguchi e48ffdbe77
Update CsvOutputEncodingTest.php 2021-04-06 04:44:24 +09:00
Akira Taniguchi 991616d1d9
Update CsvOutputEncodingTest.php 2021-04-06 04:39:26 +09:00
Akira Taniguchi eac9dd3168
Update Csv.php 2021-04-06 04:34:36 +09:00
Akira Taniguchi 86f3bdd598
Update CsvOutputEncodingTest.php 2021-04-06 04:27:14 +09:00
Akira Taniguchi bfd4a659a4
Update CsvOutputEncodingTest.php 2021-04-06 04:11:46 +09:00