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

Add Ability to Add Custom Functions to Calculation #4390

Merged
merged 3 commits into from
Mar 8, 2025

Conversation

oleibman
Copy link
Collaborator

@oleibman oleibman commented Mar 2, 2025

For an overview of why this is desired (and ways that people have coped with its absence), see issue #2900 and issue #4048; also PR #4043 which will be superseded by this PR.

The list of Excel functions is moved from Calculation/Calculation to its own member. I believe that it is done in a way that will not cause big complications to two experiments from @MarkBaker (PR #2714 and PR #2734). I believe it is also done in such a way that further refactoring of Calculation can follow this model.

Custom functions can be added or removed from the function list. You cannot add a function if it already exists in the list, and you cannot remove a non-custom function from the list. They will, of course, not be understood by Excel if written to a spreadsheet; the use case is mainly using the Calculation engine outside of spreadsheet context.

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

For an overview of why this is desired (and ways that people have coped with its absence), see issue PHPOffice#2900 and issue PHPOffice#4048; also PR PHPOffice#4043 which will be superseded by this PR.

The list of Excel functions is moved from Calculation/Calculation to its own member. I believe that it is done in a way that will not cause big complications to two experiments from @MarkBaker (PR PHPOffice#2714 and PR PHPOffice#2734). I believe it is also done in such a way that further refactoring of Calculation can follow this model.

Custom functions can be added or removed from the function list. You cannot add a function if it already exists in the list, and you cannot remove a non-custom function from the list. They will, of course, not be understood by Excel if written to a spreadsheet; the use case is mainly using the Calculation engine outside of spreadsheet context.
@oleibman
Copy link
Collaborator Author

oleibman commented Mar 2, 2025

4 new false positives from Scrutinizer, which doesn't seem to understand how "protected" works.

oleibman added 2 commits March 6, 2025 16:40
Prove you can't override a built-in function.
@oleibman oleibman added this pull request to the merge queue Mar 8, 2025
Merged via the queue into PHPOffice:master with commit 6ec2cc9 Mar 8, 2025
14 checks passed
@oleibman oleibman deleted the customfunc branch March 8, 2025 05:46
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.

1 participant