Skip to content

Ods Handling of Ceiling and Floor #4466

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

Merged
merged 4 commits into from
May 15, 2025
Merged

Conversation

oleibman
Copy link
Collaborator

@oleibman oleibman commented May 11, 2025

Fix #407, which went stale over 7 years ago, and is now reopened. Ods handling of CEILING and FLOOR functions is, apparently by design, subject to interoperability problems with Excel. See FLOOR and CEILING. Ods implements its own CEILING.XCL and FLOOR.XCL functions for interoperability purposes. PhpSpreadsheet will implement those, and CEILING.ODS and FLOOR.ODS psuedo-functions as well; none of these four will be listed in the official Functions documentation.

In all of the descriptions below, FLOOR follows CEILING exactly.

Ods writes its functions to Xml as follows:

  • CEILING.XCL becomes COM.MICROSOFT.CEILING
  • CEILING.MATH becomes COM.MICROSOFT.CEILING.MATH
  • CEILING.PRECISE becomes COM.MICROSOFT.CEILING.PRECISE
  • CEILING remains unchanged

PhpSpreadsheet Ods Writer will do the same, plus:

  • CEILING.ODS becomes CEILING

PhpSpreadsheet Ods Reader will act as follows:

  • CEILING (not preceded by 'COM.MICROSOFT.') becomes CEILING.ODS
  • COM.MICROSOFT.CEILING.MATH becomes CEILING.MATH
  • COM.MICROSOFT.CEILING.PRECISE becomes CEILING.PRECISE
  • COM.MICROSOFT.CEILING becomes CEILING

PhpSpreadsheet Xlsx Writer will act as follows:

  • CEILING.ODS becomes CEILING.MATH
  • CEILING.XCL becomes CEILING

PhpSpreadsheet Xls Writer will recognize only the CEILING (to which it treats CEILING.XLC as an alias) and FLOOR (to which it treats FLOOR.XLC as an alias) functions.

Note that the only difference between Ods CEILING and CEILING.MATH is that CEILING will return an error if the number and significance operands have opposite signs. PhpSpreadsheet implements this as #NUM!.

This is:

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

Checklist:

oleibman added 4 commits May 10, 2025 21:40
Fix PHPOffice#407, which went stale over 7 years ago, and is now reopened. Ods handling of CEILING and FLOOR functions is, apparently by design, subject to interoperability problems with Excel. See [FLOOR](https://wiki.documentfoundation.org/Documentation/Calc_Functions/FLOOR) and [CEILING](https://wiki.documentfoundation.org/Documentation/Calc_Functions/CEILING). Ods implements its own `CEILING.XCL` and `FLOOR.XCL` functions for interoperability purposes. PhpSpreadsheet will implement those, and `CEILING.ODS` and `FLOOR.ODS` psuedo-functions as well; none of these four will be listed in the official Functions documentation.

In all of the descriptions below, FLOOR follows CEILING exactly.

Ods writes its functions to Xml as follows:
- CEILING.XCL becomes COM.MICROSOFT.CEILING
- CEILING.MATH becomes COM.MICROSOFT.CEILING.MATH
- CEILING.PRECISE becomes COM.MICROSOFT.CEILING.PRECISE
- CEILING remains unchanged

PhpSpreadsheet Ods Writer will do the same, plus:
- CEILING.ODS becomes CEILING

PhpSpreadsheet Ods Reader will act as follows:
- CEILING (not preceded by 'COM.MICROSOFT.') becomes CEILING.ODS
- COM.MICROSOFT.CEILING.MATH becomes CEILING.MATH
- COM.MICROSOFT.CEILING.PRECISE becomes CEILING.PRECISE
- COM.MICROSOFT.CEILING becomes CEILING

PhpSpreadsheet Xlsx Writer will act as follows:
- CEILING.ODS becomes CEILING.MATH
- CEILING.XCL becomes CEILING

PhpSpreadsheet Xls Writer will recognize only the CEILING and FLOOR functions.

Note that the only difference between Ods CEILING and CEILING.MATH is that CEILING will return an error if the number and significance operands have opposite signs. PhpSpreadsheet implements this as `#VALUE!`.
Very peculiar implementation in Excel. PhpSpreadsheet will match it:
- FLOOR(8,0) is #DIV/0. This already matched, and is the only result I understand.
- CEILING(8,0) is 0 (already matched)
- FLOOR.MATH(8,0) is 0 (changed to match)
- FLOOR.PRECISE(8,0) is 0 (changed to match)
- CEILING.MATH(8,0) is 0 (already matched)
- CEILING.PRECISE(8,0) is 0 (already matched)
@oleibman oleibman enabled auto-merge May 15, 2025 01:20
@oleibman oleibman added this pull request to the merge queue May 15, 2025
Merged via the queue into PHPOffice:master with commit e6aacf7 May 15, 2025
13 of 14 checks passed
@oleibman oleibman deleted the issue407b branch May 15, 2025 01:28
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.

Possibly bug - FLOOR and FLOOR.MATH
1 participant