Commit Graph

5780 Commits

Author SHA1 Message Date
oleibman 31d1cd7e17 Minor Tweaks 2025-09-14 01:20:24 -07:00
oleibman 9df8ceb5c0 Minor Improvements to Reader/Writer Coverage 2025-09-14 00:18:08 -07:00
oleibman 996de17311 Merge pull request #4640 from oleibman/lessprecise
Option To Display Numbers With Less Precision
2025-09-13 14:59:05 +00:00
oleibman f8fc6b5ea9 Update CHANGELOG.md 2025-09-13 07:56:18 -07:00
oleibman 38cf7ed656 Merge branch 'master' into lessprecise 2025-09-13 07:36:24 -07:00
oleibman 5179fff699 Merge pull request #4639 from oleibman/wakeup
Deprecate Worksheet::getHashInt and Spreadsheet::getId
2025-09-12 05:07:18 +00:00
oleibman 77eaac2e79 Merge branch 'master' into wakeup 2025-09-11 21:21:49 -07:00
oleibman c07675a59c Merge pull request #4641 from oleibman/issue4638
Proper Output for BASE Function
2025-09-12 03:29:16 +00:00
oleibman dc11b8cccd Update CHANGELOG.md 2025-09-11 20:26:30 -07:00
oleibman 9b28b9e9c1 Merge pull request #4644 from oleibman/phpstan2123
Upgrade Phpstan
2025-09-12 03:08:23 +00:00
oleibman 4b8f4e8d66 Upgrade Phpstan
A lot of changes since its last update, including one that I requested.
2025-09-11 20:02:57 -07:00
oleibman e49d7a9d94 Small Improvement 2025-09-10 10:16:28 -07:00
oleibman 43754a130e Bug in Uncovered Code in XMLWriter
Add test, fix bug.
2025-09-10 08:19:57 -07:00
oleibman f19a73fdd6 Proper Output for BASE Function
Fix #4638. Microsoft does not document BASE as being introduced in Excel 2010 or later, but apparently it was.
2025-09-10 07:34:50 -07:00
oleibman 6b505d2d83 Coverage Tweak 2025-09-10 07:23:28 -07:00
oleibman ebdbdd41ba Option To Display Numbers With Less Precision
Fix #4626. Previous changes had increased the precision of floating point numbers when cast to string, making for greater accuracy after save and load operations, without affecting the values displayed by Excel. Although the results of the cast are now more accurate computationally, they can appear unexpected to humans. A new boolean parameter `lessFloatPrecision` (defaulting to false) is added to `StringHelper::convertToString`, to `NumberFormat::toFormattedString` and `NumberFormat\Formatter::toFormattedString`, and to the entire `Worksheet::toArray` family of functions. When the new parameter is set to true, the result can be less surprising to humans. It should not, however, be used in subsequent computations.

In the case of the NumberFormat functions, the new parameter will be considered only when the NumberFormat for the cell in question is `General` or equivalent. Setting an actual numeric format for the cell is probably a better solution than using the new parameter.
2025-09-10 00:32:26 -07:00
oleibman 00191100ba Deprecate Worksheet::getHashInt and Spreadsheet::getId
Php8.5 *may* deprecate the use of `__wakeup` (it is planned, but not yet implemented, and it is convtroversial). We use it only twice. In the first instance, it just throws an exception to prevent a security exploit. This can be trivially replaced with `__unserialize`.

The other instance is merely to initialize a Worksheet instance variable. Converting this use to `__unserialize` is *not* trivial (one of the reasons for the controversy). However, I see no useful purpose for that variable. Since it has no use, there is no real need for `__wakeup`, so we will just remove the routine altogether, and deprecate the variable's getter (there is no setter).

A similar instance variable in Spreadsheet also serves no useful purpose, so we will deprecate its getter as well (again no setter).
2025-09-10 00:27:22 -07:00
oleibman 109b2b282b Merge pull request #4633 from oleibman/issue4629
Conditional Formatting in extLst
2025-09-07 07:40:06 +00:00
oleibman 3ace47ad4d Merge branch 'master' into issue4629 2025-09-07 00:37:14 -07:00
oleibman 3b674b6653 Update CHANGELOG.md 2025-09-07 00:36:09 -07:00
oleibman 84f259b1fc Merge pull request #4624 from oleibman/calccov
Minor Improvements to Calculation Coverage
2025-09-07 07:28:13 +00:00
oleibman da9a414df3 Merge branch 'master' into calccov 2025-09-07 00:04:02 -07:00
oleibman 66ea4056d2 Merge pull request #4609 from Fuzuki785/fix/4607
Performance improvement when working with large amounts of cells
2025-09-07 06:52:12 +00:00
oleibman 889d26a51e Merge pull request #4634 from oleibman/pruner
Php8.5 Deprecates Use of Null as Array Index
2025-09-05 22:34:23 +00:00
oleibman a0dd42681c Update CHANGELOG.md 2025-09-05 15:31:29 -07:00
oleibman 740b54d307 Php8.5 Deprecates Use of Null as Array Index 2025-09-05 15:25:31 -07:00
oleibman 5082b35709 Conditional Formatting in extLst
Fix #4629. Excel Xml can specify Conditional Formatting in 2 ways - either using a `conditionalFormatting` tag as a child of `worksheet`, or in a slightly different manner as a child of `worksheet->extLst`. Although these are both handled by PhpSpreadsheet, the former is lost if there exists a latter whose cell range (`sqref`) matches it. This PR merges the former with the latter in that circumstance, preserving both.

