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 support for _xlfn. prefixed functions + implement ISFORMULA #390

Closed
wants to merge 6 commits into from

Conversation

Josh-G
Copy link
Contributor

@Josh-G Josh-G commented Feb 24, 2018

This is:

- [ ] a bugfix
- [x] a new feature

Checklist:

Why this change is needed?

This change adds support for newer functions that are prefixed by _xlfn. (#356). The calculation engine has been updated to recognise these as functions, and drop the _xlfn. part. I've added a couple of the new functions such as STDEV.S/P, MODE.SNGL, ISFORMULA.

Whilst testing ISFORMULA, I see that loading and saving a spreadsheet that contains true or false values, without making any modifications causes the spreadsheet to contain integer 0 or 1 when loaded again in Excel. Could the following code block be added here

elseif (is_bool($calculatedValue)) {
    $objWriter->writeAttribute('t', 'b');
}

to resolve this?

Let me know if my PR needs amending.

Copy link
Member

@PowerKiKi PowerKiKi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks very good. We should only figure out what to do when $pCell is null and then it should be mergeable.

*
* @return bool
*/
public static function isFormula($value = '', \PhpOffice\PhpSpreadsheet\Cell\Cell $pCell = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either $pCell should not be optional or there should be a check whether it is null and do something else instead. Maybe add something like:

        if (!is_object($pCell)) {
            return Functions::REF();
        }

and cover it with tests.

@Josh-G
Copy link
Contributor Author

Josh-G commented Feb 25, 2018

Thanks for the review. I wasn't sure under what circumstances it could be null? I've updated it to return a REF error instead and modified the test.

Any thoughts on the boolean save conversion I mentioned above?

@PowerKiKi PowerKiKi closed this in 148bee1 Feb 26, 2018
@PowerKiKi
Copy link
Member

Thank you for this nice contribution.

For the boolean save conversion I suggest to create a new PR and it could be covered with functionnal tests, probably something similar to tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php.

@Josh-G Josh-G deleted the feature/xlfn-functions branch February 26, 2018 20:27
Dfred pushed a commit to Dfred/PhpSpreadsheet that referenced this pull request Nov 20, 2018
…`STDEV.P`

This change adds support for newer functions that are prefixed
by _xlfn. (PHPOffice#356). The calculation engine has been updated to
recognise these as functions, and drop the _xlfn. part.

It also add a couple of the new functions such as STDEV.S/P,
MODE.SNGL, ISFORMULA.

Fixes PHPOffice#356
Closes PHPOffice#390
@kory- kory- mentioned this pull request Dec 14, 2022
8 tasks
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.

None yet

2 participants