5744 Commits

Author SHA1 Message Date
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 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 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
oleibman 0a63194f86 Merge pull request #4608 from h-marumoto/fix_typo_in_reading-and-writing-to-file.md
Fix typo in reading-and-writing-to-file.md
2025-08-27 07:22:23 +00:00
h-marumoto 965361b75b Fix typo in reading-and-writing-to-file.md 2025-08-27 15:16:55 +09:00
oleibman b99dc608a0 Merge pull request #4598 from oleibman/issue2912
Better Handling of Print Area After Column/Row Removal
2025-08-26 16:15:58 +00:00
oleibman 87a78e13c5 Update CHANGELOG.md 2025-08-26 09:13:12 -07:00
oleibman ad76caed2d Merge pull request #4581 from oleibman/maxwidth
Maximum Column Width
2025-08-26 16:08:04 +00:00
oleibman c5aa1c8730 Merge branch 'master' into issue2912 2025-08-26 08:28:37 -07:00
oleibman 31502b05d5 Merge branch 'master' into maxwidth 2025-08-26 07:36:50 -07:00
oleibman 3c28bf4552 Merge pull request #4599 from oleibman/coverage
WIP Remove Scrutinizer, Add Coveralls
2025-08-26 14:32:39 +00:00
oleibman d8391bad15 Merge pull request #4601 from oleibman/strinc1
String Incremented Deprecated in 8.5 - First of Many
2025-08-26 01:06:31 +00:00
oleibman b3c81d3b8f String Incremented Deprecated in 8.5 - First of Many 2025-08-25 17:54:30 -07:00
oleibman 8f3477b673 WIP Remove Scrutinizer, Add Coveralls
Scrutinizer has been a source of problems for a long time. False positives, unavailability, not open source, irrelevant complexity flags.

I am a bit concerned because Scrutinizer sometimes seems to run even without a yaml file. We shall see.

I do still want coverage reports. Instead of uploading them to Scrutinizer, I will try Coveralls, which is used by PhpWord.
2025-08-24 19:34:29 -07:00
oleibman 8d3a9598c1 Support Multiple Ranges After All 2025-08-24 10:33:15 -07:00
oleibman 5e02e282c7 Better Handling of Print Area After Column/Row Removal
Fix #2912, another oldie (3+ years). Removal of rows or columns which include part of the print area is not recalculating the print area correctly. This PR will correct that problem, but only if the print area consists of a single range. I think that is by far the most common use case. If there is a demonstrated need to handle multiple ranges, I will respond to a new issue.
2025-08-24 09:05:12 -07:00
oleibman 63d3960f3b Merge pull request #4591 from oleibman/mpdf826
Update Mpdf (Php8.5 compatibility)
2025-08-21 18:30:51 +00:00
oleibman e949acc255 Update Mpdf (Php8.5 compatibility) 2025-08-21 11:21:40 -07:00
oleibman 2933bfd8e7 Merge pull request #4585 from oleibman/promise
Update react/promise (for Php8.5)
2025-08-19 23:40:15 +00:00
oleibman 49ebe5c460 Update react/promise (for Php8.5) 2025-08-19 16:31:21 -07:00
oleibman e31c9246ed Merge pull request #4582 from oleibman/setaccessible
Remove Reflection::setAccessible From Tests
2025-08-18 06:43:32 +00:00
oleibman 029d79c3fc Remove Reflection::setAccessible From Tests
Method has no effect starting with Php 8.1.0, and will be deprecated in 8.5. Remove it from our test suite.
2025-08-17 23:21:17 -07:00
oleibman 06fef872be Maximum Column Width
PR #455 was submitted by @Aketos in 2018. It added no unit tests, so it was not merged, and it eventually went stale. Without the tests, I'm not sure exactly what the user had in mind. But my investigation indicates the following:
- for Xls files, if the column width in the file specifies a value greater than 255, Excel will choose its own width when it opens the file.
- for Xlsx files:
    - Excel does not allow you to set a column width > 255, neither by dragging the column boundary, nor by right-clicking and setting a value, nor by auto-fitting the column width.
    - Nevertheless, if the XML specifies a column width > 255, Excel will honor that value in the displayed spreadsheet, and even write it out if the file is saved.


I have taken a different approach than the original PR, which changed `Worksheet::calculateColumnWidths`. Instead, this PR adds an option to the Xlsx Writer to either restrict column widths to 255 or not. The default is "not" in order to avoid a breaking change. For emulating Excel's behavior, in the unusual situation where it might matter, the user might consider using the non-default option.

