Commit Graph

3647 Commits

Author SHA1 Message Date
MarkBaker 269e9ba14d Bugfix for Issue #3013, Named ranges not usable as anchors in OFFSET function 2022-08-19 11:28:51 +02:00
MarkBaker d7da206103 Remove file accidentally committed 2022-08-15 07:47:27 +02:00
Mark Baker 4f714cd2a3
Merge pull request #3007 from PHPOffice/Issue-3005_Extract-CellReferences-in-Range-with-Worksheet-Reference
Adjust `extractAllCellReferencesInRange()` method to allow a worksheet in the reference
2022-08-15 06:40:50 +02:00
MarkBaker b0f7e83dc2 Fix phpstan baseline 2022-08-15 06:33:31 +02:00
Mark Baker 44ab25d4f2
Merge branch 'master' into Issue-3005_Extract-CellReferences-in-Range-with-Worksheet-Reference 2022-08-15 06:21:06 +02:00
Mark Baker 069efdb729
Merge pull request #3008 from PHPOffice/Expand-Return-Datatypes
More return type declarations, and some additional argument typehinting
2022-08-15 06:20:51 +02:00
Mark Baker dfa6f803fd
Merge branch 'master' into Issue-3005_Extract-CellReferences-in-Range-with-Worksheet-Reference 2022-08-15 00:25:03 +02:00
Mark Baker febd8d8991
Merge branch 'master' into Expand-Return-Datatypes 2022-08-15 00:24:49 +02:00
MarkBaker cd66298901 Adjust `extractAllCellReferencesInRange()` method to allow a worksheet in the reference 2022-08-14 23:43:52 +02:00
oleibman bb072d1ca7
Upgrade Dev TCPDF to 6.5 (#3006)
* Upgrade Dev TCPDF to 6.5

Implementation of https://github.com/tecnickcom/TCPDF/pull/467, which is available in just-released Tcpdf 6.5, will improve look of Tcpdf rendering for PhpSpreadsheet. Fix #1164.

One test had been suppressed for Tcpdf, ostensibly because it was not compatible with Php8. As it turns out, the PhpSpreadsheet code which invokes Tcpdf was (harmlessly) incorrect, so the Php8 issue was actually with PhpSpreadsheet, not Tcpdf. That code is corrected, and the test is no longer suppressed.

* Update Change Log

Pick up some earlier changes as well as this one, and deprecations which had been omitted from the 1.24 change log.
2022-08-14 10:57:34 -07:00
oleibman fadfb727bf
Minor Changes for Mpdf, Dompdf (#3002)
See discussion in #2999. Mpdf is not acknowledging the styling that we're using to hide table rows. I have opened an issue with them, but enclosing the cells in the hidden row inside a div with appropriate css does seem to be a workaround, and that can be incorporated into PhpSpreadsheet. It's kludgey, and it isn't even valid HTML, but ...

Mpdf also doesn't like the addition of the ```file:///``` prefix when using local images from Windows (sample 21). Results are better when that prefix is not added.

Dompdf seemed to have problems with sample 21 images on both Windows and Unix, with or without the file prefix. It does, however, support data urls for both, so is changed to embed images. It's still not perfect - the image seems truncated to the row height - but the results are better. I will continue to research, but may proceed as-is if I don't find anything better to do.

Html Writer was producing a file with mixed line endings on Windows. This didn't cause any harm, but it seems a bit sloppy. It is changed to always use PHP_EOL as a line ending.
2022-08-13 18:28:22 -07:00
oleibman 5c13b179a1
Replace Dev jpgraph/jpgraph with mitoteam/jpgraph (#2997)
* Replace Dev jpgraph/jpgraph with mitoteam/jpgraph

PR #2979 added support for mitoteam/jpgraph as an alternative to jpgraph/jpgraph. The package jpgraph/jpgraph is abandoned in composer, and the version loaded with composer has been unusable for some time. This PR removes the dev requirement for jpgraph/jpgraph, and adds a dev requirement for mitoteam/jpgraph in its place.

With a usable graph library, a number of tests and samples that had been disabled are now re-enabled. A lot of new functionality has been added to Charts recently. Some of that new code has exposed bugs in JpgraphRendererBase. I have fixed those where I could. A handful of exceptions remain; I will investigate, and hopefully fix, those over time, but I don't feel it is necessary to fix them all before installing this PR - we are already way ahead of the game with the graphs that are working.

Three members had been ignoring code coverage in whole or in part because of the unavailability of a usable graph libray. Code coverage is restored in them. I am relieved to report that, although they aren't completely covered, adding them did not reduce code coverage by much - it is still over 90.4%.

I took a look at JpgraphRendererBase and Phpstan. Phpstan reports 128 problems. When I added some docblocks to correct some of those, the number increased to 284. Sigh. I will investigate over time, but, for now, we will still suppress Phpstan for JpgraphRendererBase.

I do not find a License file for mitoteam. However, there also wasn't one for jpgraph in the first place. Based on that and the discussion in #2996 (mitoteam will be used in exactly the same manner as mpdf), I don't think this is a problem. IANAL.

* PHP 8.2 Problems

Tons of "cannot create dynamic property" deprecations in jpgraph. Disable the test with most of those for now; leave the two with only a handful of messages enabled.

* Correct Failures in 2 Stock Charts

Down to 6 templates on which Render fails.
2022-08-13 18:14:25 -07:00
oleibman f34e0ead29
Add setName Method for Chart (#3001)
Addresses a problem identified in issue #2991. Chart name is set in constructor, but there is no method to subsequently change it. This PR adds a method to do so.
2022-08-12 20:10:45 -07:00
oleibman 0492ea6d8a
Use Only mb_convert_encoding in StringHelper sanitizeUTF8 (#2994)
* Test if UConverter Exists Without Autoload

Fix #2982. That issue is actually closed, but it did expose a problem. Our test environments all enable php-intl, but that extension isn't a formal requirement for PhpSpreadsheet. Perhaps it ought to be. Nevertheless ...

Using UConverter for string translation solved some problems for us. However, it is only available when php-intl is enabled. The code tests if it exists before using it, so no big deal ... except it seems likely that the people reporting the issue not only did not have php-intl, but they do have their own autoloader which issues an exception when the class isn't found. The test for existence of UConverter defaulted to attempting to autoload it if not found. So, on a system without php-intl but with a custom autoloader, there is a problem. Code is changed to suppress autoload when testing UConverter existence.

Pending this fix, the workaround for this issue is to enable php-intl.

* Minor Improvement

Make mb_convert_encoding use same substitution character as UConverter, ensuring consistent results whatever the user's environment.

* And Now That I Figured That Out

Since mb_convert_encoding can now return the same output as UConverter, we don't need UConverter (or iconv) after all in sanitizeUTF8.
2022-08-12 18:59:28 -07:00
MarkBaker b783fecb7f More return type declarations, and some additional argument typehinting 2022-08-12 14:03:13 +02:00
Mark Baker d13b07ba6e
Merge pull request #2995 from PHPOffice/Matrix-Operations-Additional
Additional for PR #2964; validate value after extracting from flattened array
2022-08-07 19:15:57 +02:00
MarkBaker ca1650df9e Additional for [PR #2964](https://github.com/PHPOffice/PhpSpreadsheet/pull/2964); validate value after extracting from flattened array 2022-08-07 18:45:36 +02:00
Mark Baker c34662b8b2
Merge pull request #2993 from PHPOffice/Matrix-Arithmetic-Value-Testing
Expand PR #2964 to cover all arithmetic operators, and both left and right side values
2022-08-07 14:18:58 +02:00
Mark Baker b627770ece
Merge branch 'master' into Matrix-Arithmetic-Value-Testing 2022-08-07 14:07:31 +02:00
MarkBaker 71b2c5ae89 Expand [PR #2964](https://github.com/PHPOffice/PhpSpreadsheet/pull/2964) to cover all arithmetic operators, not just multiplication, and both left and right side values 2022-08-07 13:59:26 +02:00
Mikhail Oleynik b65ff9f20d
MtJpGraph support added (#2979)
https://github.com/PHPOffice/PhpSpreadsheet/pull/2979

Co-authored-by: Mikhail Oleynik <mishutka@mito-team.com>
2022-08-07 04:50:38 -07:00
oleibman 8bde1ace44
Charts Support for Rounded Corners and Trendlines (#2976)
Fix #2968. Fix #2815. Solution largely based on suggestions by @bridgeplayr.
2022-08-06 18:06:36 -07:00
oleibman eb76c3c0ff
Code Coverage >90% (#2973)
No source code changes, just additional tests. FormulaParser appears unused, replaced by newer code in Calculation. However, it's a public interface, so probably shouldn't be deleted without first deprecating it. I have no strong feelings about whether that should happen. However, as long as it's part of the package, we may as well have some formal unit tests for it.
2022-08-06 17:56:30 -07:00
oleibman b661d31887
Limited Support for Chart Titles as Formulas (#2971)
This is a start in addressing issue #2965 (and earlier issue #749). Chart Titles are usually entered as strings or Rich Text strings, and PhpSpreadsheet supports that. They can also be entered as formulas (typically a pointer to a cell with the title text), and, not only did PhpSpreadsheet not support that, it threw an exception when reading a spreadsheet that did so.

This change does:
- eliminate the exception
- set a static chart title when it can determine it from the Xml

This change does not:
- fully support dynamic titles (e.g. if you change the contents of the source cell, or delete or insert cells or rows or columns)
- permit the user to set the title to a formula
- allow the use of formulas when writing a chart title to a spreadsheet
- provide styling for titles when it has read them as a formula
2022-08-06 17:39:18 -07:00
Jonathan Goode 7f0ca404fc
Ensure multiplication is performed on a non-array value (#2964)
* Ensure multiplication is performed on a non-array value

* Simplify formula
Numbers should be numbers

* Provide test coverage for SUM combined with INDEX/MATCH

* PHPStan
2022-08-06 17:28:26 -07:00
Mark Baker ada583f3cf
Merge pull request #2990 from PHPOffice/TextFunctions-ArrayToText
Initial work on the ARRAYTOTEXT() Excel Function
2022-08-05 01:17:07 +02:00
Mark Baker a8b6214574
Merge branch 'master' into TextFunctions-ArrayToText 2022-08-04 23:02:20 +02:00
MarkBaker 4724c8f7e9 Initial work on the ARRAYTOTEXT() Excel Function 2022-08-04 22:43:36 +02:00
Mark Baker 630d92f0f4
Merge pull request #2988 from PHPOffice/Issue-2987_NamedCell-UTF8-Worksheet-getCell
cellExists() and getCell() methods should support UTF-8 named cells
2022-08-04 15:00:40 +02:00
MarkBaker f331bca470 cellExists() and getCell() methods should support UTF-8 named cells 2022-08-04 14:38:35 +02:00
MarkBaker 06d2682c5b Documentation markdown fix 2022-08-03 12:43:38 +02:00
Mark Baker a7df02fd55
Merge pull request #2975 from PHPOffice/TextFunctions-New-TextSplit
Initial implementation of the `TEXTSPLIT()` Excel Function
2022-08-03 12:38:16 +02:00
Mark Baker fe3ec55341
Merge branch 'master' into TextFunctions-New-TextSplit 2022-08-02 19:36:47 +02:00
MarkBaker 07f4fbe396 Initial implementation of the `TEXTSPLIT()` Excel Function 2022-08-02 19:05:43 +02:00
dependabot[bot] db2bc3b289
Bump phpstan/phpstan from 1.8.0 to 1.8.2 (#2977)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.8.0 to 1.8.2.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.8.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.8.0...1.8.2)

---
updated-dependencies:
- dependency-name: phpstan/phpstan
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-08-01 06:03:17 -07:00
Mark Baker 1c587e90c6
Merge pull request #2972 from PHPOffice/TextFunctions-New
Allow multiple delimiters for `TEXTBEFORE()` and `TEXTAFTER()` functions
2022-07-30 10:57:52 +02:00
MarkBaker 290d0731fe Allow multiple delimiters for `TEXTBEFORE()` and `TEXTAFTER()` functions 2022-07-30 10:27:31 +02:00
oleibman 641b6d0ccb
Improve Coverage for Shared/Font (#2961)
Shared/Font is hardly covered in unit tests (as opposed to Style/Font which is completely covered). And it presented some good opportunities for code optimization. I wrote and tested the new unit tests first, then optimized the code and confirmed that everything still works.

There is still a bit of a gap with "exact" measurements. I had tests ready, but had to withdraw them when I discovered they weren't quite portable (see https://github.com/php/php-src/issues/9073).
2022-07-29 07:11:37 -07:00
oleibman 39df9c3bcc
Fix Some Pdf Problems (#2960)
* Fix Some Pdf Problems

Fix #1747. No support for text rotation in Pdf. That issue actually has a decent workaround, but PhpSpreadsheet should handle it on its own. Mpdf requires the proprietary text-rotate css attribute; Html and Dompdf will use the CSS3 attribute transform:rotate.

Fix #1713. Some paper-size values in PhpSpreadsheet are strings, some are 2-element float arrays. Dompdf accepts strings or 4-element float arrays, where the first 2 elements are always 0. Convert the PhpSpreadsheet array accordingly before passing it to Dompdf.

Some tests had been disabled when Dompdf and Tcpdf were slow to achieve PHP8 compliance. They achieved it some time ago. Re-enable the tests.

* Remove Tcpdf From One Test

No problem with the other tests I added it in for.
2022-07-29 06:14:28 -07:00
Mark Baker e748ac7c03
Merge pull request #2947 from PHPOffice/TextFunctions-New
Initial Implementation of the new Excel TEXTBEFORE() and TEXTAFTER() functions
2022-07-29 13:04:18 +02:00
Mark Baker 345c0ebdfc
Merge branch 'master' into TextFunctions-New 2022-07-28 19:14:06 +02:00
MarkBaker 88bfa98291 Initial Implementation of the new Excel TEXTBEFORE() and TEXTAFTER() functions 2022-07-28 16:05:18 +02:00
oleibman c0809b0c6c
Fix Spreadsheet Copy, Disable Clone, Improve Coverage (#2951)
* Fix Spreadsheet Copy, Disable Clone, Improve Coverage

This PR was supposed to be merely to increase coverage in Spreadsheet. However, in doing so, I discovered that neither clone nor copy worked correctly. Neither had been covered in the test suite. Copy not only did not work, it broke the source spreadsheet as well. I tried to debug and got nowhere; I even tried using myclabs/deep-copy which is already in use in the test suite, but it failed as well. However, write and reload ought to work just fine for copy. It can't be used for clone; however, since copy does what clone ought to do, there's no reason why clone needs to be used, so __clone is changed to throw an exception if attempted.

One other source change was needed, an obvious bug where an if condition uses 'or' when it should use 'and'. Also, one docblock declaration needed a change. Aside from that, the rest of this PR is test cases, and overall coverage passes 89% for the first time.

* Clone is Okay After All

But copy wasn't, changing it to just return clone. Perhaps save and reload will be needed instead at some point, but not yet.

* An Error I Cannot Reproduce

PHP8.1 unit test says error because GdImage can't be serialized. I can't reproduce this error on any of my test systems. I have no idea why GdImage is even involved. Using try/catch to see if it helps.

* Weird Failures in Github

I thought restoring clone was a good idea. That left me in a state where, after one change, copy/clone no longer worked on Github (unable to reproduce on any of my test systems). After a second change, copy worked but clone didn't, again unable to reproduce. So, reverting to original version - copy does save and reload, clone throws exception.
2022-07-28 07:03:26 -07:00
Jonathan Goode e460c82606
Fully flatten an array (#2956)
* Fully flatten an array

* Provide test coverage for CONCAT combined with INDEX/MATCH
2022-07-27 19:29:02 -07:00
oleibman b8456105dd
Charts - Gradients, Transparency, Hidden Axes (#2950)
Fix #2257. Fix #2929. Fix #2935 (probably in a way that will not satisfy the requester). 2257 and 2929 requested changes that ultimately affect the same section of code, so it's appropriate to deal with them together. 2257 requests the ability to make the chart background transparent (so that the Excel gridlines are visible beneath the chart), and the ability to hide an Axis. 2929 requests the ability to set a gradient background on the chart.
2022-07-23 08:06:13 -07:00
oleibman abc1d3db70
Big Memory Leak in One Test (#2958)
* Big Memory Leak in One Test

Many tests leak a little by not issuing disconnectWorksheets at the end. CellMatcherTest leaks a lot by opening a spreadsheet many times. Phpunit reported a high watermark of 390MB; fixing CellMatcherTest brings that figure down to 242MB. I have also changed it to use a formal assertion in many cases where markTestSkipped was (IMO inappropriately) used.

* Another Leak

Issue2301Test lacks a disconnect. Adding one reduces HWM from 242MB to 224.
2022-07-23 07:46:32 -07:00
Vincent Langlet b3f319a8d3 Do not remove @throws 2022-07-22 14:37:20 +02:00
Vincent Langlet faa7c870e9 Add throws tag to writer::save 2022-07-22 11:23:12 +02:00
Mark Baker 0ee13303f3
Merge pull request #2954 from u01jmg3/master
Typo
2022-07-20 12:49:32 +02:00
Jonathan Goode 93b0de0414
Typo 2022-07-20 11:36:40 +01:00