Commit Graph

5650 Commits

Author SHA1 Message Date
oleibman 6e9d0a0c0e Trim Change Log 2025-07-23 22:52:57 -07:00
oleibman 2ea9786632 Merge pull request #4552 from oleibman/changelog20250723
Prepare Changelog for New Release
4.5.0
2025-07-24 05:15:59 +00:00
oleibman da5f6952bd Prepare Changelog for New Release 2025-07-23 22:11:19 -07:00
oleibman dfa1d46868 Merge pull request #4543 from oleibman/blockimages
All Readers - Allow or Forbid Fetching of External Images
2025-07-23 04:39:36 +00:00
oleibman 59e20db22f Merge branch 'master' into blockimages 2025-07-22 21:32:24 -07:00
oleibman 2c4ad945cd Update Changelog 2025-07-22 21:23:55 -07:00
oleibman adb7459dfe Merge pull request #4541 from oleibman/issue4539
Html Writer Conditional Formatting Inline Css
2025-07-22 04:26:08 +00:00
oleibman b489fb3a17 Merge branch 'master' into issue4539 2025-07-21 21:23:15 -07:00
oleibman 40138b4110 Update CHANGELOG.md 2025-07-21 21:21:59 -07:00
oleibman 994b072418 Merge pull request #4540 from oleibman/issue4537
Don't Use htmlspecialchars When Formatting Xml
2025-07-22 04:12:28 +00:00
oleibman e005fdb49a Update CHANGELOG.md 2025-07-21 21:09:19 -07:00
oleibman 3538c7e0af Merge branch 'master' into issue4537 2025-07-21 20:52:07 -07:00
oleibman ba72dfe132 Update CHANGELOG.md 2025-07-21 20:51:12 -07:00
oleibman 143921118e Merge pull request #4544 from oleibman/replacedummy
Allow Replace of Dummy Function with Custom Function
2025-07-21 01:06:39 +00:00
oleibman dfb9411da7 Merge branch 'master' into replacedummy 2025-07-20 18:03:39 -07:00
oleibman 4e8bf60a28 Update CHANGELOG.md 2025-07-20 18:02:36 -07:00
oleibman 09442da690 Merge pull request #4536 from oleibman/issue347
Preserve 0x0a In Strings If Desired
2025-07-19 23:45:02 +00:00
oleibman 8cbd7a201d Update CHANGELOG.md 2025-07-19 16:36:50 -07:00
oleibman 36dd484c86 Merge branch 'master' into issue347 2025-07-18 23:28:48 -07:00
oleibman 4403ffc7e5 Merge branch 'master' into replacedummy 2025-07-18 22:47:10 -07:00
oleibman f1477b130f Allow Replace of Dummy Function with Custom Function
Custom functions were introduced recently, with a restriction that non-custom functions could not be replaced. However, reviewing a recent issue has led me to the conclusion that it might sometimes be impractical to implement an Excel function in PhpSpreadsheet for all users, but it could still be helpful to some users to offer an implementation anyhow.

The Excel ASC function is currently unimplemented in PhpSpreadsheet, and is a candidate for replacement using the functionality added in this PR. This PR supersedes PR #4513, which I will now close, and its earlier incarnation PR #4511. For reasons discussed in 4513, I don't see a way forward for implementing the Excel ASC function in a way that would be generally usable. However, this PR would permit a user to implement ASC in a way which would satisfy the user's local requirements. See the new `testReplaceDummyFunction`; I think, or at least hope, that, despite the deficiencies of 4511 and 4513, this might satisfy the author's requirement.
2025-07-18 22:01:59 -07:00
oleibman a9c6cbe146 All Readers - Allow or Forbid Fetching of External Images
Add to all readers the option to allow or forbid fetching external images. This is unconditionally allowed now. The default will be set to "allow", so no code changes are necessary. However, we are giving consideration to changing the default.
2025-07-18 21:22:09 -07:00
oleibman b442eefd80 Merge pull request #4535 from oleibman/issue1104
Writer Html/Pdf Support RTL Alignment of Table
2025-07-18 04:47:41 +00:00
oleibman 450c900ccd Merge branch 'master' into issue1104 2025-07-17 21:44:59 -07:00
oleibman 09f6a1df9f Update CHANGELOG.md 2025-07-17 21:43:45 -07:00
oleibman e1d26a0bff Merge pull request #4533 from oleibman/readdynam
Xlsx Reader Use Dynamic Arrays if Spreadsheet Did So
2025-07-18 04:34:04 +00:00
oleibman 7c1da83f8d Merge branch 'master' into readdynam 2025-07-17 21:31:08 -07:00
oleibman 5ca9c5a44e Update CHANGELOG.md 2025-07-17 21:29:26 -07:00
oleibman 3cc82a975c Border Tweak
Do not override base style if conditional style indicates BORDER_OMIT.

