Commit Graph

3550 Commits

Author SHA1 Message Date
oleibman 3861f7e37e
Charts - Add Support for Date Axis (#3018)
* Charts - Add Support for Date Axis

Fix #2967. Fix #2969 (which had already been fixed prior to opening the issue, but had added urgency for Date Axes). Add ability to set axis type to date axis, in addition to original possiblities of value axis and category axis.

* Update 33_Chart_create_line_dateaxis.php

No idea why php-cs-fixer is complaining. It didn't do so when I first uploaded. I can't duplicate problem on my own system. Not enough detail in error message for me to act. Grasping at straws, I have moved the function definition (which is the only use of braces in the entire script) from the end of the script to the beginning.

* Update 33_Chart_create_line_dateaxis.php

Some comments were mis-aligned. This may be related to the reasons behind PR #3025, which didn't take care of this because this script had not yet been merged.
2022-08-24 19:31:55 -07:00
oleibman e97428ba67
Html Writer - Do Not Generate background-color When Fill is None (#3016)
* Html Writer - Do Not Generate background-color When Fill is None

For PR #3002, I noted that there was a problem with Dompdf truncating images. I raised an issue with them (https://github.com/dompdf/dompdf/issues/2980), and they agree that there is a bug; however, they also suggested a workaround, namely omitting background-color from any cells which the image overlays. That did not at first appear to be a solution which could be generalized for PhpSpreasheet. However, investigating further, I saw that Html Writer is generating background-color for all cells, even though most of them use the default Fill type None (which suggests that background-color should not be specified after all). So this PR changes HTML Writer to generate background-color only when the user has actually set Fill type to something other than None. This is not a complete workaround for the Dompdf problem - we will still see truncation if the image overlays a cell which does specify a Fill type - however, it is almost certainly good enough for most use cases.

In addition to that change, I made the generated Html a little smaller and the code a little more efficient by combining the TD and TH styles for each cell into a single declaration and calling createCssStyle only once.

* Revamp One Test

Look for both td.style and th.style instead of just td.style in test.
2022-08-24 18:00:37 -07:00
Alexis Lefebvre d0781c3fd2
Explain that UoM = Unit of Measure (#3014) 2022-08-24 17:47:22 -07:00
Mark Baker f039a24bc7
Merge pull request #3025 from PHPOffice/Minor-Tweaks
Minor changes, mainly cosmetic
2022-08-24 16:30:40 +02:00
MarkBaker 99c6fed1e0 Minor changes, mainly cosmetic 2022-08-24 16:19:41 +02:00
Mark Baker cc17d2fef9
Merge pull request #3019 from PHPOffice/Cache-SimpleCache3-Support
Support for SimpleCache Interface versions 1.0, 2.0 and 3.0
2022-08-21 18:49:44 +02:00
Mark Baker 18ca844981
Merge branch 'master' into Cache-SimpleCache3-Support 2022-08-21 18:31:31 +02:00
oleibman d55978cf93
Correct Namespaces in 11 Tests (#3020)
The setup for unit testing in Github in the "Install dependencies" log reports 11 members as "does not comply with with psr-4 autoloading standard." In each case, it is because the test namespace does not match the directory; in most cases, it was caused by the member being moved from one directory to another without changing the namespace declaration. No harm results from these problems, but there's also no reason to not correct them.
2022-08-20 19:58:43 -07:00
MarkBaker e67de6f300 Support for SimpleCache Interface versions 1.0, 2.0 and 3.0; to stop people moaning; even though it requires a second implementation of the Memory cache for Cells 2022-08-20 21:27:05 +02:00
MarkBaker 4e82b55f37 Update Change Log 2022-08-19 14:26:39 +02:00
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