Commit Graph

5572 Commits

Author SHA1 Message Date
oleibman ca284fac35 Update Spreadsheet.php 2025-07-04 09:15:02 -07:00
oleibman f52d70984f Update Spreadsheet.php 2025-07-04 07:41:56 -07:00
oleibman 852182039f Update Spreadsheet.php 2025-07-04 07:39:08 -07:00
Denny Septian Panggabean ca12ffd6ef refactor: using function count instead 2025-06-02 11:34:42 +07:00
Denny Septian Panggabean ea6ed77fdd refactor: cleanup code twice calling 2025-06-02 11:26:30 +07:00
oleibman 44c3bd564b Merge pull request #4487 from oleibman/issue1154
Various Writers RichText TextElement Should Inherit Cell Style
2025-06-01 16:29:26 +00:00
oleibman 59387176e3 Update CHANGELOG.md 2025-06-01 09:26:35 -07:00
oleibman 277c8d5615 Merge branch 'master' into issue1154 2025-06-01 09:17:22 -07:00
oleibman 5c643a890b Merge pull request #4491 from oleibman/filterparm
Minor Changes to FILTER Function
2025-06-01 16:04:59 +00:00
oleibman df3a069722 Merge pull request #4493 from oleibman/torow
TOCOL and TOROW
2025-06-01 16:04:23 +00:00
oleibman bd792ec985 Merge pull request #4492 from oleibman/vstack
VSTACK and HSTACK
2025-06-01 16:04:06 +00:00
oleibman 1825c7428b Merge pull request #4498 from oleibman/stan2117
Upgrade Phpstan
2025-06-01 15:58:55 +00:00
oleibman f84724d13e Upgrade Phpstan
Too many problems with Dependabot update.
2025-06-01 08:41:13 -07:00
oleibman 02671e5c4f Merge pull request #4496 from PHPOffice/dependabot/composer/tecnickcom/tcpdf-6.10.0
Bump tecnickcom/tcpdf from 6.9.3 to 6.10.0
2025-06-01 13:37:00 +00:00
oleibman 173dd22c07 Merge pull request #4494 from PHPOffice/dependabot/composer/squizlabs/php_codesniffer-3.13.0
Bump squizlabs/php_codesniffer from 3.12.2 to 3.13.0
2025-06-01 13:36:43 +00:00
dependabot[bot] d7d4a04d27 Bump tecnickcom/tcpdf from 6.9.3 to 6.10.0
Bumps [tecnickcom/tcpdf](https://github.com/tecnickcom/TCPDF) from 6.9.3 to 6.10.0.
- [Changelog](https://github.com/tecnickcom/TCPDF/blob/main/CHANGELOG.TXT)
- [Commits](https://github.com/tecnickcom/TCPDF/compare/6.9.3...6.10.0)

---
updated-dependencies:
- dependency-name: tecnickcom/tcpdf
  dependency-version: 6.10.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-01 11:56:56 +00:00
dependabot[bot] 64bd02a5c5 Bump squizlabs/php_codesniffer from 3.12.2 to 3.13.0
Bumps [squizlabs/php_codesniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) from 3.12.2 to 3.13.0.
- [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.12.2...3.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-01 11:56:49 +00:00
oleibman f3c3aba618 TOCOL and TOROW
TOCOL and TOROW were introduced to Excel in 2024, and will now be supported by PhpSpreadsheet. The documentation says that, under certain circumstances, "blanks" will be ignored. This seems demonstrably wrong. In the right circumstance, Excel will ignore nulls, not blanks. Further, when it decides to not ignore the nulls, it changes them to 0, which also seems insufficiently documented. PhpSpreadsheet will behave as Excel does.

I discovered some minor problems and some missing test conditions for the TRANSPOSE function while testing these. Those are now fixed.
2025-05-28 23:15:06 -07:00
oleibman e83eae9be7 VSTACK and HSTACK
Fix #4485. VSTACK and HSTACK were introduced to Excel in 2024, and will now be supported by PhpSpreadsheet. Special thanks to @SlowFox71, who posted some code to implement VSTACK in the linked issue. I didn't have to change much between that version and the one in this ticket.

Excel has at least one idiosyncrasy with these functions. If you try to stack 2 tables with, say, `=VSTACK(TABLE1, TABLE2)`, Excel will silently change it to `=VSTACK(TABLE1[], TABLE2[])` and all will be well. This would be difficult for PhpSpreadsheet to do. The problem is that, when Excel reads the formula without the square brackets, it calculates it as a `#NAME?` error. This is baffling, and all the more so because you can "correct" it by editing the formula *without changing anything*, hit enter, and the formula will magically work again. So, if you plan to stack tables using PhpSpreadsheet, you're probably best off using the square brackets.
2025-05-27 19:53:30 -07:00
oleibman 347980a3cb Minor Changes to FILTER Function
Its first parameter is typed as `array`. Like all Excel spreadsheet functions, it should be `mixed` to avoid TypeErrors. If an argument other than an array is supplied, Excel will return VALUE, and now PhpSpreadsheet will do so as well. This had not been unit-tested. In fact, all the unit tests take place outside of spreadsheet context. New tests in spreadsheet context are added.
2025-05-26 19:10:09 -07:00
oleibman c00c2dfa59 Merge pull request #4490 from oleibman/changetypos
Changelog Typos
2025-05-26 19:15:25 +00:00
oleibman 19c04712dd Changelog Typos 2025-05-26 12:11:51 -07:00
oleibman d0ac70d610 Merge pull request #4489 from oleibman/issue4488
Regression in Date::stringToExcel
4.3.1
2025-05-26 18:51:08 +00:00
oleibman 1deff50416 Regression in Date::stringToExcel
Fix #4448.
2025-05-26 11:47:16 -07:00
oleibman 494efa4ab7 Move a Statement
No idea why this should help, but no better ideas.
2025-05-25 23:24:07 -07:00
oleibman ba079b3967 Various Writers RichText TextElement Should Inherit Cell Style
Fix #1154, which went stale over 5 years ago, and is now reopened. RichText elements can be a Run, which sets its own style, or a TextElement, which doesn't. As the issue states, TextElement handling is inconsistent. This PR forces it to inherit the style of the cell. As implemented, this will change it to a Run when it is read in, but there should be no practical difference as far as the end-user is concerned. There is no change as far as Run is concerned. The user suggested 3 options - TextElement and Run both inherit for any unspecified style elements, TextElement inherits and Run does not, neither inherits. Option 2 makes most sense to me. Option 1 may not even be possible (we can't tell if, say, the user explicityl set Italic to false, or if that was just the default choice).

Tests are added for all of Xlsx, Xls, and Html. Html reading of RichText elements is not well-supported. The tests are fairly difficult to understand. A new sample is added to demonstrate this change.
2025-05-25 21:22:12 -07:00
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