Do not export BORDER_NONE color 0 for conditional; same approach is already taken for unconditional.
2025-07-17 10:20:25 -07:00
oleibman 2735c40179 StyleMerger Use Copy Of baseStyle
Using baseStyle directly can lead to the by-reference problems associated with Cell and Style.
2025-07-17 07:45:55 -07:00
oleibman ffeaa42583 Emulate Xlsx More Closely
Xlsx conditional styles cannot be used to change alignment, nor font family, nor font size.

Conditional::getStyle currently allocates a new style as an unconditional style; it is changed to do so a conditional ctyle.

Border should not be conditionally merged if borderStyle is OMIT.

Inline Css was generating `class="gridlines gridlinesp"` for all cells. It is changed to use the worksheet settings to decide which classes to use.
2025-07-16 22:11:53 -07:00
oleibman a15091737f Html Writer Conditional Formatting Inline Css
Fix #4539. Conditional Formatting was recently added to Html Writer. It works fine when not using inline Css. However, when using inline Css, the code inadvertently added 2 different `style` attributes (one for the unconditional style and one for the conditional style) to the same cell. This is not valid html, and results in losing the conditional styling. This PR combines the two `style` attributes into one, which will now come after the `class`, `colspan`, and `rowspan` attributes.

Aside from the new tests, this PR changes an unusually large number of existing tests. While this might normally be considered a red flag, it is not a problem here. All of the changes involve merely changing the order of attributes within html tags; none of them affect how the generated html would appear in a browser.
2025-07-15 22:22:34 -07:00
oleibman b82756de76 Don't Use htmlspecialchars When Formatting Xml
Fix #4537. PhpSpreadsheet currently changes apostrophes in text values to `'`. This is perfectly valid Xml. Issue was opened because R does not handle this correctly; this is unquestionably a bug on R's part. So I was not inclined to do anything about it. However ...

User suggested a change to how `htmlspecialchars` was called. Investigating the use of that routine in PhpSpreadsheet, I found that there was some double escaping going on for cells whose type was set to `TYPE_INLINE` - `htmlspecialchars` escaped the string correctly, but it was later written as Xml using a method which escaped the data a second time. So, a real bug in PhpSpreadsheet after all.

There was one call to `htmlspecialchars` in `Shared\XmlWriter`. I replaced `writeRaw(htmlspecialchars(...))` with `text(...)`. And one call in `Writer\Xlsx\Worksheet`, the source of the double escaping bug above; the call to `htmlspecialchars` can just be eliminated there.

Making those changes, the only remaining calls to `htmlspecialchars` are in `Writer\Html`, where they belong. As a bonus, apostrophes now wind up unescaped, so R will be satisfied (even though they should fix their bug).
2025-07-15 21:53:43 -07:00
oleibman 250394d128 Preserve 0x0a In Strings If Desired
Fix #347, which had gone stale but is now reopened. PhpSpreadsheet is automatically replacing CR-LF and CR with LF. The reason for this is unknown, although I suggest a possibility in the issue. I am not willing to make this a breaking change. This PR adds a new property `preserveCr` with setter and getter to DefaultValueBinder (and, by extension, to StringValueBinder and AdvancedValueBinder). The property defaults to false, but users who wish to preserve CR-LF and CR can set it to true for a Spreadsheet or a Reader.
2025-07-15 00:26:20 -07:00
oleibman 2d676462a3 Merge pull request #4532 from oleibman/builtinnumfmt
Excel Inappropriate Number Format Substitution
2025-07-15 06:41:18 +00:00
oleibman 8fb10a665f Update CHANGELOG.md 2025-07-14 23:38:32 -07:00
oleibman a106886447 Merge pull request #4531 from oleibman/issue4528
Ods Reader Process Nested table-row
2025-07-15 06:25:13 +00:00
oleibman b5af16def9 Merge branch 'master' into issue4528 2025-07-14 23:22:15 -07:00
oleibman 11dc1fb67e Update CHANGELOG.md 2025-07-14 23:20:41 -07:00
oleibman 98f464b41f Writer Html/Pdf Support RTL Alignment of Table
Fix #1104, which went stale over 6 years ago, and is now reopened. This PR addresses the alignment of the table, not alignment of text. Support is added for the following:

