Commit Graph

4130 Commits

Author SHA1 Message Date
dependabot[bot] 86381b73b7 Bump phpstan/phpstan from 1.10.9 to 1.10.14 (#3543)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.10.9 to 1.10.14.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.11.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.10.9...1.10.14)

---
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>
2023-05-01 07:47:44 -07:00
Mikhail Oleynik 6347726ac4 More universal mitoteam/jpgraph notes (#3537) 2023-04-27 20:37:10 -07:00
oleibman c8743061a3 PhpUnit 10 Compatibility Part 3 (Last) (#3530)
* PhpUnit 10 Compatibility Part 3 (Last)

Final changes for PhpUnit 10, including enabling it for testing. This finishes the work of PR #3523 and PR #3526.

The major remaining problem with PhpUnit 10 is that earlier releases converted notices and warnings to exceptions, and 10 does not. Not having the information provided by the messages seems risky to me. Fortunately, it appears that you can add an error handler to the test bootstrap for 10 and make it act like earlier versions; I have done so. In order to demonstrate the effectiveness of this handler, a new otherwise unused class Helper/Handler and tests for that class are added.

As part of the testing of this change, it became apparent that the fopen in OLE::getStream attempts to create a dynamic property $context in Shared/OLE/ChainedBlockStream, and that action is deprecated in Php8.2. Adding the property to the class eliminates that problem. No executable code is added, and this is the only change to source code.

There also seems to have been a change in assertXmlStringEqualsXmlString in PhpUnit 10. The only test which uses that method is Chart/Issue589Test, and both the places which use that method could just as easily and effectively use assertSame. They are changed to do so.

* Remove Phpunit Verbose Option

Not supported in PhpUnit 10. I'm not at all sure that this is the correct solution for this problem.

* Try Changing Phpunit Command for Different Php Releases

Not sure how to test this locally. We'll see if it works on github.

* Another main.yml attempt

We shall see.

* Eliminate One Test

Not sure why testDeprecated is not working in Github; it works locally. Disable it for now and continue to research.

* Show Incomplete and Other Messages in PhpUnit 10

6 new command line args to replace the 1 they got rid of.

* Restore Disabled Test

Deprecated messages are suppressed by default setting for error_reporting. Switch that to E_ALL in bootstrap and restore original test.

* Add Deprecation Tests for PhpUnit 9-

Default configuration option caused deprecation messages to be suppressed. Change the option.
2023-04-27 20:20:25 -07:00
oleibman e9cf27354d PhpUnit 10 Compatibility Part 2 (#3526)
Successor to PR #3523. There are 494 single-line changes (`public function provider` to `public static function provider`) in this PR. None of these were made manually; they were all created with the following script (adapted from
https://stackoverflow.com/questions/25909820/how-to-recursively-iterate-through-files-in-php):
```php
$dir = 'C:/git/unit10prep2/tests/PhpSpreadsheetTests';
$it = new RecursiveDirectoryIterator($dir);

// Loop through files
foreach(new RecursiveIteratorIterator($it) as $file) {
    if ($file->getExtension() === 'php') {
        $contents = file_get_contents($file);
        $new = preg_replace('/public function (\\w*)([Pp])rovider/', 'public static function $1$2rovider', $contents);
        if ($new !== $contents) {
            echo "changing $file\n";
            file_put_contents($file, $new);
        }
    }
}
```

After this PR, there will be one more, with a small number of test changes, and enabling PhpUnit 10 for Php 8.1+.
2023-04-20 13:48:00 -07:00
oleibman 1187825738 PhpUnit 10 Compatibility Part 1 (#3523)
* PhpUnit 10 Compatibility Part 1

This is not a change to move to PhpUnit 10. There is no compelling reason to do so at this time, although it is bound to happen eventually. There are a staggering number of problems (somewhere around 3,000) with the current test suite under PhpUnit 10; this is an attempt to get ahead of the curve by addressing them now.

Method `setOutputCallback` has gone away. This affects only Helper/SampleTest. It appears that `ob_start` and its allies provide an effective equivalent. FWIW, the absence of `setOutputCallback` is a good indication of whether or not PhpUnit 10 is in use, and I will use that fact in a few tests.

Class `ComplexAssert` with no constructor, and always used with `new ComplexAssert()`, extends `TestCase`. Apparently, the constructor for TestCase requires an argument, and PhpUnit 10 complains about not supplying one. Adding an empty constructor to ComplexAssert avoids this problem.

There are two very minor source changes, to Calculation/Calculation and Reader/Xlsx, where problems were exposed with PhpUnit 10 that had not been previously been exposed. AFAIK, these are the only source changes required; the rest of the changes are to test members.

The bulk of the problems are because PhpUnit 10 insists that provider methods be static. Most of those can be changed by a script without any further action; those changes will constitute the Part 2 counterpart of this PR. In this PR you will find the exceptional cases that can't be automated for one reason or another. The tests for Database functions have mild complications that are easily handled. Most of the other provider changes in this PR are because the method names didn't follow an established pattern ('provider' isn't part of the method name); those are also easily handled manually. Modifying the following tests provided significant challenges:
- Writer/Xls/WorkbookTest testAddColor
- Worksheet/Table/TableTest testSetRangeValidRange

The handling of warning messages issued by the code differs in PhpUnit 10. According to the change log, "This means that using PHP functionality which triggers E_DEPRECATED, E_NOTICE, E_STRICT, or E_WARNING or calling code which triggers E_USER_DEPRECATED, E_USER_NOTICE, or E_USER_WARNING can no longer hide a bug in your code." To me, the effect of that change seems to be exactly the opposite - such messages were available to the test with PhpUnit 9 (so we could test for them), and are no longer available (so we can't). I haven't even succeeded with a custom error message handler as part of the script. I will continue to investigate, but, for now, will skip some tests under PhpUnit 10 for the following:
- Shared/OleTest testChainedWriteMode and testChainedBadPath
- Reader/Html/HtmlLoadStringTest testLoadInvalidString
- Reader/Html/HtmlTest testBadHtml

* Scrutinize, and Parent Construct

Parent construct suggested by @MarkBaker.

* Redo Tests Dependent on Warning Messages

Warning (and other) messages are handled differently in PhpUnit 10 than in earlier versions.
2023-04-18 19:50:59 -07:00
oleibman 784eb6cbef Stock Chart Improvements - Minor Break (#3515)
Stock charts currently ignore upDownBars tag and its subsidiary gapWidth, upBars, and downBars tags when reading, and hard-codes those tags on write. As a result, the sample reproductions of stock charts in the 32* series aren't faithful to the originals. This PR fixes samples 1, 2, and 5. Samples 3 and 4 are reproduced better, but they require currently unsupported secondary axes (issue #560, issue #1072, and PR #1073 were closed as stale; see also https://github.com/PHPOffice/PHPExcel/pull/1037). I will start to look at those, but it could take a while, and I don't think there's a reason to delay this in the meantime.

Charts which depended on the hard-coded values written by the Xlsx Chart writer will be slightly different as a result of this change. To restore the hard-coded behavior:
```php
$plotArea->setGapWidth(300);
$plotArea->setUseUpBars(true);
$plotArea->setUseDownBars(true);
```
The new behavior is demonstrated in 33_Chart_create_stock. The old behavior is demonstrated (with the code above) in new 33_Chart_create_stock2.
2023-04-15 07:17:44 -07:00
oleibman a77977d61f Different Hashes for Font File (#3524)
Wanting a sanity test for ExactFontTest, I used the MD5 of a known file. However, there are various versions of the file in the wild, and use of these variants cause test to be skipped. Allow known variations to satisfy MD5 check.
2023-04-13 09:54:19 -07:00
MarkBaker 6cc2bb4e02 Minor update the change log 2023-04-13 18:03:54 +02:00
Mark Baker 4400392aa2 Merge pull request #3521 from PHPOffice/Examples_Charts-Render-as-Images
Improve web-rendering of Chart Examples by displaying the rendered image
2023-04-13 15:08:29 +02:00
Mark Baker db14712df7 Merge branch 'master' into Examples_Charts-Render-as-Images 2023-04-13 13:25:25 +02:00
MarkBaker ddb9891d05 Don't try to render every chart in CLI mode 2023-04-13 11:23:34 +02:00
Mark Baker ec0e45955d Merge pull request #3522 from PHPOffice/Examples-Improve-Reader-Display
Improve web-rendering of Reader Examples by displaying the loaded wor…
2023-04-13 11:10:16 +02:00
MarkBaker d3a1b43822 Improve web-rendering of Reader Examples by displaying the loaded worksheet grids 2023-04-13 10:35:38 +02:00
MarkBaker 71898419ce Improve web-rendering of Chart Examples by displaying the rendered image 2023-04-12 11:26:05 +02:00
oleibman 86d2505925 Documentation Updates (#3517)
Fix #3471. Fix #3514. No code changes.
2023-04-10 08:45:14 -07:00
oleibman ffc6f307d3 Change Log (#3516)
* Change Log

Catch up some undocumented changes.

* Missed One

Add it now.
2023-04-08 23:28:48 -07:00
oleibman aab16147e4 Add Ability to Ignore Cell Errors in Excel (#3508)
* Add Ability to Ignore Cell Errors in Excel

Fix #1141, which had been closed as stale, but which I have reopened. Excel will show cells with certain "errors" with a green triangle in the upper left. The suggestion in the issue to use quotePrefix to suppress the numberStoredAsText error is ineffective. In Excel, the user can turn this indicator off for individual cells. Cells where this is turned off can be detected at read time, and PhpSpreadsheet will now process those. In addition, the user can explicitly set the ignored error as in Excel.
```php
$cell->setIgnoredErrorNumberStoredAsText(true);
```

There are a number of different errors that can be ignored in this fashion. This PR implements `numberStoredAsText` (which is likely to be by far the most useful one), `formula`, `twoDigitTextYear`, and `evalError`, all of which are demonstrated in the new test spreadsheet. There are several others for which I am not able to create good examples; I have not implemented those, but they can be easily added if needed (`calculatedColumn`, `emptyCellReference`, `formulaRange`, `listDataValidation`, and `unlockedFormula`).

* Scrutinizer

A new change, a new Scrutinizer false positive.

* Move Ignored Errors to Own Class

In response to comments from @MarkBaker, implement ignoredError as a new class. This simplifies Cell by requiring only 1 new method, rather than 8+. This requires a slightly more complicated syntax.
```php
$cell->getIgnoredErrors()->setNumberScoredAsText(true);
```

Mark had also suggested that there might be a pre-existing regexp for processing the cells/cellranges when reading the sqref attribute. Those in Calculation are too complicated (read "non-performant") for this piece of code; the one in Coordinates is slightly less complicated than Calculation, but still more complicated than the one I'm using, and doesn't handle ranges.
2023-04-08 21:58:07 -07:00
Mark Baker 5ef48e90ce Merge pull request #3512 from PHPOffice/Issue-3511_NumberFormat-colour-indexed-palette
Allow color palette index values in number format masks
2023-04-07 12:21:47 +02:00
Mark Baker 24725c8f74 Merge branch 'master' into Issue-3511_NumberFormat-colour-indexed-palette 2023-04-07 12:08:33 +02:00
Mark Baker e5ed8e932b Merge pull request #3509 from PHPOffice/Stricter-Identify-Spreadsheet-Files-Only
Validate that OLE file contains a workbook object (ie. isn't a doc or a ppt file)
2023-04-07 01:55:38 +02:00
Mark Baker 9e384a1094 Merge branch 'master' into Stricter-Identify-Spreadsheet-Files-Only 2023-04-07 01:37:56 +02:00
MarkBaker 44c74f8eca Update change log 2023-04-06 10:18:22 +02:00
Mark Baker 937d5f7450 Merge pull request #3510 from PHPOffice/Examples-Fixed-Header
Fix header for examples to make navigation easier
2023-04-06 03:42:15 +02:00
MarkBaker c5fb58fe68 Allow color palette index values in number format masks 2023-04-06 03:41:20 +02:00
Mark Baker 5c3d360fe6 Merge branch 'master' into Examples-Fixed-Header 2023-04-06 03:31:00 +02:00
Mark Baker c7cd388bf3 Merge pull request #3506 from PHPOffice/Samples-Table-Column-Formula-with-Total
New Autofilter example: column formula with totals
2023-04-06 03:30:31 +02:00
Mark Baker f6f7b47427 Merge branch 'master' into Samples-Table-Column-Formula-with-Total 2023-04-06 03:13:27 +02:00
oleibman e5697fbc4e Xlsx Reader Formula with quotePrefix (#3497)
Fix #3495. This seems to be a bug in Excel, one which it manages to cover up but PhpSpreadsheet is affected. User enters a formula preceded by an apostrophe into a cell. Excel turns on `quotePrefix` style and stores the data as a string rather than a formula. User now enters a formula not preceded by an apostrophe into the same cell. Excel stores it is a formula but does not turn `quotePrefix` off. When the spreadsheet is saved, the cell's style specifies `quotePrefix`, but the cell's content indicates it's a formula. Till now, PhpSpreadsheet sees that quotePrefix is set, and therefore treats the cell's contents as a string rather than a formula. This PR will change that behavior so that quotePrefix is automatically turned off when Xlsx Reader sees that the cell indicates that it is a formula.
2023-04-04 07:29:47 -07:00
MarkBaker 495a011d26 Fix header for examples to make navigation easier 2023-04-04 01:47:38 +02:00
MarkBaker ee1075dc09 Validate that OLE file contains a workbook object (ie. isn't a doc or a ppt file) 2023-04-04 00:14:15 +02:00
MarkBaker 0613cbd1bf New Autofilter example: column formula with totals 2023-04-03 04:55:04 +02:00
Mark Baker 5da2f6ec42 Merge pull request #3503 from PHPOffice/Examples-AutoFilter-Improvements
Examples auto filter improvements
2023-04-02 21:49:38 +02:00
Mark Baker 82e513162f Merge branch 'master' into Examples-AutoFilter-Improvements 2023-04-02 21:30:46 +02:00
Mark Baker 0e17cbb480 Merge pull request #3505 from PHPOffice/Issue-3504_Structured-Reference-Range-Cache
Resolve Issue #3504
2023-04-02 21:29:47 +02:00
MarkBaker 8e3f385224 Resolve Issue #3504
Cached result for a this row range with structured references
2023-04-02 20:22:51 +02:00
MarkBaker 44f3dbe82b Improved Table examples 2023-04-02 20:05:59 +02:00
MarkBaker 9cf41b5dd2 Improved AutoFilter examples 2023-04-02 20:05:43 +02:00
MarkBaker 3f418ceb9a Merge branch 'master' into Examples-AutoFilter-Improvements 2023-04-01 22:44:17 +02:00
Mark Baker 378d46b761 Merge pull request #3494 from PHPOffice/Worksheet-toArray_Ignore-Hidden-Rows-Columns-Option
Provide an Ignore/Return Hidden rows/columns option to the `toArray()` methods
2023-04-01 22:39:12 +02:00
Mark Baker 5ebb1c9943 Merge branch 'master' into Worksheet-toArray_Ignore-Hidden-Rows-Columns-Option 2023-04-01 22:22:23 +02:00
dependabot[bot] f4e897e3b9 Bump mitoteam/jpgraph from 10.2.5 to 10.2.6 (#3502)
Bumps [mitoteam/jpgraph](https://github.com/mitoteam/jpgraph) from 10.2.5 to 10.2.6.
- [Release notes](https://github.com/mitoteam/jpgraph/releases)
- [Commits](https://github.com/mitoteam/jpgraph/compare/10.2.5...10.2.6)

---
updated-dependencies:
- dependency-name: mitoteam/jpgraph
  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>
2023-04-01 09:02:07 -07:00
dependabot[bot] efa462f76f Bump friendsofphp/php-cs-fixer from 3.14.4 to 3.15.1 (#3501)
Bumps [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) from 3.14.4 to 3.15.1.
- [Release notes](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases)
- [Changelog](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/compare/v3.14.4...v3.15.1)

---
updated-dependencies:
- dependency-name: friendsofphp/php-cs-fixer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-01 08:56:09 -07:00
dependabot[bot] 74f455a373 Bump phpstan/phpstan-phpunit from 1.3.9 to 1.3.11 (#3500)
Bumps [phpstan/phpstan-phpunit](https://github.com/phpstan/phpstan-phpunit) from 1.3.9 to 1.3.11.
- [Release notes](https://github.com/phpstan/phpstan-phpunit/releases)
- [Commits](https://github.com/phpstan/phpstan-phpunit/compare/1.3.9...1.3.11)

---
updated-dependencies:
- dependency-name: phpstan/phpstan-phpunit
  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>
2023-04-01 08:19:36 -07:00
dependabot[bot] 79ecc8bbae Bump phpstan/phpstan from 1.10.3 to 1.10.9 (#3499)
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.10.3 to 1.10.9.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Changelog](https://github.com/phpstan/phpstan/blob/1.10.x/CHANGELOG.md)
- [Commits](https://github.com/phpstan/phpstan/compare/1.10.3...1.10.9)

---
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>
2023-04-01 07:52:31 -07:00
dependabot[bot] 9ded32a72f Bump phpunit/phpunit from 9.6.4 to 9.6.6 (#3498)
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.6.4 to 9.6.6.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/main/ChangeLog-9.6.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.6.4...9.6.6)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  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>
2023-04-01 07:42:11 -07:00
oleibman d6180ad113 Font Themes (#3486)
* Font Themes

It isn't a feature of Excel that I've made any use of, but PR #3476 added better Theme support for colors, and it is relatively easy to add Theme support for Fonts on top of that.

Excel assigns two theme fonts to its spreadsheets, one for Headings (major), and one for Body (minor). If the body theme is Calibri, when you choose a font for a cell in Excel, you can choose 'Calibri (Body)' from the Theme Fonts section at the top of the Font dropdown, or 'Calibri' from the 'All Fonts' section. If you choose the former, the cell will be automatically restyled if you change the Theme Fonts (via Page Layout, Themes, Fonts). The relationship to the theme fonts is recorded in the XML via a `scheme` tag (descending from `font`) whose `val` attribute can be either `major` or `minor`. Accordingly, this PR, in addition to defining the Theme Font properties, adds a `scheme` property, with getter and setter, to Style/Font.

The main benefit of this PR is that you can now load and save a spreadsheet preserving the connections to the Theme Fonts, without having to take any additional action.

A secondary benefit arises from the following difference. Empty cells in Excel will use the spreadsheet's default font name when they are filled in; but, in Google Sheets, they will use the Theme Minor Font name. By setting the `scheme` property in the default style, the resulting spreadsheet will behave the same in both Excel and Google.

I will note that Excel's font themes specify a Latin font, an East Asian font, a Complex Scripts font, and a set of font substitutions for various languages. PhpSpreadsheet will preserve all of these, and allow them to be changed. However, although it is easy to imagine how the non-Latin options might work, I have not yet been able to come up with an example where Excel uses any of them. In particular, if I use a theme font which does not support language X, and I use Language X in a cell bound to the theme, Excel will use a substitution font which does support it, but the font which it uses does not seem to be chosen from the alternatives supplied in the theme.

* Scrutinizer

The sun rises in the east, and Scrutinizer issues more false positives.
2023-03-31 17:12:37 -07:00
Mark Baker ab83bfab88 Merge pull request #3496 from PHPOffice/CalcEngine-Improved-Range-Logging
Add result logging for Range operator
2023-03-31 20:12:51 +02:00
Mark Baker 1781baae25 Merge branch 'master' into CalcEngine-Improved-Range-Logging 2023-03-31 19:45:23 +02:00
MarkBaker 0eef2c9d29 Add result logging for Range operator 2023-03-31 19:28:59 +02:00
Mark Baker e35b39a9c9 Merge pull request #3482 from PHPOffice/Xlsx-Reader_Windows-Folder-Separator-in-Zip
Handle zips with Windoze directory separators (`\`) rather than the standard linux (`/`)
2023-03-31 13:32:47 +02:00