Commit Graph

3574 Commits

Author SHA1 Message Date
Mark Baker 47067494f5
Merge branch 'master' into Calculation-Examples 2022-09-14 20:13:38 +02:00
oleibman 8513c6418c
Memory Leak in Sample35 (#3062)
* Memory Leak in Sample35

All but 6 chart samples can be rendered by Sample35. Of those 6, 3 of the problems are because the script runs out of memory processing them. Adopting a suggestion from @MAKS-dev in issue #2092, adding a call to gc_collect_cycles after the charts from each spreadsheet is rendered appears to make it possible to include those 3 spreadsheets in Sample35 after all.

Also take advantage of this opportunity to correct a number (hopefully all) of Scrutinizer problems with JpgraphRendererBases.

* Minor Fix

Problem running 8.1 unit tests.

* Resolve Problems with Pie 3D Charts

Minor fix, leaving only one spreadsheet unusable in Sample35. The reasons for its unusability are now documented in the code.

* Mitoteam Made Changes

Discussing this problem with them, they decided they should make a change for Pie3D rather than forcing us to use the workaround pushed earlier. Change to require mitoteam 10.2.3, revert workaround.
2022-09-14 10:12:53 -07:00
oleibman 6c1651e995
Floating-point Equality in Two Tests (#3064)
* Floating-point Equality in Two Tests

Merging a change today, Git reported failures that did not occur during "normal" unit testing. The merge still succeeded, but ... The problem was an error comparing float values for equal, and the inequality occurred beyond the 14th decimal digit. Change the tests in question, which incidentally were not part of the merged changed, to use assertEqualsWithDelta.

* Egad - 112 More Precision-related Problems

Spread across 9 test members.
2022-09-14 09:05:01 -07:00
oleibman 252474c1bd
Scrutinizer Clean Up Tests (#3061)
* Scrutinizer Clean Up Tests

No source code involved.

* Scrutinizer Whack-a-mole

Fixed 17, added 10. Trying again.

* Simplify Some Tests

Eliminate some null assertions.

* Dead Code

Remove 2 statements.
2022-09-14 07:11:20 -07:00
MarkBaker 441ae741d7 Update Excel function samples for Date/Time and Engineering functions 2022-09-14 14:16:32 +02:00
oleibman 3e8d50547c
Minor Fix for Percentage Formatting (#3053)
Fix #1929. This was already substantially fixed, but there was a lingering problem with an unexpected leading space. It turns out there was also a problem with leading zeros, also fixed. There are also problems involving commas; fixing those seems too complicated to delay these changes, but I will add it to my to-do list.
2022-09-12 08:45:13 -07:00
oleibman 2fe66d097f
Upgrade mitoteam/jpgraph for Php8.2 Usage (#3058)
They just released a Php8.2-compatible version. We should use that version going forward. Some tests had been disabled in 8.2 due to the problems which the new release fixes; these are now restored.
2022-09-12 08:23:43 -07:00
oleibman b5f70de61d
More Scrutinizer Catch Up (#3050)
* More Scrutinizer Catch Up

Continue the work of PR #3043 by attending to the 12 remaining 'new' issues.

* Php 8.1 Problem

One new null-instead-of-string problem.
2022-09-09 07:56:11 -07:00
oleibman 7e3807309d
Reconcile Differences between Css and Excel For Cell Alignment (#3048)
This PR expands on PR #2195 from @nkjackzhang. That PR has been stalled for some time awaiting requested fixes. Those fixes are part of this PR, and additional tests and samples are added. The original request was to handle `vertical-align:middle` in Css (Excel uses `center`). This PR does its best to also handle vertical alignment Excel values not found in Css - `justify` (as `middle`) and `distributed` (as `middle`). It likewises handles valid Css values not found in Excel (`baseline`, `sub`, and `text-bottom` as `bottom`; `super` and `text-top` as `top`; `middle` as `center`).

It also handles horizontal alignment Excel values not found in Css - `center-continuous` as `center` and `distributed` as `justify`; I couldn't think of a reasonable equivalent for `fill`, so it is ignored.

The values assigned for vertical and horizontal alignment are now lower-cased (special handling required for `centerContinuous`).
2022-09-09 07:34:36 -07:00
Mark Baker 420a63bc01
Merge pull request #3047 from PHPOffice/Calculation-Examples
Update Excel function samples for Database and Date/Time functions
2022-09-04 22:56:23 +02:00
Mark Baker 350f38ca60
Merge branch 'master' into Calculation-Examples 2022-09-04 22:46:11 +02:00
MarkBaker 3884aa7477 Update Excel function samples for Date/Time functions 2022-09-04 21:06:42 +02:00
oleibman adbda63912
Phpstan and Xlsx Reader (#3043)
Eliminate most Phpstan messages in Xlsx Reader. In combination with similar changes to Xlsx Writer, baseline will shrink to just over 3,000 lines.
2022-09-04 10:43:31 -07:00
oleibman 57a72037b5
Phpstan and Xlsx Reader (#3044)
Eliminate most Phpstan messages in Xlsx Reader. In combination with similar changes to Xlsx Writer, baseline will shrink to just over 3,000 lines.
2022-09-04 09:45:29 -07:00
oleibman 5f33ec0eea
Phpstan Baseline < 4000 Lines Part 3 (#3041)
The last of these changes for now. No remaining Phpstan complaints in any Writer/Xlsx. Number of lines remaining in Phpstan baseline is now below 3500.
2022-09-03 19:00:01 -07:00
MarkBaker ad2d3df2f7 Update Excel function samples for Database functions 2022-09-03 14:26:41 +02:00
oleibman 4f8aa806bc
Phpstan Baseline < 4000 Lines Part 2 Html (#3037)
Continue to reduce the size of Phpstan Baseline by fixing problems reported for Writer/Html.
2022-08-30 22:34:20 -07:00
oleibman 9eb5e7e976
Phpstan Baseline < 4000 Lines Part 1 (#3023)
A lot of easily fixed problems throughout Writer/Xlsx/*, mostly supplying int rather than string as input to WriteAttribute/WriteElement. There are, in fact, so many opportunities, that I will split it over 2 or 3 PRs. But this first one will get Phpstan baseline down to the goal on its own.

Some of the other problems are also easily fixed. In particular, the docBlocks in Style/ConditionalFormatting/ConditionalDataBar do not allow for null values, and should.
2022-08-29 22:15:50 -07:00
MarkBaker 026f699a65 Minor documentation updates 2022-08-29 17:14:03 +02:00
oleibman ca90379dc4
2 Minor Phpstan-related Fixes (#3030)
For one of the Phpstan upgrades, some message text had changed so drastically that the only practical solution at the time was to move the messages from phpstan-baseline.neon to phpstan.neon.dist. This was not ideal, but it allowed us time to move on and study the errors, which I have now done. At one point, Parser is expecting a variable to be an array, and that was not clear from the code. If not an array, the code will error out (which was Phpstan's concern); I have changed it to throw an exception instead. This satisfies Phpstan, and I can get the message out of neon.dist (without needing to restore it to baseline). Unsurprisingly, the exception was never thrown in the existing test suite, although I added a couple of tests to exercise that code.

In Helper/Dimension, Phpstan flagged a statement inappropriately. I suppressed the message using an annotation and filed a bug report https://github.com/phpstan/phpstan/issues/7563. A fix for the problem was merged yesterday, which is good, but it puts us in a tenuous position. The annotation is needed now, but, when the fix is inevitably pushed to the version we use, the no-longer-needed annotation will trigger a different message. Recode so that neither the current nor the future versions will issue a message, eliminating the annotation in the process.
2022-08-27 23:15:16 -07:00
oleibman 389ca80e00
Additional Properties for Trendlines (#3028)
Fix #3011. Some properties for Trendlines were omitted in the original request for this feature. Also, the trendlines sample spreadsheet included two charts. The rendering script 35_Chart_render handles this, but overlays the first output file with the second. It is changed to produce files with different names.
2022-08-27 22:59:35 -07:00
Mark Baker 24f1a2fbc1
Merge pull request #3033 from PHPOffice/ExcelFunctions-ValueToText
Implementation of the `VALUETOTEXT()` Excel Function
2022-08-27 16:36:18 +02:00
MarkBaker f7a3534928 Implementation of the `VALUETOTEXT()` Excel Function 2022-08-27 16:23:55 +02:00
oleibman 131708409b
Correct Very Minor Error / Php8.2 Deprecation (#3021)
When Reader/Xlsx/WorkbookView was split off from Reader/Xlsx.php, one statement accidentally brought `!empty($this->loadSheetsOnly)` with it. That property does not exist in WorkbookView, so the test is useless (it is always empty); and, in fact, the caller passes its own version of loadSheetsOnly as a parameter, so it isn't needed even it did exist. In Php8.2, this might be a deprecation, although it hasn't shown up in the GitHub 8.2 tests. Fix it anyhow.
2022-08-25 23:22:59 -07:00
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