Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape any dollar signs when formatting cell data #4243

Merged
merged 3 commits into from
Nov 30, 2024

Conversation

sirbaconjr
Copy link
Contributor

@sirbaconjr sirbaconjr commented Nov 25, 2024

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

Why this change is needed?

Fix #4242. When a cell is formatted as text and contains a number prefixed with dollar sign, this number is getting replaced with 0. The replacement happens due to the preg_replace function. This commit escapes any sollar signs on the cell data, so those are not replaced.

@sirbaconjr sirbaconjr changed the title Escale any dollar signs when formatting cell data Escape any dollar signs when formatting cell data Nov 25, 2024
@sirbaconjr sirbaconjr force-pushed the fix-dollar-sign-issue-4242 branch from 61c0f25 to 32a004f Compare November 25, 2024 17:14
@sirbaconjr sirbaconjr force-pushed the fix-dollar-sign-issue-4242 branch 2 times, most recently from a726ff9 to 3af8f4e Compare November 25, 2024 20:59
@sirbaconjr sirbaconjr force-pushed the fix-dollar-sign-issue-4242 branch from 4d7bc6b to 171ca3a Compare November 26, 2024 20:15
This commit fix two issues that happened when the a cell was formatted as text
* When the cell contains a number prefixed with dollar sign, this number is getting replaced with 0. The replacement happens due to the preg_replace function.
* When the cell contains quotes, the quote would be removed.
@sirbaconjr sirbaconjr force-pushed the fix-dollar-sign-issue-4242 branch from 171ca3a to 3eee749 Compare November 26, 2024 20:20
@oleibman
Copy link
Collaborator

I finally figured it out - we want special processing for quote marks if they are part of the format, but not if they are part of the value. Updated your code slightly, added a new test case. I think this is what we need, or pretty close if not. I'll continue to think about for a day or two, and then merge.

@oleibman
Copy link
Collaborator

@sirbaconjr We seem to be working at cross purposes. If you have changes you still want to make, please use the current state of the PR as your starting point - commit 4b568b4

@oleibman oleibman added this pull request to the merge queue Nov 30, 2024
Merged via the queue into PHPOffice:master with commit d4ffa3e Nov 30, 2024
14 checks passed
@oleibman
Copy link
Collaborator

Thank you for your contribution, and for your patience as we expanded the scope of your change.

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.

Number prefixed with dollar sign is replaced when using rangeToArray
2 participants