Commit Graph

5704 Commits

Author SHA1 Message Date
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 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 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 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
oleibman 0c8db6e7d2 Merge branch 'master' into issue1324 2025-08-07 20:33:00 -07:00
oleibman d1db7845cc Update CHANGELOG.md 2025-08-07 20:30:24 -07:00
oleibman 8d8bc23b6d Merge pull request #4572 from oleibman/issue484
Header/Footer Images Expand "Location"
2025-08-07 05:29:16 +00:00
oleibman a4ee68bf1e Merge branch 'master' into issue484 2025-08-06 22:26:24 -07:00
oleibman 3c67aba359 Update CHANGELOG.md 2025-08-06 22:24:24 -07:00
oleibman 216db02ad5 Merge pull request #4565 from oleibman/issue4588
Create Uninitialized Cell If Used in Calculation
2025-08-07 05:00:06 +00:00
oleibman fa2c32996a Merge branch 'master' into issue4588 2025-08-06 21:57:24 -07:00
oleibman 4b9a3cdef8 Update CHANGELOG.md 2025-08-06 21:54:11 -07:00
oleibman 7689037b60 Additional Floating Point Precision Changes
Fix #1324, which went stale many years ago, and is now re-opened. It can be considered a follow-on to PR #4479 which was installed in May. The user complains of a *very* small loss of precision. This can be corrected by using `StringHelper::convertToString` in lieu of a simple cast from float to string in two places. `Style\NumberFormat\Formatter` is quite straightforward. `Writer\Csv` is a bit more complicated. If you put a float with more than 15 digits precision in a Csv, on opening it Excel will give a pop-up, saying something inaccurate like "We've corrected this for you - is that okay?" Better to avoid that by making sure to avoid too much precision when writing to Csv.
2025-08-06 17:53:04 -07:00
issa 0327b49060 Added Conditional Formatting: IconSet for Xlsx (#4560) 2025-08-07 08:59:11 +09:00
oleibman ea97afb754 Merge pull request #4562 from oleibman/issue4557date
Shared/Date::isDateTime Handle Cells Which Calculate as Arrays
2025-08-06 07:16:44 +00:00
oleibman c4cd1b3410 Merge branch 'master' into issue4557date 2025-08-05 23:52:31 -07:00
oleibman 9a805fd7b2 Update CHANGELOG.md 2025-08-05 23:51:04 -07:00
oleibman a907f19462 Merge pull request #4573 from PHPOffice/dependabot/composer/setasign/fpdi-2.6.4
Bump setasign/fpdi from 2.6.3 to 2.6.4
2025-08-05 23:44:36 +00:00
dependabot[bot] 02b12603b7 Bump setasign/fpdi from 2.6.3 to 2.6.4
Bumps [setasign/fpdi](https://github.com/Setasign/FPDI) from 2.6.3 to 2.6.4.
- [Release notes](https://github.com/Setasign/FPDI/releases)
- [Commits](https://github.com/Setasign/FPDI/compare/v2.6.3...v2.6.4)

---
updated-dependencies:
- dependency-name: setasign/fpdi
  dependency-version: 2.6.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-05 21:26:16 +00:00
oleibman 9c083e271d Header/Footer Images Expand "Location"
Fix #484. Fix #1318. Both went stale a long time ago. The images can currently specify their location as Left, Center, or Right. However, they also need to specify their type - first page, even pages, or odd pages (which is what is used when neither of the others is applicable). This is accomplished by adding 18 new constants to `Worksheet\HeaderFooter`, any of which can be specified as the second argument to `HeaderFooter::addImage`. Somewhat surprisingly, no changes are required to Xlsx Writer or Reader.

Xls Reader and Writer support header/footer, but do not support using images in them. No other readers nor writers support header/footer.
2025-08-04 18:15:19 -07:00
oleibman 9a193f2841 Merge pull request #4571 from oleibman/calcformulatests
Clean Up Some Engineering Tests
2025-08-03 23:34:51 +00:00
oleibman 79fca7601c Clean Up Some Engineering Tests
This came to light while cleaning up ComplexAssert. Many tests are calling `_calculateFormulaValue` rather than `calculateFormula`, and, as a result, have to be trimmed before asserting. This PR changes those calls, and does a bit more to simplify the tests. There are a lot of other non-Engineering tests which call `_calculateFormulaValue`, but none of those need to manipulate the result after the test.

This PR changes only tests, no source code.
2025-08-03 13:48:45 -07:00
oleibman f65b0a2d10 Merge pull request #4570 from oleibman/complextests
Redo ComplexAssert
2025-08-03 15:56:42 +00:00
oleibman e78bca9668 Merge pull request #4556 from oleibman/xmlspace
Xlsx Writer Eliminate xml:space From Non-Text Nodes
2025-08-03 15:46:51 +00:00
oleibman c32605828b Update CHANGELOG.md 2025-08-03 08:44:08 -07:00
oleibman 3dcdbcac3e Redo ComplexAssert
Its use is already causes an issue with Phpstan. It uses interfaces marked as internal by Phpunit, and it will not work with Phpunit 12. It is more complicated than needed. This PR corrects all these problems. It also corrects a handful of other problems that will show up with Phpunit 12. Only tests are changed - no source code.
2025-08-03 08:25:05 -07:00
oleibman 8f7a401f74 Merge pull request #4569 from oleibman/stanfixer
Upgrade Phpstan and php-cs-fixer
2025-08-03 04:07:14 +00:00
oleibman eb53b55157 Upgrade Phpstan and php-cs-fixer 2025-08-02 20:29:32 -07:00
oleibman b726eb3f1c Merge pull request #4554 from oleibman/deprecations
Eliminate Deprecated Constants
2025-08-03 02:10:41 +00:00
oleibman 6d8fc67512 Merge branch 'master' into deprecations 2025-08-02 19:07:45 -07:00
oleibman 7e89ad9e08 Merge pull request #4551 from oleibman/base2html
Minor Breaking Change - Move Some BaseWriter Properties
2025-08-03 01:49:48 +00:00
oleibman 20ac2f1940 Merge pull request #4527 from oleibman/issue4522
Minor Breaking Change to DefaultValueBinder
2025-08-03 01:48:03 +00:00
oleibman ac4befd2f7 Merge commit from fork 2025-08-02 18:06:29 -07:00
oleibman 150b3849a8 Create Uninitialized Cell If Used in Calculation
Fix #4558. Fix #4530. 4558 deals with a problem with COUNTA. Excel does not count empty cells, but it does count literal nulls (usually empty parameters) in the argument list. PhpSpreadsheet has till now not created empty cells during calculation, and so winds up treating them as literals. It is changed to create the cell when appropriate.

4530 has a similar problem. When INDIRECT winds up evaluating an uninitialized cell, it treats it as a null literal, leading to incorrect results. It is now changed to create the missing cell.

A number of functions, almost all of them Financial, have a related problem. They test for a null literal when initializing some of their parameters, but they should be testing for null literal or cell containing null. They are changed to do the right thing.

SUMIF and related functions are slightly affected by this change, and are changed so that they are no longer affected.

New tests have been added. Only one existing test had to change. MergeBehaviorTest for `[12, '=5+1', '=A1/A2']`, where cell A2 was uninitialized formerly returned one row, but now returns a second all-null row because A2, by virtue of being used in a calculation, now winds up defined. I do not consider this a significant difference.
2025-07-31 23:58:05 -07:00
oleibman 079dc87604 More Tweaks 2025-07-30 23:27:08 -07:00
oleibman 624dafa3b8 Merge branch 'master' into deprecations 2025-07-30 21:33:35 -07:00
oleibman c16eaeb6e4 Coverage Tweaks
See if we can satisfy Scrutinizer.
2025-07-30 20:55:02 -07:00
oleibman f1ce95eaa4 Shared/Date::isDateTime Handle Cells Which Calculate as Arrays
In issue #4557, the user complains, with some justification, about the way Excel handles certain calculations. We are not able to help with that problem. However, the user also notes a problem in Shared/Date when `isDateTime` has to evaluate a cell whose calculated value is an array. This is solved by flattening the calculated result to a single value.

It became obvious while working on this change that the code to set `instanceArrayReturnType` was kind of awkward. Simpler methods `returnArrayAsArray` and `returnArrayAsValue` are added to `Spreadsheet`. Even these started out a bit awkward because `Spreadsheet::calculationEngine` was defined as nullable, which really isn't true. It is allocated by the constructor, and never freed except in the destructor. It is no longer nullable.
2025-07-30 17:19:26 -07:00
oleibman 95b4e32da2 Merge pull request #4561 from oleibman/docnoprivate
Remove Private Methods/Properties From Online Doc
2025-07-31 00:09:03 +00:00
oleibman bc6c09c8da Remove Private Methods/Properties From Online Doc
Documenting public and protected methods is useful; I don't believe it is useful to document private methods. If people really need them, they can clone the project and run PhpDocumentor against it.

As long as I'm at it, we are several releases behind in PhpDocumentor. Use the latest (3.8.1 replacing 3.5.0). I have confirmed that this works locally on my machine. There's no real way to verify the change until the next PhpSpreadsheet release. Hope it works.
2025-07-30 17:02:06 -07:00
oleibman 69b65d4e2a Xlsx Writer Eliminate xml:space From Non-Text Nodes
Fix #4542. PhpSpreadsheet has been writing attribute `xml:space="preserve"` to the `table` tag when writing a Table. According to the issue, Excel 2016 is treating the resulting file as corrupt. I do not have access to a version of Excel 2016 to confirm. This seems to be a bug with that release. Nevertheless, the OOXML spec, with over 100 references to `xml:space` does not indicate that it is a permitted attribute for `table`. It should only be specified for text nodes. This PR eliminates the undocumented, and unneeded, usage.

Investigating further, PhpSpreadsheet also writes this attribute for `workbook`, `styleSheet`, and `worksheet` tags. It is again undocumented and unneeded in those cases. Although all Excel releases, including 2016, apparently tolerate such usage, this PR also eliminates those.

Finally, there is one case where PhpSpreadsheet omits this tag when it is needed. When writing a cell whose data type is an inline string, and the string contains leading or trailing whitespace, the text tag needs to specify `xml:space`, and is now changed to do so.
2025-07-26 00:08:33 -07:00
oleibman 0b75730cc9 Merge pull request #4555 from oleibman/breakdoc
Changelog Update Semantic Versioning Statement
2025-07-26 05:23:52 +00:00
oleibman ce399b4bc7 Changelog Update Semantic Versioning Statement 2025-07-25 22:16:55 -07:00
oleibman a12a0d0271 Eliminate Deprecated Constants
In Theme, change COLOR_SCHEME_2013_PLUS_NAME to private (use COLOR_SCHEME_2013_2022_NAME instead), and delete COLOR_SCHEME_2013_PLUS (use COLOR_SCHEME_2013_2022).
2025-07-24 01:27:56 -07:00