This PR also restricts column dimension width to 255 when saving an Xls file.
2025-08-17 20:29:47 -07:00
oleibman 3174773a81 Merge pull request #4580 from oleibman/issue1457
splitRange and ProtectedRange
2025-08-17 04:12:03 +00:00
oleibman ae1b517ff3 Update CHANGELOG.md 2025-08-16 21:09:21 -07:00
oleibman efa0c0fa73 Merge pull request #4577 from oleibman/issue1203
Copy Cell Adjusting Formula
2025-08-17 03:55:42 +00:00
oleibman 08f2f1bfd8 Merge pull request #4579 from oleibman/issue1637
Handle Google-only Formulas Exported from Google Sheets
2025-08-17 03:43:32 +00:00
oleibman fe1220110b Documentation Update 2025-08-16 20:32:08 -07:00
oleibman 653645c50b Merge pull request #4574 from issakujitsuk/icon-set
Add Conditional Formatting with IconSet
2025-08-17 03:01:08 +00:00
oleibman 14a989a7e3 Handle Missing Defined Names Better
The original issue leading to this PR was fixed by correctly treating a token in Calculator as a function rather than a defined name. However, it *should* have worked even when treating it as a defined name. There was a problem because Calculator was raising an exception for a missing defined name rather than returning `#NAME?`. It is now changed to return the error.

That change initially had some adverse affects for functions ROW, ROWS, COLUMN, and COLUMNS. Those are fixed to handle the change correctly. As a bonus, a test for each which had been commented out, because it didn't work, is now uncommented and works correctly. One test for ISFORMULA and one for ISREF were also changed - the old expected result did not reflect Excel's behavior and the new one does.

Sheet title and Defined Name matching used `strtoupper` to achieve case-insensitive compares. This handles only ASCII characters. They are changed to use a conversion routine which handles non-ASCII UTF-8 character sets.
2025-08-12 09:21:26 -07:00
oleibman 05fa51581c splitRange and ProtectedRange
Fix #1457, which had gone stale but is now re-opened. The `Coordinate::splitRange` method expects a string of cell ranges, but it is a bit limited. Excel sometimes uses comma for union and space for intersection, and sometimes vice versa. `splitRange` uses comma for union, and doesn't do anything with spaces. This PR adds a new method `Coordinate::allRanges` which handles both union and intersection, and adds a parameter to indicate whether comma means union or intersection (with space meaning the other). Also, since the issue specifically mentioned this as a problem for `ProtectedRange`, an `allRanges` method is added to that class.
2025-08-10 15:05:51 -07:00
oleibman f51ec365c5 Handle Google-only Formulas Exported from Google Sheets
Fix #1637, which went stale but is now re-opened. When Google Sheets exports a document to Xlsx or Ods, it replaces Google-only formulas with something that Excel or LibreOffice can handle. In the test case accompanying this PR, cell C1 on Google Sheets contains `=flatten(A1:A5,B1:B5)`. On export, C1:C10 (the actual result is a 10*1 array) are changed to `=IFERROR(__xludf.DUMMYFUNCTION("flatten(A1:A5, B1:B5)"),1.0)`, where `1.0` is replaced by the calculated value for each cell in question.

The issue reports an Internal Error when evaluating such a formula. I am unable to duplicate that. However, PhpSpreadsheet evaluates the cell as a `#NAME?` error rather than the correct value (1.0 for cell C1). The reason is that `__xludf.DUMMYFUNCTION` does not match the regexp for formulas, but does match the regexp for defined names. Not finding such a defined name results in the Name error. Altering the formula regexp to recognize `__xludf.` is easy, and solves the problem.
2025-08-10 14:45:05 -07:00
oleibman 1e6668fe58 Copy Cell Adjusting Formula
Fix #1203. The issue actually complains about the documentation, but I think it wants documented functionality that doesn't yet exist. This PR adds a method for copying a formula from one cell to another, adjusting cell references in the formula as Excel would. For a non-formula, it copies the value without making any adjustments.
2025-08-10 13:45:03 -07:00
oleibman d88efcac24 Merge pull request #4576 from oleibman/changelog20250810
Update Changelog for New Release
5.0.0
2025-08-10 06:18:27 +00:00
oleibman 44fe16575c Update Changelog for New Release 2025-08-09 23:12:30 -07:00
issa 782610d02b Add sample for Conditional Formatting with Icon Sets in Xlsx 2025-08-09 23:24:31 +09:00
issa a0f9706855 Add Conditional Formatting tests for IconSet in Xlsx writer 2025-08-09 08:06:19 +09:00
issa a3588b2c22 Add test for unsupported icon sets 2025-08-09 07:23:18 +09:00
oleibman 886a8c35c1 Merge pull request #4575 from oleibman/issue1324
Additional Floating Point Precision Changes
2025-08-08 03:35:45 +00:00