Skip to content

Conversation

@oleibman
Copy link
Collaborator

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.

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests

Checklist:

  • Changes are covered by unit tests
    • Changes are covered by existing unit tests
    • New unit tests have been added
  • Code style is respected
  • Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • Documentation is updated as necessary

Fix PHPOffice#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.
@oleibman oleibman marked this pull request as draft May 26, 2025 04:32
@oleibman
Copy link
Collaborator Author

Unsure what the runtime problem is with Xls Writer. Unable to duplicate problem on my own system. Converting to draft while I research.

No idea why this should help, but no better ideas.
@oleibman
Copy link
Collaborator Author

No explanation for what the original problem was, nor any good explanation for why my 'fix' worked. At any rate, take PR back out of draft status now.

@oleibman oleibman marked this pull request as ready for review May 26, 2025 06:33
@oleibman
Copy link
Collaborator Author

No concern about Scrutinizer's "complexity" message.

@oleibman oleibman enabled auto-merge June 1, 2025 16:26
@oleibman oleibman added this pull request to the merge queue Jun 1, 2025
Merged via the queue into PHPOffice:master with commit 44c3bd5 Jun 1, 2025
13 of 14 checks passed
@oleibman oleibman deleted the issue1154 branch June 1, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent cell styles on RichText values.

1 participant