Commit Graph

5527 Commits

Author SHA1 Message Date
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 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 4521864199 Document New Feature 2025-05-21 00:04:29 -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 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
oleibman 576ce504f9 Merge branch 'master' into issue56 2025-05-06 19:51:00 -07:00
oleibman f9b1b76322 Merge pull request #4459 from oleibman/stan1004
More Phpstan Level 10 Prep - Readers and Styles
2025-05-07 02:43:16 +00:00
oleibman 3977e2ace7 Add Style 2025-05-05 09:19:24 -07:00
oleibman 5c94de34a9 More Phpstan Level 10 Prep - Readers
Also upgrade Phpstan.
2025-05-03 21:18:55 -07:00
oleibman c2a9649782 Merge pull request #4457 from PHPOffice/dependabot/composer/squizlabs/php_codesniffer-3.12.2
Bump squizlabs/php_codesniffer from 3.12.0 to 3.12.2
2025-05-01 15:04:24 +00:00
oleibman b504baf196 Merge pull request #4458 from PHPOffice/dependabot/composer/tecnickcom/tcpdf-6.9.3
Bump tecnickcom/tcpdf from 6.9.0 to 6.9.3
2025-05-01 15:04:05 +00:00
dependabot[bot] aa88cd8f23 Bump tecnickcom/tcpdf from 6.9.0 to 6.9.3
Bumps [tecnickcom/tcpdf](https://github.com/tecnickcom/TCPDF) from 6.9.0 to 6.9.3.
- [Changelog](https://github.com/tecnickcom/TCPDF/blob/main/CHANGELOG.TXT)
- [Commits](https://github.com/tecnickcom/TCPDF/compare/6.9.0...6.9.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-01 11:26:54 +00:00
dependabot[bot] c82aac1d5f Bump squizlabs/php_codesniffer from 3.12.0 to 3.12.2
Bumps [squizlabs/php_codesniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer) from 3.12.0 to 3.12.2.
- [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.0...3.12.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-01 11:26:48 +00:00
oleibman c88627681c Merge pull request #4452 from oleibman/stan1003write
More Phpstan Level 10 Prep - Writers
2025-04-30 07:47:46 +00:00
oleibman 92d3c1bc7d Xls Writer Treat Hyperlink Starting with # as Internal
Fix #56, which had gone stale but is now reopened. The problem which it reported with Xlsx Writer was fixed long ago. However, Xls Writer has 2 problems regarding hyperlinks. First, some logic which should have been `if ... elseif ... else ...` was coded as `if ... if ... unconditional ...`, resulting in multiple writes and a corrupt worksheet (which Excel does fix correctly). Second, it treated a hyperlink url starting with `#` (pointer to a cell in the same spreadsheet) as external, when it should be treated as internal.

Also changed `Hyperlink::isInternal` to recognize a starting `#`, and to use `str_starts_with('sheet://')` rather than `str_contains`.
2025-04-30 00:23:35 -07:00
oleibman 662033720c Include Some Readers 2025-04-28 15:24:46 -07:00
oleibman ebb04a8811 More Phpstan Level 10 Prep - Writers 2025-04-27 07:15:26 -07:00
oleibman fb2cfed070 Merge pull request #4450 from oleibman/issue1275
Print Area and Row Break
2025-04-23 06:09:17 +00:00
oleibman f474cd6773 Update CHANGELOG.md 2025-04-22 23:06:04 -07:00
oleibman ac9a0fed7e Merge branch 'master' into issue1275 2025-04-22 22:50:27 -07:00
oleibman d8ad4b03d7 Merge pull request #4449 from oleibman/issue4448
XML Reader Recognize Indents
2025-04-23 05:45:32 +00:00
oleibman 11f0b571a4 Merge pull request #4442 from oleibman/issue4438
Micro-optimization for excelToDateTimeObject
2025-04-23 05:16:56 +00:00
oleibman 3c7afe6879 Merge pull request #4447 from oleibman/stan1002
Phpstan 10 and IterableValue Prep Part 2
2025-04-23 05:08:50 +00:00
oleibman 0d236eb274 Print Area and Row Break
Fix #1275, which had been closed as stale, and is now reopened pending the implementation of this PR. If there is a page break inside a defined print area, Excel may not render the print correctly unless the xml `brk` tag contains a `max` attribute. Libre Office renders it correctly. This seems like a bug in Excel (https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/b32ae11b-dee7-4dcb-9b46-a0feb32ce94f states that Office ignores min and max). PR #3345 (issue #3143) already addressed this problem by allowing the user to explicitly specify a `max` property in the PageBreak object. This PR eliminates the need for the user to make use of that kludge, by adding `max` to the xml whenever a page break is specified on a sheet with a defined print area. Xlsx Reader will now ignore the `max` attribute for row breaks, since it is no longer needed; it already ignores it for column breaks. The user may still set the `max` property if desired, just in case the new treatment is not adequate (I have not found a case where that is true). Two existing unit tests are very marginally changed because of this PR.
2025-04-21 23:52:08 -07:00