Skip to content

[FEATURE] Convert Currencies stored as text during formula calculations #3165

Closed
@fdjohnston

Description

@fdjohnston

This is:

- [ ] a bug report
- [x] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

Hi, it's me again. Just ran into a situation similar to the percentage case we just worked through, but this time with currencies. My specific case from the Formula Parser logs is:

Evaluating 1.07 + "$0.00"
Evaluation Result is a a #VALUE! error

My initial thoughts are we could do something similar to what we just did for percentages, but for currencies. I did some playing around in Excel and it seems that it is much more restrictive about what is considered to be a currency than it is with percentages, though I wonder how localization settings are playing into this. I expect one would have to handle cases with the currency symbol before or after the value, probably very similar to what we ran into with percentages. I haven't thought this all the way through, but I wonder if we could even get away with turning the symbol into a capture group in the regexp and depending on if it's a currency symbol or a % have the convertToNumberIfPercent() function omit the division by 100. There's no way it could be that simple, but I wonder if that is a direction that bears exploring.

I going to assume that I'm underestimating the complexity of this like I did with percentages, but I thought it was worth pointing out.

As before, I'd be happy to contribute a PR if this is something the maintainers think is worth fixing, or would this just be opening a can of worms?

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions