Commit Graph

4641 Commits

Author SHA1 Message Date
oleibman 02479de01a CSV Writer Allow Varying Number of Columns
Supersedes PR #1415 by @AndrewMonty, which went stale in May 2020, and which is not directly usable due to changes between now and then. Fix #1414, which also went stale; I will remove the stale status and reopen the issue pending the merging of this PR.

Add an option to CSV Writer so that it writes the cells for a row only through the highest data column used in the row, rather than through the highest data column used in the worksheet.
2024-06-27 00:01:55 -07:00
oleibman 318a82e0f9 Merge pull request #4057 from oleibman/unitstan
Phpunit 10 and Phpstan 1.11
2024-06-03 13:28:08 +00:00
oleibman 192d4a3dd5 Resolve Phpstan missingType.generics
Doc-block changes only; no change to executable code.
2024-06-02 14:40:07 -07:00
oleibman 6be8be8c1b Update Phpunit Command in main.yml 2024-06-01 17:50:22 -07:00
oleibman 9b239ebdb0 Phpunit 10 and Phpstan 1.11
Dependabot suggested some changes this month which required an unusual effort to implement successfully. With the elimination of Php 8.0 as a supported environment, it became possible to use Phpunit 10 rather than 9. Among other considerations, the configuration file for Phpunit is changed. I preserved the Phpunit 9 version under a different name. Aside from the configuration change, several other changes needed to be made to accommodate the change:
- Fix #3993. A peculiar problem indeed. One of the reporters said it had something to do with mocking, but I couldn't duplicate it. But Phpunit 10 revealed the problem in one test (Reader/Xlsx/AutoFilterTest), and that was sufficient for me to apply the trivial source code change to Worksheet/Worksheet.
- Some extra stringency on data providers required extra work in Calculation/CalculationFunctionListTest.
- There was a misplaced label in Calculation/ParseFormulaTest. Likewise in the data member CellGetRangeBoundaries.
- More stringency required changes to data members Shared/Trend/ExponentialBestFit and Shared/Trend/LinearBestFit.
- Issue3982Test testLoadAllRows seemed to go into a memory-acquiring loop in 10 that was not evident in 9. This particular test uses a lot of memory by design, but was included only to establish a base level for the other tests in that member. I feel it is acceptable to skip it for 10.

Phpstan errors with a new release are not unusual. One of the problems this time around was, however, unusual - it is fixed when Phpstan runs under Php8.3, but not for earlier Php releases. Our tools currently use Php 8.1. It is on my to-do list to get Phpstan and other test tools running under 8.3 before 8.1 goes EOL. There are also some configuration file changes needed for Phpstan.

Php-cs-fixer has been taking an increasingly long time to run. They've added an experimental option to permit it to run its checks in parallel. I've changed its configuration to use that option.
2024-06-01 17:39:39 -07:00
oleibman 101f90310f Merge pull request #4054 from PHPOffice/dependabot/composer/dompdf/dompdf-3.0.0
Bump dompdf/dompdf from 2.0.8 to 3.0.0
2024-06-01 13:29:14 +00:00
oleibman 5c8f95cdd4 Merge pull request #4052 from PHPOffice/dependabot/composer/squizlabs/php_codesniffer-3.10.1
Bump squizlabs/php_codesniffer from 3.9.2 to 3.10.1
2024-06-01 13:28:37 +00:00
oleibman 8a22155e09 Merge pull request #4051 from PHPOffice/dependabot/composer/friendsofphp/php-cs-fixer-3.58.1
Bump friendsofphp/php-cs-fixer from 3.56.1 to 3.58.1
2024-06-01 13:28:22 +00:00
dependabot[bot] caa148ade8 Bump dompdf/dompdf from 2.0.8 to 3.0.0
Bumps [dompdf/dompdf](https://github.com/dompdf/dompdf) from 2.0.8 to 3.0.0.
- [Release notes](https://github.com/dompdf/dompdf/releases)
- [Commits](https://github.com/dompdf/dompdf/compare/v2.0.8...v3.0.0)

---
updated-dependencies:
- dependency-name: dompdf/dompdf
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 11:10:05 +00:00
dependabot[bot] 5db40920cc Bump squizlabs/php_codesniffer from 3.9.2 to 3.10.1
Bumps [squizlabs/php_codesniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) from 3.9.2 to 3.10.1.
- [Release notes](https://github.com/PHPCSStandards/PHP_CodeSniffer/releases)
- [Changelog](https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PHPCSStandards/PHP_CodeSniffer/compare/3.9.2...3.10.1)

---
updated-dependencies:
- dependency-name: squizlabs/php_codesniffer
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-01 11:09:56 +00:00
dependabot[bot] 2914239d9c Bump friendsofphp/php-cs-fixer from 3.56.1 to 3.58.1
Bumps [friendsofphp/php-cs-fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) from 3.56.1 to 3.58.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.56.1...v3.58.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>
2024-06-01 11:09:52 +00:00
oleibman 3360608cdd Merge pull request #4042 from oleibman/issue4039
Conditional Range Unions and Intersections
2024-06-01 01:07:59 +00:00
oleibman a6000b63e5 Update CHANGELOG.md 2024-05-31 18:04:55 -07:00
oleibman 1852923c62 Merge pull request #4050 from oleibman/issue4049
Conditional Color Scale Improvements
2024-05-31 15:53:34 +00:00
oleibman 15fb1b542a Merge branch 'master' into issue4049 2024-05-31 08:50:17 -07:00
oleibman 24e6f4d837 Update CHANGELOG.md 2024-05-31 08:48:34 -07:00
oleibman 626b08fcd3 Merge pull request #4026 from oleibman/stan9c
Better Definitions for Mixed Parameters and Values Part 2 of Many
2024-05-31 04:04:05 +00:00
oleibman d539dfa2d5 Merge pull request #4047 from oleibman/issue3557
Writer Mpdf and Tcpdf Borders on Merged Cells
2024-05-30 17:14:48 +00:00
oleibman 60d49eca1c Merge branch 'master' into issue3557 2024-05-30 10:11:18 -07:00
oleibman 52743f9e1b Update CHANGELOG.md 2024-05-30 10:08:51 -07:00
oleibman fcc5cf1369 Minor Test Improvement 2024-05-30 09:35:40 -07:00
oleibman 2760e5abb7 Conditional Color Scale Improvements
Fix #4049. Some possible options were not included for read or write. In addition, although it isn't well documented, it appears that 2-color scale always has 2 cvfo entries in Xml in order minimum/maximum, and 3-color scale always has 3 entries in order minimum/midpoint/maximum.
2024-05-30 00:19:11 -07:00
oleibman 0b4bdfb510 Add Disconnects to Tests 2024-05-29 19:23:33 -07:00
oleibman cf6c8046eb Full(?) Conditional Range Union and Intersection Support
Provide a means to convert a range, possibly with unions and possibly with intersections, into something that both Excel and PhpSpreadsheet can handle. Intersections are changed into unions of the individual cells which they comprise. With this change, Xls Writer now handles intersections (previously it would have thrown an Exception or created a corrupt worksheet if this was attempted), and Xlsx Writer works correctly (it seemed to before, but Excel didn't understand what it wrote). Worksheet::getConditionalRange and ::getConditionalStyles would previously have thrown an Exception when presented with an intersection, and will no longer do so.

**NOTE:** Intersection support is limited to Conditional ranges. Use of intersections in other contexts will usually not achieve the desired result.
2024-05-29 08:19:17 -07:00
oleibman c65674cbcb Merge branch 'master' into issue4039 2024-05-28 17:17:54 -07:00
oleibman c8f5c62e5d Invert Union and Intersection Between Excel and Xml
I don't know why MS did this. We're stuck with it.
2024-05-28 17:01:45 -07:00
oleibman 4be300865c Writer Mpdf and Tcpdf Borders on Merged Cells
Fix #3557. Borders around merged cells are not handled correctly for Mpdf. Although a perfectly acceptable workaround is suggested in the issue, it would be better if things just worked without the workaround. Html and Dompdf work with the existing code. As it turns out, Tcpdf does not work, but for a different reason than Mpdf.

Mpdf was not working because Mpdf does not honor the `!important` attribute in Css. We can get it working almost perfectly by suppressing `border*:none`; the exception is fairly Byzantine, and I'll be glad to discuss the matter should anyone report a problem with it. At any rate, it's not working now in the exception case, so we won't be any worse off.

Tcpdf was not working because the merging of attributes happened only when `useInlineCss` was not being used, but Tcpdf does use it. Merging of border attributes is now added for useInlineCss.
2024-05-27 16:38:04 -07:00
oleibman 68218c175d Merge pull request #4033 from oleibman/condxlsborder
Xls Conditional Border
2024-05-26 01:53:12 +00:00
oleibman d0c49cd666 Merge branch 'master' into condxlsborder 2024-05-25 18:46:13 -07:00
oleibman 8e87f554b1 Merge pull request #4035 from oleibman/issue3982a
Xlsx Reader Optionally Ignore Rows With No Cells
2024-05-25 13:45:54 +00:00
oleibman 75d630cd0e Update CHANGELOG.md 2024-05-25 06:42:38 -07:00
oleibman 7b25b18a8b Merge pull request #4040 from oleibman/issue4036
Csv Reader Allow Use of mimetype=text/html Files Without Extension
2024-05-25 04:23:56 +00:00
oleibman 72f53de761 Update CHANGELOG.md 2024-05-24 21:18:51 -07:00
oleibman a51d3541c0 Php 8.4 Change Affects Test
mime_content_type will recognize files as text/csv rather than text/html.
2024-05-24 21:00:25 -07:00
oleibman 7ce0184f8e Don't Interfere with SelectedCells And Other Changes
Xls Reader processing Conditionals interferes with the previously established SelectedCells. Make sure that value is restored.

StopIfTrue should always be set for Xls spreadsheet.

Set NoFormatSet to true unless any of Font, Fill, or Borders is specified in Conditional Style.

In my notes for PR #3372, I mentioned that I could not include some Xls tests because of errors in the software at that time. This PR fixes those errors, so I am adding the missing test, and making the equivalent Xlsx test more comprehensive.
2024-05-24 07:58:36 -07:00
oleibman 33edddf40d Split Conditional Ranges
Fix #4039. Excel sometimes stores the location for a Conditional as, say, `B1:B10 C1:C10` rather than `B1:C10`. PhpSpreadsheet does not have a problem with this, but internally stores it as separate Conditionals, one for each range. (There may be more than 2.) User would like it stored as a single Conditional. Since the range is used as the index of an array which holds the conditionals, there is no technical reason why this can't be done. And it does seem like being able to change multiple ranges all at once has some advantages, whether you're doing it in PhpSpreadsheet or in Excel itself.

Making such a change in Xlsx Reader showed no problem in Xlsx Reader and Writer tests. A number of problems did show up in CellMatcherTest, and one in WizardFactoryTest. This was good news, because it meant some of our test spreadsheets used the same type of construction as the test spreadsheet supplied with the issue. So, if additional fixes make the test problems go away, I think no new tests are required. And a smattering of source changes did indeed result in a clean test suite once more.

This is a change, but I don't really think it should break anyone. So I don't think it's necessary to add an option  to opt in to the old or new behavior. I could be wrong. I'll leave this ticket open for at least a couple of weeks to see if anyone thinks otherwise.
2024-05-23 17:27:37 -07:00
oleibman 66415974a5 Merge pull request #4041 from Maikuolan/patch-1
Fix typo.
2024-05-23 13:32:13 +00:00
Caleb Mazalevskis 4dd7000647 Fix typo. 2024-05-23 10:58:17 +08:00
oleibman 2833ddc22d Csv Reader Allow Use of mimetype=text/html Files Without Extension
Fix #4036. The issue was originally reported as #564 (and #811) and fixed for the most part, but this is a variation that was not covered by the original. Cells with html fragments can cause `mime_content_type` to identify the file as `text\html`. Original fix was to ignore mime_content_type when file extension is 'csv' or 'tsv'. However, if the file does not have one of those extensions, it will be rejected by Csv Reader as invalid mimetype. This PR adds text\html to the list of valid mimetypes.

I imagine that this type of problem might occur for other mimetypes. If any of those are reported in future, it might be better to just add a "suppress mimetype" check option, rather than extending the list forever. Html is unusual in that its rules are so lax, which is why it seems appropriate to add it here.

Note that IOFactory may still identify a file as Html even when intended as Csv. The sample associated with this issue does not fall into this category, but one of the unit tests on this ticket does. The file will still be read correctly by Csv Reader, but IOFactory load may cause it to use Html Reader instead.
2024-05-22 08:24:06 -07:00
oleibman 0c2708b1c6 Xlsx Reader Optionally Ignore Rows With No Cells
Fix #3982. A number of issues submitted about Xlsx read performance have a common theme, namely that row 1,048,576 and a few rows before it are defined in the worksheet Xml with no cells attached to them. These might be the work of a third party product. While these extraneous rows do not cause any problems for the cells that are actually used on the worksheet, they can lead to excessive memory use. This PR provides an option for the application to ignore rows with no cells when loading.

Recent changes to the load logic had already made a significant difference to memory consumption and load time. For the spreadsheet attached to issue 3982, which had caused out-of-memory errors on the user's system, peak memory usage was already reduced to 40-odd MB. With the new option, this is drastically reduced again, to just over 9MB. Specifying the new option is very easy:
```php
$reader->setIgnoreRowsWithNoCells(true);
```
Note that there are cases where you might not want this (non-default) behavior. For example, if you set a row height on a row with no cells, the height would be lost with this option. Unfortunately, the extraneous row definitions in the problematic spreadsheets claim to have a custom height, so I can't just use "no custom row styles" as an additional filter.
2024-05-21 19:16:08 -07:00
oleibman 313dcc537b Scrutinizer Identified Some Dead Code 2024-05-21 01:38:32 -07:00
oleibman a6e992671c Xls Conditional Border
Xls Writer Conditional Border had been creating corrupt spreadsheets. This was mainly because a pack statement that should have specified `V` instead specified `v`. Even changing that, the logic was still slightly wrong on write, and missing altogether on read. This PR corrects the write problems and adds the missing read code. It also adds italic and strikethrough support for Xls Writer Conditional Font italic and strikethrough (read code was already in place). With this, Xls Conditional Writer is completely supported except for NumberFormat. Xls does support that, but I cannot figure out how from the available documentation.
2024-05-21 01:04:07 -07:00
oleibman 2ed696f0a2 Merge pull request #4030 from oleibman/condxls
Xls Conditional Format Improvements
2024-05-19 15:36:44 +00:00
oleibman 623efc0211 Update CHANGELOG.md 2024-05-19 08:33:40 -07:00
oleibman 1a187d689b Merge branch 'master' into condxls 2024-05-19 08:15:10 -07:00
oleibman f2a934ae6d Merge pull request #4027 from oleibman/issue4025
Do Not Output Alignment and Protection for Conditional Formats
2024-05-19 15:07:44 +00:00
oleibman f5c1e8796c Merge pull request #4031 from oleibman/powernullarg
POWER Needs to Accept NULL Args
2024-05-16 23:30:15 +00:00
oleibman 989a44d001 Update CHANGELOG.md 2024-05-16 16:26:53 -07:00
oleibman 26d58b4fde Merge branch 'master' into powernullarg 2024-05-16 14:25:03 -07:00
oleibman 1314f82408 Merge pull request #4029 from SchmidtClaudia/issue4028
Incorrect reader used for CSV files with BOM #4028
2024-05-16 19:00:19 +00:00