- Html. Full support.
- Mpdf. Full support, except that, when mixed LTR and RTL worksheets are output, all tables will be on the left of the page (but will be properly aligned).
- Tcpdf. Full support when all worksheets being output are RTL; no support when mixed LTR and RTL worksheets are output.
- Dompdf. No support.
2025-07-14 00:22:54 -07:00
oleibman 159059595e Minor Tweaks 2025-07-11 17:13:53 -07:00
oleibman ae4df820bf Xlsx Reader Use Dynamic Arrays if Spreadsheet Did So
By default, when an Xlsx spreadsheet is read, its calculation engine is set to `RETURN_ARRAY_AS_VALUE` for array formulas. The user does have the option to change this. However, the presence of certain metadata in the file indicates that it was saved as if `RETURN_ARRAY_AS_ARRAY` was in use. This PR tests for the metadata, and, if present, sets `...ARRAY` rather than `...VALUE`. This eliminates the need for any extra action on the user's part.
2025-07-10 18:11:41 -07:00
oleibman ace1755238 Excel Inappropriate Number Format Substitution
My system short date format is set to `yyyy-mm-dd`.
I used Excel to create a spreadsheet, and included some dates, specifying `yyyy-mm-dd` formatting. When I looked at the resulting spreadsheet, I was surprised to see that Excel had stored the style not as `yyyy-mm-dd`, but rather as builtin style 14 (system short date format). Apparently the fact that the Excel styling matched my system choice was sufficient for it to override my choice! This is an astonishingly user-hostile implementation. Even though there are formats which, by design, "respond to changes in regional date and time settings", and even though the format I selected was not among those, Excel decided it was appropriate to vary the display even when I said I wanted an unvarying format.

This PR adds a new method `replaceBuiltinNumberFormat` to undo the damage that Excel does in such a situation. It also adds an `Excel Anomalies` document to the formal documentation, just to make situations like this readily available to the community.

BTW, Excel's sabotage can be avoided by using a number format style like `[Black]yyyy-mm-dd`.
2025-07-10 17:54:52 -07:00
oleibman 9708d72ee1 Ods Reader Process Nested table-row
Fix #4528. Fix #2507. Ods Reader expects `table:table-row` to descend directly from `table:table`. But it turns out that it can be nested under `table:table-header-rows`, `table:table-rows`, or `table:table-row-group`. Similar considerations apply to `table:table-column`. Ods Reader is changed to process the nesting tags, and therefore the nested tags underneath them. This is a major change, but it doesn't seem to have broken any existing tests or samples.

No attempt is made to add any of the nesting tags in Ods Writer.

It should be noted that 4528 has an additional problem, which has been reported as issue #4530. It is not fixed by this PR.
2025-07-08 12:52:55 -07:00
oleibman fbd4070144 Merge pull request #4524 from oleibman/issue4521
Recognize "New" Mimetype for Empty File
2025-07-04 19:57:30 +00:00
oleibman 3eff3b475a Merge branch 'master' into issue4521 2025-07-04 12:54:53 -07:00
oleibman 3cefc50690 Update CHANGELOG.md 2025-07-04 12:53:28 -07:00
oleibman b271cbffde Merge pull request #4474 from oleibman/issue4451
Bug in resizeMatricesExtend
2025-07-04 17:44:33 +00:00
oleibman 7efb118cbd Phpstan Catch-up 2025-07-04 10:41:20 -07:00
oleibman 019afe055a Merge branch 'master' into issue4451 2025-07-04 09:49:41 -07:00