* ROUND Accepts null, false, and true as First Parameter Issue #1789 was addressed by PR #1799. In a follow-up discussion, it came to light that ROUND was not handling the unexpected case where the first parameter is an empty cell in the same manner that Excel does. Subsequent investigation showed that a boolean first parameter is permitted. I broadened my investigation to include the following related functions. - ROUNDUP - ROUNDDOWN - MROUND - TRUNC - INT - FLOOR - FLOOR.MATH - FLOOR.PRECISE - CEILING - CEILING.MATH - CEILING.PRECISE All of these allow a NULL first parameter, and all except MROUND allow boolean. For completeness, I will note that all treat null string as invalid. I suspect there are other functions which permit similarly unexpected parameters, but I consider them out of scope for this PR. CEILING.MATH and CEILING.PRECISE were unimplemented, and are now supported as part of this PR. The tests for each of these functions have been re-coded, though all the original test data is still included in the test cases, plus several new cases for each. The new tests now take place as a user would invoke the functions, through a spreadsheet cell rather than a direct call to the appropriate function within Calculation/MathTrig. Aside from being more realistic, the new tests are also more complete. For example, FLOOR.MATH can take from 1-3 arguments, and the existing tests confirmed that the function in Calculation could handle a single argument. However, the function list in Calculation.php erroneously set the number of arguments for FLOOR.MATH to exactly 3, so, if a user tried to get the calculated result of a cell containing FLOOR.MATH(1.2), the result would be an Exception. Aside from the parameter support, there are a few minor code changes. Ods, as well as Gnumeric, allows the omission of the second parameter for FLOAT and CEILING; Excel does not. A potential divide-by-zero error is avoided in CEILING, FLOOR, and FLOORMATH. I will note that it would probably be beneficial in terms of maintainability to break MathTrig up into many individual modules. The same would hold for the other Calculation modules. I would be willing to look into this if you agree that it would be worthwhile. |
||
|---|---|---|
| .github | ||
| bin | ||
| docs | ||
| samples | ||
| src/PhpSpreadsheet | ||
| tests | ||
| .gitattributes | ||
| .gitignore | ||
| .php_cs.dist | ||
| .phpcs.xml.dist | ||
| .scrutinizer.yml | ||
| CHANGELOG.PHPExcel.md | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| README.md | ||
| composer.json | ||
| composer.lock | ||
| mkdocs.yml | ||
| phpunit.xml.dist | ||
README.md
PhpSpreadsheet
PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc.
Documentation
Read more about it, including install instructions, in the official documentation. Or check out the API documentation.
Please ask your support questions on StackOverflow, or have a quick chat on Gitter.
PHPExcel vs PhpSpreadsheet ?
PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.).
Because all efforts have shifted to PhpSpreadsheet, PHPExcel will no longer be maintained. All contributions for PHPExcel, patches and new features, should target PhpSpreadsheet master branch.
Do you need to migrate? There is an automated tool for that.
License
PhpSpreadsheet is licensed under MIT.

