5546 Commits

Author SHA1 Message Date
oleibman 13537148b1 Merge pull request #4486 from oleibman/changelog430
Prepare Changelog for 4.3.0
4.3.0
2025-05-26 03:42:48 +00:00
oleibman 9f40b9cfd0 Prepare Changelog for 4.3.0 2025-05-25 20:38:31 -07:00
oleibman 0552814d75 Merge pull request #4482 from oleibman/stan1009
Phpstan Level 10 (Final)
2025-05-26 03:25:00 +00:00
oleibman 68fd7119f3 Merge pull request #4479 from oleibman/issue4476
More Precision for Float to String Casts
2025-05-26 03:18:55 +00:00
oleibman 9da522f721 Merge pull request #4484 from oleibman/issue1247
Document That Precision As Displayed Is Not Supported
2025-05-25 07:28:12 +00:00
oleibman aab714ce11 Document That Precision As Displayed Is Not Supported
Fix #1247. Aside from being difficult to implement, see, for example, https://answers.microsoft.com/en-us/msoffice/forum/all/what-are-the-dangers-of-using-precision-as/1a2ba5eb-9470-452f-816e-d7961c0d0ad5
2025-05-25 00:14:51 -07:00
oleibman 170010076b Merge branch 'master' into issue4476 2025-05-24 22:30:13 -07:00
oleibman dbca68c1ab Additional Test 2025-05-24 22:28:35 -07:00
oleibman 3bb10ff88d Merge pull request #4478 from oleibman/hyperlinkstyle
Hyperlink Styles
2025-05-25 04:14:49 +00:00
oleibman 99f0e6a4e6 Merge branch 'master' into hyperlinkstyle 2025-05-24 21:12:00 -07:00
oleibman 31b4cadda9 Update CHANGELOG.md 2025-05-24 21:09:15 -07:00
oleibman 20df5edad7 Update recipes.md 2025-05-24 20:45:31 -07:00
oleibman e65bc8b8e2 Merge pull request #4483 from oleibman/compactlist
Compact Function List by Name Document
2025-05-25 03:19:27 +00:00
oleibman fcb5efc466 Merge pull request #4480 from oleibman/issue4477
Xlsx Reader Do Not Process Printer Settings for Dataonly
2025-05-23 19:06:51 +00:00
oleibman 0cbaf103d3 Update CHANGELOG.md 2025-05-23 11:43:47 -07:00
oleibman 365f9f1995 Compact Function List by Name Document
The entries in the "function list by name" document are very long, and almost all of them require horizontal scrolling, which is not very convenient for the end-user. This PR creates a "function list by name compact" document, in which `CATEGORY_` is stripped from all the category names and `PhpOffice\PhpSpreadsheet\Calculation\` is stripped from all the functions. I believe this eliminates the need to scroll horizontally within the document. I waffled on whether this should replace the existing document, or whether it should be an additional document. I decided there was probably some merit in keeping the old, and hardly any down-side, so, at least for now, we will generate both documents, and they will link to each other.

No changes to source code.
2025-05-23 08:32:52 -07:00
oleibman 5a9055ca6a Phpstan Level 10 (Final)
Fix all of Statistical. We can now use Level 10 going forward.
2025-05-22 17:48:30 -07:00
oleibman 6b2767ce1d Merge pull request #4475 from oleibman/stan1008
Phpstan Level 10 Prep Penultimate
2025-05-22 19:18:46 +00:00
oleibman 12e74f4008 Ignore Theme When Tint is Also Specified
Theme colors subject to tints occur in the wild, and should not be targeted by this PR. Our use case is an unmodified Theme color. There is probably a decent case to be made for adding a Tint property to Color, but that can come later if desired.

`Color::setHyperlinkTheme` will now try to fill in `rgb` as well as `theme` if it can locate an appropriate value in the Spreadsheet Theme. This will permit non-Xlsx formats to at least duplicate the color that Xlsx uses for hyperlinks.

Setting `Color::rgb\argb` will reset `theme` to none. If you want to use both, do rgb first, then theme. This will, I hope, avoid surpises for end-users.
2025-05-21 23:00:45 -07:00
oleibman cadeb88d4b Xlsx Reader Do Not Process Printer Settings for Dataonly
Fix #4477. Xlsx Spreadsheet could be loaded and saved normally, but, when the load specified Dataonly, the output file was corrupt. Reader is changed to not process Printer Settings when Dataonly is in effect.
2025-05-21 19:15:20 -07:00
oleibman 4521864199 Document New Feature 2025-05-21 00:04:29 -07:00
oleibman ef81f19996 More Precision for Float to String Casts
Fix #3899. Supersedes PR #4476, which will be changed to draft status and closed if this PR is merged.

A standard cast from float to string in PHP can drop trailing decimal positions. This can lead to problems above and beyond the usual problems associated with floating point. See the superseded PR for a more complete explanation.

`StringHelper::convertToString` is changed for how it handles floats. It will now do separate casts for the whole and decimal parts, and then combine the results. This affects `Cell::getValueString` and `Cell::getCalculatedValueString`. Xlsx Writer will now invoke `convertToString` before writing  a float to Xml. Ods Writer already uses `getValueString`, so no change is needed there. Xls Writer writes its float values in binary, so no change is needed there. Tests are added for all 3 writers.

Aside from fixing some problems, it might appear that this change introduces some new problems. For instance, setting a cell to `12345.6789` will now result in `12345.67890000000079` in the Xml. This difference is an illusion, merely a consequence of floating point rounding. If you run the following check under PhpUnit, it will pass:
```php
self::assertSame(12345.6789, 12345.67890000000079);
```
2025-05-20 23:35:50 -07:00
oleibman 76ab794557 Scrutinizer Identified Some Dead Code
Eliminate it.
2025-05-20 23:17:26 -07:00
oleibman c35cc943e8 Hyperlink Styles
Fix #1632. Excel automatically supplies a style for cells which contain hyperlinks (e.g. underlined, and blue text changing to purple after the link has been followed). PhpSpreadsheet cannot handle the style automatically. The user can, with some effort, specify a style for the cell which mimics Excel's choice (except for the color change after following).

Examining a sheet with a hyperlink created through Excel, it appears that Excel creates 3 different entries in styles.xml, one for cellStyleXfs, one for cellXfs, and one for cellStyles. It is difficult for me to figure out how they interrelate. This is especially so since PhpSpreadsheet outputs only 1 entry (for the default style) for each of cellStyles and cellStyleXfs. However, it appears that only the cellXfs entry is required, and, when it specifies a font whose color specifies `theme="10"` rather than an rgb value, the style works as expected.

In order to implement this, it is necessary to add a `theme` property, with setter and getter, to Style/Color. There are 12 possible values for theme, 0-11 representing 0=dk1 1=lt1 2=dk2 3=lt2 4-9=accent1-6 10=hlink 11=folHlink. This PR is mainly to allow the use of hlink, but the others are also usable if a use case arises for them. If a theme is set for Color, Xlsx Writer will use the theme rather than rgb when generating the color xml. Other writers will continue to use rgb rather than theme, so there is a use case for setting both if you want to generate both Xlsx and some other format.

The `theme` property will, for now, be ignored except for Font. There is probably a case to be made for using it for Fill, and maybe for Border and other areas that I haven't yet considered. I will wait for someone to make that case before adding those.

In order to make it as easy as possible to use this, a method `setHyperlinkTheme` is added to both Style/Color and Style/Font. The one in Color sets `theme` to the appropriate value. The one in Font calls the one in Color, and also sets `underline` on (this will be honored by other writers in addition to Xlsx).

Samples which use hyperlinks are updated to use `setHyperlinkTheme`. So is `Reader\Xlsx\HyperlinkTest`, with appropriate tests added.
2025-05-20 22:54:08 -07:00
oleibman 645d9fea64 Phpstan Level 10 Prep Penultimate
Everything except Statistical.
2025-05-18 18:04:25 -07:00
oleibman 85a9a39b91 Merge pull request #4468 from oleibman/issue1425
Copy Styles after insertNewColumnBefore
2025-05-18 19:46:24 +00:00
oleibman a6e2e71791 Merge branch 'master' into issue1425 2025-05-18 12:43:54 -07:00
oleibman 45fe36e6d8 Update CHANGELOG.md 2025-05-18 12:40:11 -07:00
oleibman e16571ea1a Merge pull request #4469 from oleibman/stan1007
Still More Prep for Phpstan 10
2025-05-18 19:25:39 +00:00
oleibman 770eddf69d Still More Prep for Phpstan 10
Remaining:
- Calculation/LookupRef
- Calculation/Statistical
- Shared/OLE
- Odds and ends
2025-05-15 08:19:39 -07:00
oleibman 0e570a50cd Merge pull request #4467 from oleibman/stan1006
More prep for Phpstan 10
2025-05-15 01:31:13 +00:00
oleibman e6aacf72b0 Merge pull request #4466 from oleibman/issue407b
Ods Handling of Ceiling and Floor
2025-05-15 01:22:53 +00:00
oleibman 48ed1bca3e Update CHANGELOG.md 2025-05-14 18:20:14 -07:00
oleibman 2d1f4e87d6 Merge pull request #4465 from oleibman/issue282
Removing Columns/Rows Containing Merged Cells
2025-05-15 01:17:36 +00:00
oleibman 37f7c0d366 Update CHANGELOG.md 2025-05-14 18:15:05 -07:00
oleibman 6a7c834f22 Copy Styles after insertNewColumnBefore
Fix #1425 which went stale 5 years ago, and which I've reopened. Style was not being set properly for last row. Also, Style was not being set at all for insertNewColumnBefore('B').
2025-05-14 16:56:01 -07:00
oleibman 6786cd5f25 Something More Sophisticated
When the merged cells start outside the deleted range but end inside it, the merge is truncated to that portion which is outside the range.
2025-05-13 21:54:27 -07:00
oleibman 7db6e1f491 More prep for Phpstan 10 2025-05-12 22:59:34 -07:00
oleibman 01e97405f8 Tweaks for Gnumeric and Xls 2025-05-12 11:05:39 -07:00
oleibman 3e93d4d85c Merge pull request #4463 from oleibman/stan1005
More Phpstan 10 Prep
2025-05-11 22:32:16 +00:00
oleibman 3a6009d49e Recalibrate for Significance=0
Very peculiar implementation in Excel. PhpSpreadsheet will match it:
- FLOOR(8,0) is #DIV/0. This already matched, and is the only result I understand.
- CEILING(8,0) is 0 (already matched)
- FLOOR.MATH(8,0) is 0 (changed to match)
- FLOOR.PRECISE(8,0) is 0 (changed to match)
- CEILING.MATH(8,0) is 0 (already matched)
- CEILING.PRECISE(8,0) is 0 (already matched)
2025-05-11 00:27:34 -07:00
oleibman 39511e03b5 Ods Handling of Ceiling and Floor
Fix #407, which went stale over 7 years ago, and is now reopened. Ods handling of CEILING and FLOOR functions is, apparently by design, subject to interoperability problems with Excel. See [FLOOR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/FLOOR) and [CEILING](https://wiki.documentfoundation.org/Documentation/Calc_Functions/CEILING). Ods implements its own `CEILING.XCL` and `FLOOR.XCL` functions for interoperability purposes. PhpSpreadsheet will implement those, and `CEILING.ODS` and `FLOOR.ODS` psuedo-functions as well; none of these four will be listed in the official Functions documentation.

In all of the descriptions below, FLOOR follows CEILING exactly.

Ods writes its functions to Xml as follows:
- CEILING.XCL becomes COM.MICROSOFT.CEILING
- CEILING.MATH becomes COM.MICROSOFT.CEILING.MATH
- CEILING.PRECISE becomes COM.MICROSOFT.CEILING.PRECISE
- CEILING remains unchanged

PhpSpreadsheet Ods Writer will do the same, plus:
- CEILING.ODS becomes CEILING

PhpSpreadsheet Ods Reader will act as follows:
- CEILING (not preceded by 'COM.MICROSOFT.') becomes CEILING.ODS
- COM.MICROSOFT.CEILING.MATH becomes CEILING.MATH
- COM.MICROSOFT.CEILING.PRECISE becomes CEILING.PRECISE
- COM.MICROSOFT.CEILING becomes CEILING

PhpSpreadsheet Xlsx Writer will act as follows:
- CEILING.ODS becomes CEILING.MATH
- CEILING.XCL becomes CEILING

PhpSpreadsheet Xls Writer will recognize only the CEILING and FLOOR functions.

Note that the only difference between Ods CEILING and CEILING.MATH is that CEILING will return an error if the number and significance operands have opposite signs. PhpSpreadsheet implements this as `#VALUE!`.
2025-05-10 21:40:28 -07:00
oleibman bc54cfd199 Update MergeCellsDeletedTest.php 2025-05-09 21:10:55 -07:00
oleibman 0245f6ba22 Removing Columns/Rows Containing Merged Cells
Fix #282, which went stale over 7 years ago, and is now reopened. This is certainly related to issue #4379. If merged cells are in the midst of deleted rows/columns, the merge may continue to exist after the deletion, leading to various problems including spreadsheet corruption. The problem is not with either Reader or Writer.

This PR will automatically unmerge all merged cells whose first cell is in the delete range before performing the deletion. This will address the corruption problem. Something more sophisticated may be required, so I won't merge this PR for a while to give me a chance to think about it some more.
2025-05-09 20:58:06 -07:00
oleibman e53a04b016 Start Calculation Changes 2025-05-08 22:44:13 -07:00
oleibman 130c6e99d2 More Phpstan 10 Prep
All of Calculation and Shared/OLE are left to tackle.
2025-05-07 23:57:33 -07:00
oleibman 89343c81f5 Merge pull request #4462 from oleibman/issue2735
Minor Documentation Update
2025-05-08 00:10:21 +00:00
oleibman 773585ad19 Minor Documentation Update
Fix #2735.
2025-05-07 17:05:30 -07:00
oleibman 3922d9ad00 Merge pull request #4453 from oleibman/issue56
Xls Writer Treat Hyperlink Starting with # as Internal
2025-05-07 03:02:50 +00:00
oleibman 8be18d1a49 Update CHANGELOG.md 2025-05-06 20:00:22 -07:00