The issue also notes that `font` and `stopIfTrue` are not handled correctly. Support for those was missing in the `extlst` handling, and is now added with this PR.
2025-09-05 11:13:09 -07:00
oleibman b7d48e687d More Minor Tweaks 2025-09-05 10:28:48 -07:00
oleibman eec235765c Merge branch 'master' into calccov 2025-09-05 00:46:28 -07:00
oleibman 2059d3b241 A Tiny Amount of Coverage 2025-09-04 23:43:40 -07:00
oleibman fd26e45a81 Merge pull request #4630 from oleibman/updatechglog
Prepare Change Log For New Release
5.1.0
2025-09-04 05:34:49 +00:00
oleibman f0f0a330b8 Merge branch 'master' into updatechglog 2025-09-03 22:31:59 -07:00
oleibman fca1a6e803 Prepare Change Log For New Release 2025-09-03 22:12:13 -07:00
oleibman a88993dcc8 More Accurate Handling of Countries in validLocaleLanguages
This is a theoretical problem. Building FalseTrueArray only looks at languages, not countries. The only example we have is `pt` vs `pt_br`, and since True and False have the same translation for both locales, there is no problem. This PR will help it from becoming a problem in future if a new language/country combo is added.
2025-09-01 18:37:48 -07:00
oleibman fb51c3d964 Merge pull request #4625 from TobiasBg/patch-1
PHP 8.5: Prevent deprecation notices for imagedestroy
2025-09-01 18:21:23 +00:00
oleibman 4f5254606a Update MemoryDrawing.php 2025-09-01 10:59:04 -07:00
Tobias Bäthge 9baabd2a0b PHP 8.5: Prevent deprecation notices for imagedestroy
`imagedestroy` is deprecated in PHP 8.5+, and hasn't been doing anything since PHP 8.0.

To prevent deprecation warnings it should therefore be called on older versions of PHP only.

See https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_no-op_functions_from_the_resource_to_object_conversion.
2025-09-01 16:50:53 +02:00
oleibman 2803d96129 Cover Important Path in StringHelper 2025-09-01 07:45:27 -07:00
oleibman 3dfd3afff8 One More Test 2025-09-01 01:03:23 -07:00
oleibman f375d9a69b Minor Improvements to Calculation Coverage 2025-09-01 00:28:46 -07:00
oleibman ff7195c274 Merge pull request #4618 from oleibman/blanksheet
Option to Create Blank Sheet If LoadSheetsOnly Doesn't Find Any
2025-09-01 06:45:12 +00:00
oleibman 187cac7894 Update CHANGELOG.md 2025-08-31 23:42:32 -07:00
oleibman 8da69e5d6c Merge pull request #4620 from SpikedCola/Fix-Newline-Corruption
Fix "Excel2007 found unreadable content" when saving a file that contains a newline
2025-09-01 06:35:21 +00:00
SpikedCola b9a9312e2d fix: remove 0x09, 0x0a, 0x0d characters from list of control characters.
this fixes an issue where excel complains about "unreadable content" if a cell contains a "\n". these characters were originally excluded from the list, but were added by mistake in commit 250394d.
2025-08-29 22:52:38 -04:00
oleibman 53d926d569 Additional Tests 2025-08-29 01:00:06 -07:00
oleibman 2fd3ac5552 Option to Create Blank Sheet If LoadSheetsOnly Doesn't Find Any
In PhpSpreadsheet Release 1, if the LoadSheetsOnly option was specified, and no sheets matched, a new blank sheet was created. This behavior changed in PhpSpreadsheet Release 2, so that an exception wound up being thrown instead. Although the Release 2 approach seems more sensible to me, it was actually collateral damage from a different change, and was not an intentional result.

The difference in behavior is causing a problem for Laravel-Excel. In particular, a PR which would move their supported PhpSpreadsheet release from 1 to 5, is delayed because this change in behavior breaks part of their test suite. See https://github.com/SpartnerNL/Laravel-Excel/pull/4302. We would very much like them to get off release 1. I volunteered to add a compatibility option to the Readers which would emulate the release 1 behavior. The result is this PR.

Usage:
```php
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setLoadSheetsOnly([list of sheet names]);
if (method_exists($reader, 'setCreateBlankSheetIfNoneRead')) {
    $reader->setCreateBlankSheetIfNoneRead(true);
}
```
In addition to Xlsx Reader, the method is available for Xls, Ods, Xml, and Gnumeric.
2025-08-28 13:44:32 -07:00
oleibman b79b77cf0f Merge pull request #4611 from oleibman/strinc2
String Increments and Php8.5
2025-08-28 01:25:25 +00:00
oleibman f8f78a7ed3 String Increments and Php8.5
Fix #4600. String incrementation through the `++` operator is deprecated in Php 8.5. Because we make use of that operator to iterate through columns, we are particularly hard hit by that change - unaddressed, it causes over 2,000 errors in our test suite! It is, fortunately, not as difficult as I feared to correct. Replacing the `++` operator with a call to new method `StringHelper::stringIncrement` in 79 statements scattered over 31 source modules (in src, samples, test, and infra) eliminates all the messages in the test suite. It is possible that others are lurking, but I don't know a systematic way of determining if there are others. We'll stick with this for now, and deal with any others as they show up.

This PR will be applied to the master, release390, and release222 branches. It will not be applied to the release210 or release1291 branches, which will now accept security changes only.
2025-08-27 18:18:40 -07:00
Fuzuki 5474bd7063 Fix cells cache not being reset when sorting the index 2025-08-27 17:48:17 +02:00
Fuzuki 7850daa868 Improve performance when working with large amounts of cells 2025-08-27 17:09:03 +02:00