diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 35488aebd..3bd065217 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,7 @@ jobs: - '8.2' - '8.3' - '8.4' + - '8.5' include: - php-version: 'nightly' diff --git a/CHANGELOG.md b/CHANGELOG.md index bea22d6ac..33615a788 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org). Thia is a ### Added -- Nothing yet. +- Formal support for Php8.5. +- Limited Printarea support for Html/Pdf. [Issue #3941](https://github.com/PHPOffice/PhpSpreadsheet/issues/3941) [PR #4711](https://github.com/PHPOffice/PhpSpreadsheet/pull/4711) +- Implement missing `INFO` function. [PR #4709](https://github.com/PHPOffice/PhpSpreadsheet/pull/4709) +- Implement missing `BAHTTEXT` function. [PR #4715](https://github.com/PHPOffice/PhpSpreadsheet/pull/4715) ### Removed @@ -29,7 +32,11 @@ and this project adheres to [Semantic Versioning](https://semver.org). Thia is a ### Fixed -- Nothing yet. +- Protected ranges and insert/delete rows/columns. [Issue #4695](https://github.com/PHPOffice/PhpSpreadsheet/issues/4695) [PR #4702](https://github.com/PHPOffice/PhpSpreadsheet/pull/4702) +- Unexpected Exception in Php DateTime. [Issue #4696](https://github.com/PHPOffice/PhpSpreadsheet/issues/4696) [Issue #917](https://github.com/PHPOffice/PhpSpreadsheet/issues/917) [PR #4697](https://github.com/PHPOffice/PhpSpreadsheet/pull/4697) +- Add missing Dutch translation to translation file. [PR #4707](https://github.com/PHPOffice/PhpSpreadsheet/pull/4707) +- Fix lots of typos throughout codebase. [PR #4705](https://github.com/PHPOffice/PhpSpreadsheet/pull/4705) +- Apply small code style improvements. [PR #4708](https://github.com/PHPOffice/PhpSpreadsheet/pull/4708) ## 2025-10-25 - 5.2.0 diff --git a/composer.lock b/composer.lock index 1c198db43..2e7d105be 100644 --- a/composer.lock +++ b/composer.lock @@ -1509,16 +1509,16 @@ }, { "name": "nikic/php-parser", - "version": "v5.6.1", + "version": "v5.6.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2" + "reference": "3a454ca033b9e06b63282ce19562e892747449bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", - "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb", + "reference": "3a454ca033b9e06b63282ce19562e892747449bb", "shasum": "" }, "require": { @@ -1561,9 +1561,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.2" }, - "time": "2025-08-13T20:13:15+00:00" + "time": "2025-10-21T19:32:17+00:00" }, { "name": "paragonie/random_compat", @@ -1797,11 +1797,11 @@ }, { "name": "phpstan/phpstan", - "version": "2.1.31", + "version": "2.1.32", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/ead89849d879fe203ce9292c6ef5e7e76f867b96", - "reference": "ead89849d879fe203ce9292c6ef5e7e76f867b96", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e126cad1e30a99b137b8ed75a85a676450ebb227", + "reference": "e126cad1e30a99b137b8ed75a85a676450ebb227", "shasum": "" }, "require": { @@ -1846,7 +1846,7 @@ "type": "github" } ], - "time": "2025-10-10T14:14:11+00:00" + "time": "2025-11-11T15:18:17+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -2271,16 +2271,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.55", + "version": "10.5.58", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4b2d546b336876bd9562f24641b08a25335b06b6" + "reference": "e24fb46da450d8e6a5788670513c1af1424f16ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4b2d546b336876bd9562f24641b08a25335b06b6", - "reference": "4b2d546b336876bd9562f24641b08a25335b06b6", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e24fb46da450d8e6a5788670513c1af1424f16ca", + "reference": "e24fb46da450d8e6a5788670513c1af1424f16ca", "shasum": "" }, "require": { @@ -2304,7 +2304,7 @@ "sebastian/comparator": "^5.0.4", "sebastian/diff": "^5.1.1", "sebastian/environment": "^6.1.0", - "sebastian/exporter": "^5.1.2", + "sebastian/exporter": "^5.1.4", "sebastian/global-state": "^6.0.2", "sebastian/object-enumerator": "^5.0.0", "sebastian/recursion-context": "^5.0.1", @@ -2352,7 +2352,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.55" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.58" }, "funding": [ { @@ -2376,7 +2376,7 @@ "type": "tidelift" } ], - "time": "2025-09-14T06:19:20+00:00" + "time": "2025-09-28T12:04:46+00:00" }, { "name": "psr/container", @@ -3571,16 +3571,16 @@ }, { "name": "sebastian/exporter", - "version": "5.1.2", + "version": "5.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "955288482d97c19a372d3f31006ab3f37da47adf" + "reference": "0735b90f4da94969541dac1da743446e276defa6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf", - "reference": "955288482d97c19a372d3f31006ab3f37da47adf", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0735b90f4da94969541dac1da743446e276defa6", + "reference": "0735b90f4da94969541dac1da743446e276defa6", "shasum": "" }, "require": { @@ -3589,7 +3589,7 @@ "sebastian/recursion-context": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^10.5" }, "type": "library", "extra": { @@ -3637,15 +3637,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.2" + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.4" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" } ], - "time": "2024-03-02T07:17:12+00:00" + "time": "2025-09-24T06:09:11+00:00" }, { "name": "sebastian/global-state", @@ -5709,16 +5721,16 @@ }, { "name": "theseer/tokenizer", - "version": "1.2.3", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", - "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c", + "reference": "b7489ce515e168639d17feec34b8847c326b0b3c", "shasum": "" }, "require": { @@ -5747,7 +5759,7 @@ "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "support": { "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + "source": "https://github.com/theseer/tokenizer/tree/1.3.1" }, "funding": [ { @@ -5755,7 +5767,7 @@ "type": "github" } ], - "time": "2024-03-03T12:36:25+00:00" + "time": "2025-11-17T20:03:58+00:00" } ], "aliases": [], diff --git a/docs/references/function-list-by-category.md b/docs/references/function-list-by-category.md index 22c5222ad..7a8b8728d 100644 --- a/docs/references/function-list-by-category.md +++ b/docs/references/function-list-by-category.md @@ -189,7 +189,7 @@ Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- CELL | **Not yet Implemented** ERROR.TYPE | \PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError::type -INFO | **Not yet Implemented** +INFO | \PhpOffice\PhpSpreadsheet\Calculation\Information\Info::getInfo ISBLANK | \PhpOffice\PhpSpreadsheet\Calculation\Information\Value::isBlank ISERR | \PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue::isErr ISERROR | \PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue::isError @@ -525,7 +525,7 @@ Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- ARRAYTOTEXT | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Text::fromArray ASC | **Not yet Implemented** -BAHTTEXT | **Not yet Implemented** +BAHTTEXT | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Thai::getBahtText CHAR | \PhpOffice\PhpSpreadsheet\Calculation\TextData\CharacterConvert::character CLEAN | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Trim::nonPrintable CODE | \PhpOffice\PhpSpreadsheet\Calculation\TextData\CharacterConvert::code diff --git a/docs/references/function-list-by-name-compact.md b/docs/references/function-list-by-name-compact.md index 4df84d293..6cb6508ee 100644 --- a/docs/references/function-list-by-name-compact.md +++ b/docs/references/function-list-by-name-compact.md @@ -43,7 +43,7 @@ AVERAGEIFS | STATISTICAL | Statistical\Conditional::AVER Excel Function | Category | PhpSpreadsheet Function -------------------------|-----------------------|-------------------------------------- -BAHTTEXT | TEXT_AND_DATA | **Not yet Implemented** +BAHTTEXT | TEXT_AND_DATA | TextData\Thai::getBahtText BASE | MATH_AND_TRIG | MathTrig\Base::evaluate BESSELI | ENGINEERING | Engineering\BesselI::BESSELI BESSELJ | ENGINEERING | Engineering\BesselJ::BESSELJ @@ -299,7 +299,7 @@ IMSUM | ENGINEERING | Engineering\ComplexOperations IMTAN | ENGINEERING | Engineering\ComplexFunctions::IMTAN INDEX | LOOKUP_AND_REFERENCE | LookupRef\Matrix::index INDIRECT | LOOKUP_AND_REFERENCE | LookupRef\Indirect::INDIRECT -INFO | INFORMATION | **Not yet Implemented** +INFO | INFORMATION | Information\Info::getInfo INT | MATH_AND_TRIG | MathTrig\IntClass::evaluate INTERCEPT | STATISTICAL | Statistical\Trends::INTERCEPT INTRATE | FINANCIAL | Financial\Securities\Rates::interest diff --git a/docs/references/function-list-by-name.md b/docs/references/function-list-by-name.md index 35594a710..3acf55887 100644 --- a/docs/references/function-list-by-name.md +++ b/docs/references/function-list-by-name.md @@ -39,7 +39,7 @@ AVERAGEIFS | CATEGORY_STATISTICAL | \PhpOffice\PhpSpread Excel Function | Category | PhpSpreadsheet Function -------------------------|--------------------------------|-------------------------------------- -BAHTTEXT | CATEGORY_TEXT_AND_DATA | **Not yet Implemented** +BAHTTEXT | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData\Thai::getBahtText BASE | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Base::evaluate BESSELI | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering\BesselI::BESSELI BESSELJ | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering\BesselJ::BESSELJ @@ -295,7 +295,7 @@ IMSUM | CATEGORY_ENGINEERING | \PhpOffice\PhpSpread IMTAN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering\ComplexFunctions::IMTAN INDEX | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Matrix::index INDIRECT | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Indirect::INDIRECT -INFO | CATEGORY_INFORMATION | **Not yet Implemented** +INFO | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Information\Info::getInfo INT | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig\IntClass::evaluate INTERCEPT | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical\Trends::INTERCEPT INTRATE | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial\Securities\Rates::interest diff --git a/docs/topics/autofilters.md b/docs/topics/autofilters.md index a80283697..220a6fe37 100644 --- a/docs/topics/autofilters.md +++ b/docs/topics/autofilters.md @@ -176,6 +176,7 @@ $columnFilter->createRule() In MS Excel, DateGroup filters provide a series of dropdown filter selectors for date values, so you can specify entire years, or months within a year, or individual days within each month. +Note that cells covered by such a filter are expected to be in [Excel DateTime Format](./calculation-engine.md#excel-timestamps). ![04-02-dategroup-autofilter.png](./images/04-02-dategroup-autofilter.png) diff --git a/docs/topics/calculation-engine.md b/docs/topics/calculation-engine.md index ca628c0a7..c6450235c 100644 --- a/docs/topics/calculation-engine.md +++ b/docs/topics/calculation-engine.md @@ -194,20 +194,22 @@ Time functions in Excel will be a PHP `DateTime` object. #### Excel Timestamps -If `RETURNDATE_EXCEL` is set for the Return Date Type, then the returned -date value by any access to the Date and Time functions in Excel will be -a floating point value that represents a number of days from the Excel -base date. The Excel base date is determined by which calendar Excel +Excel timestamps are stored as integer or floating point, where the integer portion represents the number of days since a base date, +and the fraction portion represents the time of day (0 is midnight, 0.5 is noon, 0.999... is just before midnight the next day). +The Excel base date is determined by which calendar Excel uses: the Windows 1900 or the Mac 1904 calendar. 1st January 1900 is the base date for the Windows 1900 calendar while 1st January 1904 is the base date for the Mac 1904 calendar. -It is possible for scripts to change the calendar used for calculating -Excel date values by calling the -`\PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar()` method: +If `RETURNDATE_EXCEL` is set for the Return Date Type, then the returned +date value by any access to the Date and Time functions in Excel will be +a floating point value in Excel timestamp format (previous paragraph). +It is possible for scripts to change the calendar used for calculating +Excel date values by calling: ```php -\PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar($baseDate); +\PhpOffice\PhpSpreadsheet\Shared\Date::setExcelCalendar($baseDate); // static property, less preferred +$spreadsheet->setExcelCalendar($baseDate); // instance property, preferred ``` where the following constants can be used for `$baseDate`: @@ -218,11 +220,10 @@ where the following constants can be used for `$baseDate`: The method will return a Boolean True on success, False on failure (e.g. if an invalid value is passed in). -The `\PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar()` method can -be used to determine the current value of this setting: - +The current value of this setting can be determined via: ```php -$baseDate = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar(); +$baseDate = \PhpOffice\PhpSpreadsheet\Shared\Date::getExcelCalendar(); // static +$baseDate = $spreadsheet->getExcelCalendar(); // instance ``` The default is `CALENDAR_WINDOWS_1900`. diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b267f8c3b..524d3f5ab 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -17,9 +17,3 @@ parameters: identifier: argument.type count: 1 path: src/PhpSpreadsheet/ReferenceHelper.php - - - - message: '#^Cannot call method setParent\(\) on mixed\.$#' - identifier: method.nonObject - count: 1 - path: src/PhpSpreadsheet/Worksheet/AutoFilter.php diff --git a/src/PhpSpreadsheet/Calculation/BinaryComparison.php b/src/PhpSpreadsheet/Calculation/BinaryComparison.php index 1f697946c..2edd5dea0 100644 --- a/src/PhpSpreadsheet/Calculation/BinaryComparison.php +++ b/src/PhpSpreadsheet/Calculation/BinaryComparison.php @@ -51,7 +51,7 @@ class BinaryComparison $operand2 = Calculation::unwrapResult($operand2); } - // Use case insensitive comparaison if not OpenOffice mode + // Use case-insensitive comparison if not OpenOffice mode if (Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) { if (is_string($operand1)) { $operand1 = StringHelper::strToUpper($operand1); diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 679704bf9..832078035 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2764,6 +2764,7 @@ class Calculation extends CalculationLocale // read constant value if (str_contains($constantName, '::')) { [$className, $constantName] = explode('::', $constantName); + /** @var class-string $className */ $constantReflector = new ReflectionClassConstant($className, $constantName); return $constantReflector->getValue(); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php index 9a6faf326..6ee9d7e55 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php @@ -24,7 +24,7 @@ class Date * Excel Function: * DATE(year,month,day) * - * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function. + * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non-numeric values to this function. * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. * diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php index d29ed6bae..40356924e 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php @@ -118,7 +118,7 @@ class DateValue if (!Helpers::dateParseSucceeded($PHPDateArray)) { // If original count was 1, we've already returned. // If it was 2, we added another. - // Therefore, neither of the first 2 stroks below can fail. + // Therefore, neither of the first 2 strtoks below can fail. $testVal1 = strtok($dateValue, '- '); $testVal2 = strtok('- '); $testVal3 = strtok('- ') ?: $dti->format('Y'); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php index 2ccadf53f..58eb68de6 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php @@ -76,7 +76,7 @@ class Days360 } /** - * Return the number of days between two dates based on a 360 day calendar. + * Return the number of days between two dates based on a 360-day calendar. */ private static function dateDiff360(int $startDay, int $startMonth, int $startYear, int $endDay, int $endMonth, int $endYear, bool $methodUS): int { diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index ee1d4866c..492447dd0 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -7,6 +7,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Exception; use PhpOffice\PhpSpreadsheet\Calculation\Functions; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper; +use Throwable; class Helpers { @@ -56,6 +57,12 @@ class Helpers throw new Exception(ExcelError::NAN()); } + try { + SharedDateHelper::excelToDateTimeObject((float) $dateValue); + } catch (Throwable) { + throw new Exception(ExcelError::NAN()); + } + return (float) $dateValue; } diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php index a7f415d33..86007d4b5 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php @@ -4,7 +4,9 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; use PhpOffice\PhpSpreadsheet\Calculation\Exception; +use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Shared\Date as SharedDateHelper; +use Throwable; class TimeParts { @@ -44,6 +46,11 @@ class TimeParts } // Execute function + try { + SharedDateHelper::excelToDateTimeObject($timeValue); + } catch (Throwable) { + return ExcelError::NAN(); + } $timeValue = fmod($timeValue, 1); $timeValue = SharedDateHelper::excelToDateTimeObject($timeValue); SharedDateHelper::roundMicroseconds($timeValue); @@ -85,6 +92,11 @@ class TimeParts } // Execute function + try { + SharedDateHelper::excelToDateTimeObject($timeValue); + } catch (Throwable) { + return ExcelError::NAN(); + } $timeValue = fmod($timeValue, 1); $timeValue = SharedDateHelper::excelToDateTimeObject($timeValue); SharedDateHelper::roundMicroseconds($timeValue); @@ -126,6 +138,11 @@ class TimeParts } // Execute function + try { + SharedDateHelper::excelToDateTimeObject($timeValue); + } catch (Throwable) { + return ExcelError::NAN(); + } $timeValue = fmod($timeValue, 1); $timeValue = SharedDateHelper::excelToDateTimeObject($timeValue); SharedDateHelper::roundMicroseconds($timeValue); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php index 9834bccbb..3513840fb 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php @@ -150,7 +150,7 @@ class ConvertDecimal extends ConvertBase /** * toOctal. * - * Return an decimal value as octal. + * Return a decimal value as octal. * * Excel Function: * DEC2OCT(x[,places]) diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php index 4cca2d6b9..db104bfac 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php @@ -18,7 +18,7 @@ class ErfC * Note: In Excel 2007 or earlier, if you input a negative value for the lower bound argument, * the function would return a #NUM! error. However, in Excel 2010, the function algorithm was * improved, so that it can now calculate the function for both positive and negative x values. - * PhpSpreadsheet follows Excel 2010 behaviour, and accepts nagative arguments. + * PhpSpreadsheet follows Excel 2010 behaviour, and accepts negative arguments. * * Excel Function: * ERFC(x) diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php index 68ac57b8a..33031ccba 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php @@ -83,7 +83,7 @@ class Interest * =ISPMT(interest_rate, period, number_payments, pv) * * @param mixed $interestRate is the interest rate for the investment - * @param mixed $period is the period to calculate the interest rate. It must be betweeen 1 and number_payments. + * @param mixed $period is the period to calculate the interest rate. It must be between 1 and number_payments. * @param mixed $numberOfPeriods is the number of payments for the annuity * @param mixed $principleRemaining is the loan amount or present value of the payments */ diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index f07b5b5db..945bcd69d 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -463,16 +463,8 @@ class FormulaParser $tokenCount = count($tokens1); for ($i = 0; $i < $tokenCount; ++$i) { $token = $tokens1[$i]; - if (isset($tokens1[$i - 1])) { - $previousToken = $tokens1[$i - 1]; - } else { - $previousToken = null; - } - if (isset($tokens1[$i + 1])) { - $nextToken = $tokens1[$i + 1]; - } else { - $nextToken = null; - } + $previousToken = $tokens1[$i - 1] ?? null; + $nextToken = $tokens1[$i + 1] ?? null; if ($token->getTokenType() != FormulaToken::TOKEN_TYPE_WHITESPACE) { $tokens2[] = $token; @@ -518,11 +510,7 @@ class FormulaParser $tokenCount = count($tokens2); for ($i = 0; $i < $tokenCount; ++$i) { $token = $tokens2[$i]; - if (isset($tokens2[$i - 1])) { - $previousToken = $tokens2[$i - 1]; - } else { - $previousToken = null; - } + $previousToken = $tokens2[$i - 1] ?? null; if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') { if ($i == 0) { diff --git a/src/PhpSpreadsheet/Calculation/FunctionArray.php b/src/PhpSpreadsheet/Calculation/FunctionArray.php index fd2d5a0cc..bc7f3a76d 100644 --- a/src/PhpSpreadsheet/Calculation/FunctionArray.php +++ b/src/PhpSpreadsheet/Calculation/FunctionArray.php @@ -149,7 +149,7 @@ class FunctionArray extends CalculationBase ], 'BAHTTEXT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [TextData\Thai::class, 'getBahtText'], 'argumentCount' => '1', ], 'BASE' => [ @@ -919,7 +919,7 @@ class FunctionArray extends CalculationBase 'FLOOR' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [MathTrig\Floor::class, 'floor'], - 'argumentCount' => '1-2', // Excel requries 2, Ods/Gnumeric 1-2 + 'argumentCount' => '1-2', // Excel requires 2, Ods/Gnumeric 1-2 ], 'FLOOR.MATH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, @@ -1284,8 +1284,9 @@ class FunctionArray extends CalculationBase ], 'INFO' => [ 'category' => Category::CATEGORY_INFORMATION, - 'functionCall' => [Functions::class, 'DUMMY'], + 'functionCall' => [Information\Info::class, 'getInfo'], 'argumentCount' => '1', + 'passCellReference' => true, ], 'INT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, diff --git a/src/PhpSpreadsheet/Calculation/Information/Info.php b/src/PhpSpreadsheet/Calculation/Information/Info.php new file mode 100644 index 000000000..61138fe1e --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/Information/Info.php @@ -0,0 +1,44 @@ + '/', + 'numfile' => $cell?->getWorksheetOrNull()?->getParent()?->getSheetCount() ?? 1, + 'origin' => '$A:$A$1', + 'osversion' => 'PHP ' . PHP_VERSION, + 'recalc' => 'Automatic', + 'release' => PHP_VERSION, + 'system' => 'PHP', + 'memavail', 'memused', 'totmem' => ExcelError::NA(), + default => ExcelError::VALUE(), + }; + } +} diff --git a/src/PhpSpreadsheet/Calculation/Information/Value.php b/src/PhpSpreadsheet/Calculation/Information/Value.php index 57a6704df..2f949cd05 100644 --- a/src/PhpSpreadsheet/Calculation/Information/Value.php +++ b/src/PhpSpreadsheet/Calculation/Information/Value.php @@ -265,7 +265,7 @@ class Value if (is_bool($value)) { return (int) $value; } - if (is_string($value) && substr($value, 0, 1) === '#') { + if (is_string($value) && str_starts_with($value, '#')) { return $value; } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php index 3a1a6c41b..b7e0f9de7 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php @@ -58,7 +58,7 @@ class ExcelMatch return $e->getMessage(); } - // MATCH() is not case sensitive, so we convert lookup value to be lower cased if it's a string type. + // MATCH() is not case-sensitive, so we convert lookup value to be lower cased if it's a string type. if (is_string($lookupValue)) { $lookupValue = StringHelper::strToLower($lookupValue); } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php index 756478c44..ea8db548c 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php @@ -106,7 +106,7 @@ class Indirect */ private static function extractRequiredCells(?Worksheet $worksheet, string $cellAddress): array { - return Calculation::getInstance($worksheet !== null ? $worksheet->getParent() : null) + return Calculation::getInstance($worksheet?->getParent()) ->extractCellRange($cellAddress, $worksheet, false, createCell: true); } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php index 6b0726231..bc6537d10 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php @@ -84,7 +84,7 @@ class Offset $endCellColumn = self::adjustEndCellColumnForWidth($endCellColumn, $width, $startCellColumn, $columns); $startCellColumn = Coordinate::stringFromColumnIndex($startCellColumn + 1); - $endCellRow = self::adustEndCellRowForHeight($height, $startCellRow, $rows, $endCellRow); + $endCellRow = self::adjustEndCellRowForHeight($height, $startCellRow, $rows, $endCellRow); if (($endCellRow <= 0) || ($endCellColumn < 0)) { return ExcelError::REF(); @@ -102,7 +102,7 @@ class Offset /** @return mixed[] */ private static function extractRequiredCells(?Worksheet $worksheet, string $cellAddress): array { - return Calculation::getInstance($worksheet !== null ? $worksheet->getParent() : null) + return Calculation::getInstance($worksheet?->getParent()) ->extractCellRange($cellAddress, $worksheet, false); } @@ -152,7 +152,7 @@ class Offset * @param null|object|scalar $height * @param scalar $rows */ - private static function adustEndCellRowForHeight($height, int $startCellRow, $rows, int $endCellRow): int + private static function adjustEndCellRowForHeight($height, int $startCellRow, $rows, int $endCellRow): int { if (($height !== null) && (!is_object($height))) { $endCellRow = $startCellRow + (int) $height - 1; diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php index 78a30a4d7..b640f7d9a 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php @@ -55,7 +55,7 @@ class Sort extends LookupRefValidations return $e->getMessage(); } - // We want a simple, enumrated array of arrays where we can reference column by its index number. + // We want a simple, enumerated array of arrays where we can reference column by its index number. /** @var callable(mixed): mixed */ $temp = 'array_values'; /** @var array $sortOrder */ diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php b/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php index 47c2c9800..04549a1ca 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php @@ -57,7 +57,7 @@ class Arabic * * @param string|string[] $roman Should be a string, or can be an array of strings * - * @return array|int|string the arabic numberal contrived from the roman numeral + * @return array|int|string the arabic numeral contrived from the roman numeral * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions */ diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php index 378ce8a22..b53f15c4f 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php @@ -28,9 +28,9 @@ class Beta * Or can be an array of values * @param mixed $beta Parameter to the distribution as a float * Or can be an array of values - * @param mixed $rMin as an float + * @param mixed $rMin as a float * Or can be an array of values - * @param mixed $rMax as an float + * @param mixed $rMax as a float * Or can be an array of values * * @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php index 67cf4026d..948e64043 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php @@ -65,7 +65,7 @@ class Binomial /** * BINOM.DIST.RANGE. * - * Returns returns the Binomial Distribution probability for the number of successes from a specified number + * Returns the Binomial Distribution probability for the number of successes from a specified number * of trials falling into a specified range. * * @param mixed $trials Integer number of trials diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php index 7e2ee92c2..5a0a7ebed 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php @@ -116,7 +116,7 @@ class Normal // whatever purpose you want, but please show common courtesy and give credit // where credit is due. - // Input paramater is $p - probability - where 0 < p < 1. + // Input parameter is $p - probability - where 0 < p < 1. // Coefficients in rational approximations /** @var array */ diff --git a/src/PhpSpreadsheet/Calculation/TextData/Search.php b/src/PhpSpreadsheet/Calculation/TextData/Search.php index 0c4b97781..0aad5ed70 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Search.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Search.php @@ -12,7 +12,7 @@ class Search use ArrayEnabled; /** - * FIND (case sensitive search). + * FIND (case-sensitive search). * * @param mixed $needle The string to look for * Or can be an array of values @@ -54,7 +54,7 @@ class Search } /** - * SEARCH (case insensitive search). + * SEARCH (case-insensitive search). * * @param mixed $needle The string to look for * Or can be an array of values diff --git a/src/PhpSpreadsheet/Calculation/TextData/Thai.php b/src/PhpSpreadsheet/Calculation/TextData/Thai.php new file mode 100644 index 000000000..0d08db0ad --- /dev/null +++ b/src/PhpSpreadsheet/Calculation/TextData/Thai.php @@ -0,0 +1,139 @@ + 'ศูนย์', + 1 => 'หนึ่ง', + 2 => 'สอง', + 3 => 'สาม', + 4 => 'สี่', + 5 => 'ห้า', + 6 => 'หก', + 7 => 'เจ็ด', + 8 => 'แปด', + 9 => 'เก้า', + ]; + + private const THAI_UNITS = [ + 1 => 'สิบ', + 2 => 'ร้อย', + 3 => 'พัน', + 4 => 'หมื่น', + 5 => 'แสน', + 6 => 'ล้าน', + ]; + + private const THAI_COMPOUND_ONE = 'เอ็ด'; + private const THAI_COMPOUND_TWO = 'ยี่'; + private const THAI_INTEGER = 'ถ้วน'; + private const THAI_MINUS = 'ลบ'; + private const THAI_BAHT = 'บาท'; + private const THAI_SATANG = 'สตางค์'; + + /** + * BAHTTEXT. + * + * @param mixed $number The number or array of numbers to convert + * + * @return array|string If an array of values is passed as the argument, then the returned result will also be an array with the same dimensions + */ + public static function getBahtText(mixed $number): array|string + { + if (is_array($number)) { + return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); + } + + if (is_string($number) && preg_match('/^-?\d+$/', $number)) { + $isNegative = str_starts_with($number, '-'); + $baht = ltrim($number, '-0') ?: '0'; + $satang = '00'; + } elseif (is_bool($number) || is_numeric($number)) { + $number += 0; + $isNegative = $number < 0; + [$baht, $satang] = explode('.', number_format(abs($number), 2, '.', '')); + } else { + return ExcelError::VALUE(); + } + + $hasWhole = $baht !== '0'; + $hasFraction = $satang !== '00'; + + if (!$hasWhole && !$hasFraction) { + return self::THAI_DIGITS[0] . self::THAI_BAHT . self::THAI_INTEGER; + } + + $text = $isNegative + ? self::THAI_MINUS + : ''; + + if ($hasWhole) { + $text .= self::convertLarge($baht) . self::THAI_BAHT; + } + + $text .= $hasFraction + ? self::convertBlock($satang) . self::THAI_SATANG + : self::THAI_INTEGER; + + return $text; + } + + private static function convertLarge(string $digits): string + { + $length = strlen($digits) % 6 ?: 6; + + $chunks = [ + substr($digits, 0, $length), + ...str_split(substr($digits, $length), 6), + ]; + + $chunks = array_filter($chunks, fn (string $chunk): bool => $chunk !== ''); + + return implode( + self::THAI_UNITS[6], + array_map(self::convertBlock(...), $chunks) + ); + } + + private static function convertBlock(string $block): string + { + $out = ''; + $length = strlen($block); + $i = 0; + + // Hundreds and higher powers + for ($power = $length - 1; $power >= 2; --$power) { + $digit = $block[$i++]; + if ($digit !== '0') { + $out .= self::THAI_DIGITS[$digit] . self::THAI_UNITS[$power]; + } + } + + // Tens + $ten = $length > 1 ? $block[$i++] : '0'; + if ($ten !== '0') { + $out .= match ($ten) { + '1' => '', + '2' => self::THAI_COMPOUND_TWO, + default => self::THAI_DIGITS[$ten], + } . self::THAI_UNITS[1]; + } + + // Ones + $one = $block[$i] ?? '0'; + if ($one !== '0') { + $out .= $ten !== '0' && $one === '1' + ? self::THAI_COMPOUND_ONE + : self::THAI_DIGITS[$one]; + } + + return $out; + } +} diff --git a/src/PhpSpreadsheet/Calculation/locale/Translations.xlsx b/src/PhpSpreadsheet/Calculation/locale/Translations.xlsx index 080d5e7a8..78a67d0b7 100644 Binary files a/src/PhpSpreadsheet/Calculation/locale/Translations.xlsx and b/src/PhpSpreadsheet/Calculation/locale/Translations.xlsx differ diff --git a/src/PhpSpreadsheet/Calculation/locale/nl/functions b/src/PhpSpreadsheet/Calculation/locale/nl/functions index ce0b30cc8..7fd661b19 100644 --- a/src/PhpSpreadsheet/Calculation/locale/nl/functions +++ b/src/PhpSpreadsheet/Calculation/locale/nl/functions @@ -38,6 +38,7 @@ DVARP = DBVARP ## Datum- en tijdfuncties (Date & Time Functions) ## DATE = DATUM +DATEDIF = DATUMVERSCHIL DATESTRING = DATUMNOTATIE DATEVALUE = DATUMWAARDE DAY = DAG diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 227f2c117..5aa96f44b 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -316,7 +316,7 @@ abstract class Coordinate $worksheet = $matches['worksheet']; if ($worksheet !== '') { - if (substr($worksheet, 0, 1) === "'" && substr($worksheet, -1, 1) === "'") { + if (str_starts_with($worksheet, "'") && str_ends_with($worksheet, "'")) { $worksheet = substr($worksheet, 1, -1); } $data['worksheet'] = strtolower($worksheet); @@ -401,7 +401,7 @@ abstract class Coordinate return $indexCache[$columnAddress]; } // It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array - // rather than use ord() and make it case insensitive to get rid of the strtoupper() as well. + // rather than use ord() and make it case-insensitive to get rid of the strtoupper() as well. // Because it's a static, there's no significant memory overhead either. /** @var array */ static $columnLookup = [ @@ -671,7 +671,7 @@ abstract class Coordinate * * @param array $coordinateCollection associative array mapping coordinates to values * - * @return array associative array mapping coordinate ranges to valuea + * @return array associative array mapping coordinate ranges to values */ public static function mergeRangesInCollection(array $coordinateCollection): array { diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index 7736fb7a3..f10642d27 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -66,7 +66,7 @@ class Legend } /** - * Get legend position as an excel string value. + * Get legend position as an Excel string value. */ public function getPosition(): string { @@ -74,7 +74,7 @@ class Legend } /** - * Get legend position using an excel string value. + * Get legend position using an Excel string value. * * @param string $position see self::POSITION_* */ diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php index faadd9a30..ba30a35ff 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraph.php @@ -3,7 +3,7 @@ namespace PhpOffice\PhpSpreadsheet\Chart\Renderer; /** - * Jpgraph is not oficially maintained in Composer, so the version there + * Jpgraph is not officially maintained in Composer, so the version there * could be out of date. For that reason, all unit test requiring Jpgraph * are skipped. So, do not measure code coverage for this class till that * is fixed. diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php index 151d5b58c..ce08ee0a6 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php @@ -81,7 +81,7 @@ abstract class JpGraphRendererBase implements IRenderer } /** - * This method should be overriden in descendants to do real JpGraph library initialization. + * This method should be overridden in descendants to do real JpGraph library initialization. */ abstract protected static function init(): void; diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index 0661867d6..269c2679c 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -281,7 +281,7 @@ class Cells continue; } $column = ($coordinate % self::MAX_COLUMN_ID) ?: self::MAX_COLUMN_ID; - $maxColumn = $maxColumn > $column ? $maxColumn : $column; + $maxColumn = max($column, $maxColumn); } return Coordinate::stringFromColumnIndex($maxColumn); diff --git a/src/PhpSpreadsheet/Reader/Csv/Delimiter.php b/src/PhpSpreadsheet/Reader/Csv/Delimiter.php index 05b898fc4..a3370e02d 100644 --- a/src/PhpSpreadsheet/Reader/Csv/Delimiter.php +++ b/src/PhpSpreadsheet/Reader/Csv/Delimiter.php @@ -4,7 +4,7 @@ namespace PhpOffice\PhpSpreadsheet\Reader\Csv; class Delimiter { - protected const POTENTIAL_DELIMETERS = [',', ';', "\t", '|', ':', ' ', '~']; + protected const POTENTIAL_DELIMITERS = [',', ';', "\t", '|', ':', ' ', '~']; /** @var resource */ protected $fileHandle; @@ -34,7 +34,7 @@ class Delimiter public function getDefaultDelimiter(): string { - return self::POTENTIAL_DELIMETERS[0]; + return self::POTENTIAL_DELIMITERS[0]; } public function linesCounted(): int @@ -44,8 +44,8 @@ class Delimiter protected function countPotentialDelimiters(): void { - $this->counts = array_fill_keys(self::POTENTIAL_DELIMETERS, []); - $delimiterKeys = array_flip(self::POTENTIAL_DELIMETERS); + $this->counts = array_fill_keys(self::POTENTIAL_DELIMITERS, []); + $delimiterKeys = array_flip(self::POTENTIAL_DELIMITERS); // Count how many times each of the potential delimiters appears in each line $this->numberLines = 0; @@ -61,7 +61,7 @@ class Delimiter $distribution = array_count_values($splitString); $countLine = array_intersect_key($distribution, $delimiterKeys); - foreach (self::POTENTIAL_DELIMETERS as $delimiter) { + foreach (self::POTENTIAL_DELIMITERS as $delimiter) { $this->counts[$delimiter][] = $countLine[$delimiter] ?? 0; } } @@ -73,7 +73,7 @@ class Delimiter $meanSquareDeviations = []; $middleIdx = (int) floor(($this->numberLines - 1) / 2); - foreach (self::POTENTIAL_DELIMETERS as $delimiter) { + foreach (self::POTENTIAL_DELIMITERS as $delimiter) { $series = $this->counts[$delimiter]; sort($series); @@ -94,7 +94,7 @@ class Delimiter // ... and pick the delimiter with the smallest mean square deviation // (in case of ties, the order in potentialDelimiters is respected) $min = INF; - foreach (self::POTENTIAL_DELIMETERS as $delimiter) { + foreach (self::POTENTIAL_DELIMITERS as $delimiter) { if (!isset($meanSquareDeviations[$delimiter])) { continue; } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php b/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php index e947ae2f9..0729f2ef2 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php @@ -47,7 +47,7 @@ class Styles '8' => Fill::FILL_PATTERN_DARKVERTICAL, // vertical stripe '9' => Fill::FILL_PATTERN_DARKDOWN, // diagonal stripe '10' => Fill::FILL_PATTERN_DARKUP, // reverse diagonal stripe - '11' => Fill::FILL_PATTERN_DARKGRID, // diagoanl crosshatch + '11' => Fill::FILL_PATTERN_DARKGRID, // diagonal crosshatch '12' => Fill::FILL_PATTERN_DARKTRELLIS, // thick diagonal crosshatch '13' => Fill::FILL_PATTERN_LIGHTHORIZONTAL, '14' => Fill::FILL_PATTERN_LIGHTVERTICAL, diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 579f3892d..49b52028c 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -533,6 +533,10 @@ class Html extends BaseReader $sheet->setShowGridlines(in_array('gridlines', $classes, true)); $sheet->setPrintGridlines(in_array('gridlinesp', $classes, true)); } + if (isset($attributeArray['data-printarea'])) { + $sheet->getPageSetup() + ->setPrintArea($attributeArray['data-printarea']); + } if ('rtl' === ($attributeArray['dir'] ?? '')) { $sheet->setRightToLeft(true); } @@ -915,7 +919,7 @@ class Html extends BaseReader * and only takes 'background-color' and 'color'; property with HEX color * * TODO : - * - Implement to other propertie, such as border + * - Implement to other properties, such as border * * @param string[] $attributeArray */ @@ -1129,7 +1133,7 @@ class Html extends BaseReader $styleArray = self::getStyleArray($attributes); $src = $attributes['src']; - if (substr($src, 0, 5) !== 'data:') { + if (!str_starts_with($src, 'data:')) { $src = urldecode($src); } $width = isset($attributes['width']) ? (float) $attributes['width'] : ($styleArray['width'] ?? null); @@ -1195,13 +1199,13 @@ class Html extends BaseReader $arrayKey = trim($value[0]); $arrayValue = trim($value[1]); if ($arrayKey === 'width') { - if (substr($arrayValue, -2) === 'px') { + if (str_ends_with($arrayValue, 'px')) { $arrayValue = (string) (((float) substr($arrayValue, 0, -2))); } else { $arrayValue = (new CssDimension($arrayValue))->toUnit(CssDimension::UOM_PIXELS); } } elseif ($arrayKey === 'height') { - if (substr($arrayValue, -2) === 'px') { + if (str_ends_with($arrayValue, 'px')) { $arrayValue = substr($arrayValue, 0, -2); } else { $arrayValue = (new CssDimension($arrayValue))->toUnit(CssDimension::UOM_PIXELS); diff --git a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index e4da44f31..7b4e10431 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -64,7 +64,7 @@ class XmlScanner private function findCharSet(string $xml): string { - if (substr($xml, 0, 4) === "\x4c\x6f\xa7\x94") { + if (str_starts_with($xml, "\x4c\x6f\xa7\x94")) { throw new Reader\Exception('EBCDIC encoding not permitted'); } $encoding = Reader\Csv::guessEncodingBom('', $xml); diff --git a/src/PhpSpreadsheet/Reader/Xls/Biff8.php b/src/PhpSpreadsheet/Reader/Xls/Biff8.php index 2de9fb8c3..6bb84725c 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Biff8.php +++ b/src/PhpSpreadsheet/Reader/Xls/Biff8.php @@ -241,7 +241,7 @@ class Biff8 extends Xls */ protected static function readBIFF8CellRangeAddress(string $subData): string { - // todo: if cell range is just a single cell, should this funciton + // todo: if cell range is just a single cell, should this function // not just return e.g. 'A1' and not 'A1:A1' ? // offset: 0; size: 2; index to first row (0... 65535) (or offset (-32768... 32767)) @@ -297,7 +297,7 @@ class Biff8 extends Xls [$baseCol, $baseRow] = Coordinate::indexesFromString($baseCell); $baseCol = $baseCol - 1; - // TODO: if cell range is just a single cell, should this funciton + // TODO: if cell range is just a single cell, should this function // not just return e.g. 'A1' and not 'A1:A1' ? // offset: 0; size: 2; first row diff --git a/src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php b/src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php index 5c27b0cc3..85adc7fe0 100644 --- a/src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php +++ b/src/PhpSpreadsheet/Reader/Xls/LoadSpreadsheet.php @@ -34,10 +34,10 @@ class LoadSpreadsheet extends Xls $xls->spreadsheet->removeCellXfByIndex(0); // remove the default style } - // Read the summary information stream (containing meta data) + // Read the summary information stream (containing metadata) $xls->readSummaryInformation(); - // Read the Additional document summary information stream (containing application-specific meta data) + // Read the Additional document summary information stream (containing application-specific metadata) $xls->readDocumentSummaryInformation(); // total byte size of Excel data (workbook global substream + sheet substreams) @@ -490,7 +490,7 @@ class LoadSpreadsheet extends Xls // If there is no BSE Index, we will fail here and other fields are not read. // Fix by checking here. // TODO: Why is there no BSE Index? Is this a new Office Version? Password protected field? - // More likely : a uncompatible picture + // More likely: an incompatible picture if (!$BSEindex) { continue 2; } diff --git a/src/PhpSpreadsheet/Reader/Xls/RC4.php b/src/PhpSpreadsheet/Reader/Xls/RC4.php index 663f36723..a880eeeaf 100644 --- a/src/PhpSpreadsheet/Reader/Xls/RC4.php +++ b/src/PhpSpreadsheet/Reader/Xls/RC4.php @@ -12,7 +12,7 @@ class RC4 protected int $j = 0; /** - * RC4 stream decryption/encryption constrcutor. + * RC4 stream decryption/encryption constructor. * * @param string $key Encryption key/passphrase */ diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 829f81fe3..2ae91dd6d 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -2430,7 +2430,7 @@ class Xlsx extends BaseReader $attrs = $rel->attributes() ?? []; $rid = (string) ($attrs['Id'] ?? ''); $target = (string) ($attrs['Target'] ?? ''); - if ($rid === $id && substr($target, 0, 2) === '..') { + if ($rid === $id && str_starts_with($target, '..')) { $target = 'xl' . substr($target, 2); $content = $this->getFromZipArchive($this->zip, $target); $docSheet->setBackgroundImage($content); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php b/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php index 429efb089..10f26e954 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php @@ -56,7 +56,7 @@ class WorkbookView /** * Convert an 'xsd:boolean' XML value to a PHP boolean value. * A valid 'xsd:boolean' XML value can be one of the following - * four values: 'true', 'false', '1', '0'. It is case sensitive. + * four values: 'true', 'false', '1', '0'. It is case-sensitive. * * Note that just doing '(bool) $xsdBoolean' is not safe, * since '(bool) "false"' returns true. diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index be6539806..65cb5e61b 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -330,15 +330,37 @@ class ReferenceHelper protected function adjustProtectedCells(Worksheet $worksheet, int $numberOfColumns, int $numberOfRows): void { $aProtectedCells = $worksheet->getProtectedCellRanges(); - ($numberOfColumns > 0 || $numberOfRows > 0) - ? uksort($aProtectedCells, [self::class, 'cellReverseSort']) - : uksort($aProtectedCells, [self::class, 'cellSort']); - foreach ($aProtectedCells as $cellAddress => $protectedRange) { - $newReference = $this->updateCellReference($cellAddress); - if ($cellAddress !== $newReference) { - $worksheet->unprotectCells($cellAddress); - if ($newReference) { - $worksheet->protectCells($newReference, $protectedRange->getPassword(), true); + /** @var CellReferenceHelper */ + $cellReferenceHelper = $this->cellReferenceHelper; + if ($numberOfRows >= 0 && $numberOfColumns >= 0) { + foreach ($aProtectedCells as $key2 => $value) { + $ranges = $value->allRanges(); + $newKey = $separator = ''; + foreach ($ranges as $key => $range) { + $oldKey = $range[0] . (array_key_exists(1, $range) ? (':' . $range[1]) : ''); + $newKey .= $separator . $this->updateCellReference($oldKey); + $separator = ' '; + } + if ($key2 !== $newKey) { + $worksheet->unprotectCells($key2); + $worksheet->protectCells($newKey, $value->getPassword(), true, $value->getName(), $value->getSecurityDescriptor()); + } + } + } else { + foreach ($aProtectedCells as $key2 => $value) { + $range = str_replace([' ', ',', "\0"], ["\0", ' ', ','], $key2); + $extracted = Coordinate::extractAllCellReferencesInRange($range); + $outArray = []; + foreach ($extracted as $cellAddress) { + if (!$cellReferenceHelper->cellAddressInDeleteRange($cellAddress)) { + $outArray[$this->updateCellReference($cellAddress)] = 'x'; + } + } + $outArray2 = Coordinate::mergeRangesInCollection($outArray); + $newKey = implode(' ', array_keys($outArray2)); + if ($key2 !== $newKey) { + $worksheet->unprotectCells($key2); + $worksheet->protectCells($newKey, $value->getPassword(), true, $value->getName(), $value->getSecurityDescriptor()); } } } diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php index de6529c5c..540e96ca1 100644 --- a/src/PhpSpreadsheet/Shared/CodePage.php +++ b/src/PhpSpreadsheet/Shared/CodePage.php @@ -78,7 +78,7 @@ class CodePage * Convert Microsoft Code Page Identifier to Code Page Name which iconv * and mbstring understands. * - * @param int $codePage Microsoft Code Page Indentifier + * @param int $codePage Microsoft Code Page Identifier * * @return string Code Page Name */ diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 3dc16964b..d30f0ed94 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -11,6 +11,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; +use Throwable; class Date { @@ -376,15 +377,18 @@ class Date $cell->getCalculatedValue() ); } - $result = is_numeric($value) - && self::isDateTimeFormat( + if (is_numeric($value)) { + $result = self::isDateTimeFormat( $worksheet->getStyle( $cell->getCoordinate() )->getNumberFormat(), $dateWithoutTimeOkay ); - } catch (Exception) { - // Result is already false, so no need to actually do anything here + /** @var float|int $value */ + self::excelToDateTimeObject($value); + } + } catch (Throwable) { + $result = false; } $worksheet->setSelectedCells($selected); $spreadsheet->setActiveSheetIndex($index); diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php index e5d831fa7..f7053dd07 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php @@ -34,7 +34,7 @@ class DggContainer private array $OPT = []; /** - * Array of identifier clusters containg information about the maximum shape identifiers. + * Array of identifier clusters containing information about the maximum shape identifiers. * * @var mixed[] */ diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index 09a3acebc..fa9224671 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -509,7 +509,7 @@ class OLE } $dateTime = Date::dateTimeFromTimestamp("$date"); - // days from 1-1-1601 until the beggining of UNIX era + // days from 1-1-1601 until the beginning of UNIX era $days = 134774; // calculate seconds $big_date = $days * 24 * 3600 + (float) $dateTime->format('U'); diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index eb03f8c1f..c92deb5ad 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -131,7 +131,7 @@ class Root extends PPS } /** - * Helper function for caculating a magic value for block sizes. + * Helper function for calculating a magic value for block sizes. * * @param int $i2 The argument * diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index aa4224b82..5d38e9564 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -231,7 +231,7 @@ class OLERead { $offset = 0; - // loop through entires, each entry is 128 bytes + // loop through entries, each entry is 128 bytes $entryLen = strlen($this->entry); while ($offset < $entryLen) { // entry data (128 bytes) diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index 6398b613b..f6cb4f9e9 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -250,7 +250,7 @@ class StringHelper private static ?string $currencyCode = null; /** - * Is iconv extension avalable? + * Is iconv extension available? */ private static ?bool $isIconvEnabled = null; diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 5681e4aaa..42504adb8 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -17,7 +17,7 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class Spreadsheet implements JsonSerializable { - // Allowable values for workbook window visilbity + // Allowable values for workbook window visibility const VISIBILITY_VISIBLE = 'visible'; const VISIBILITY_HIDDEN = 'hidden'; const VISIBILITY_VERY_HIDDEN = 'veryHidden'; @@ -107,14 +107,14 @@ class Spreadsheet implements JsonSerializable private ?string $macrosCertificate = null; /** - * ribbonXMLData : null if workbook is'nt Excel 2007 or not contain a customized UI. + * ribbonXMLData : null if workbook isn't Excel 2007 or not contain a customized UI. * * @var null|array{target: string, data: string} */ private ?array $ribbonXMLData = null; /** - * ribbonBinObjects : null if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements + * ribbonBinObjects : null if workbook isn't Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements * ignored if $ribbonXMLData is null. * * @var null|mixed[] @@ -152,7 +152,7 @@ class Spreadsheet implements JsonSerializable /** * Specifies a boolean value that indicates whether to group dates - * when presenting the user with filtering optiomd in the user + * when presenting the user with filtering options in the user * interface. */ private bool $autoFilterDateGrouping = true; @@ -405,7 +405,7 @@ class Spreadsheet implements JsonSerializable } /** - * This workbook have additionnal object for the ribbon ? + * This workbook have additional object for the ribbon ? */ public function hasRibbonBinObjects(): bool { @@ -1146,7 +1146,7 @@ class Spreadsheet implements JsonSerializable $this->uniqueID = uniqid('', true); $usedKeys = []; - // I don't now why new Style rather than clone. + // I don't know why new Style rather than clone. $this->cellXfSupervisor = new Style(true); //$this->cellXfSupervisor = clone $this->cellXfSupervisor; $this->cellXfSupervisor->bindParent($this); @@ -1559,7 +1559,7 @@ class Spreadsheet implements JsonSerializable /** * Return whether to group dates when presenting the user with - * filtering optiomd in the user interface. + * filtering options in the user interface. * * @return bool true if workbook window is minimized */ @@ -1570,7 +1570,7 @@ class Spreadsheet implements JsonSerializable /** * Set whether to group dates when presenting the user with - * filtering optiomd in the user interface. + * filtering options in the user interface. * * @param bool $autoFilterDateGrouping true if workbook window is minimized */ diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 6ff44e3ef..7d3eb44b5 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -58,7 +58,7 @@ class Alignment extends Supervisor self::VERTICAL_CENTER => self::VERTICAL_CENTER, self::VERTICAL_JUSTIFY => self::VERTICAL_JUSTIFY, self::VERTICAL_DISTRIBUTED => self::VERTICAL_DISTRIBUTED, - // css settings that arent't in sync with Excel + // css settings that aren't in sync with Excel self::VERTICAL_BASELINE => self::VERTICAL_BOTTOM, self::VERTICAL_MIDDLE => self::VERTICAL_CENTER, self::VERTICAL_SUB => self::VERTICAL_BOTTOM, @@ -74,7 +74,7 @@ class Alignment extends Supervisor self::VERTICAL_CENTER => self::VERTICAL_MIDDLE, self::VERTICAL_JUSTIFY => self::VERTICAL_MIDDLE, self::VERTICAL_DISTRIBUTED => self::VERTICAL_MIDDLE, - // css settings that arent't in sync with Excel + // css settings that aren't in sync with Excel self::VERTICAL_BASELINE => self::VERTICAL_BASELINE, self::VERTICAL_MIDDLE => self::VERTICAL_MIDDLE, self::VERTICAL_SUB => self::VERTICAL_SUB, diff --git a/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php index 663088859..8b87062aa 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php @@ -3,6 +3,8 @@ namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Shared\Date; +use PhpOffice\PhpSpreadsheet\Shared\StringHelper; +use Throwable; class DateFormatter { @@ -161,7 +163,11 @@ class DateFormatter $callback = [self::class, 'escapeQuotesCallback']; $format = (string) preg_replace_callback('/"(.*)"/U', $callback, $format); - $dateObj = Date::excelToDateTimeObject($value); + try { + $dateObj = Date::excelToDateTimeObject($value); + } catch (Throwable) { + return StringHelper::convertToString($value); + } // If the colon preceding minute had been quoted, as happens in // Excel 2003 XML formats, m will not have been changed to i above. // Change it now. diff --git a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php index 82f2028ba..aba75f4b9 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php @@ -181,7 +181,7 @@ class Formatter extends BaseFormatter // Convert any other escaped characters to quoted strings, e.g. (\T to "T") $format = (string) preg_replace('/(\\\(((.)(?!((AM\/PM)|(A\/P))))|([^ ])))(?=(?:[^"]|"[^"]*")*$)/ui', '"${2}"', $format); - // Get the sections, there can be up to four sections, separated with a semi-colon (but only if not a quoted literal) + // Get the sections, there can be up to four sections, separated with a semicolon (but only if not a quoted literal) $sections = preg_split(self::SECTION_SPLIT, $format) ?: []; [$colors, $format, $value] = self::splitFormatForSectionSelection($sections, $value); diff --git a/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php index 7efcf2112..f869d0736 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php @@ -148,7 +148,7 @@ class NumberFormatter extends BaseFormatter $dec = $matches[2]; $right = $matches[3]; - // minimun width of formatted number (including dot) + // minimum width of formatted number (including dot) $minWidth = strlen($left) + strlen($dec) + strlen($right); if ($useThousands) { $value = number_format( diff --git a/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php index bb5b35549..3c0575b63 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php @@ -32,7 +32,7 @@ class PercentageFormatter extends BaseFormatter } // Number of digits to display before the decimal if (preg_match('/([#0,]+)\.?/u', $format, $matches)) { - $firstZero = preg_replace('/^[#,]*/', '', $matches[1]) ?? ''; + $firstZero = ltrim($matches[1], '#,'); $wholePartSize = max($wholePartSize, strlen($firstZero)); } diff --git a/src/PhpSpreadsheet/Style/RgbTint.php b/src/PhpSpreadsheet/Style/RgbTint.php index 07d0d77c9..db51f30f8 100644 --- a/src/PhpSpreadsheet/Style/RgbTint.php +++ b/src/PhpSpreadsheet/Style/RgbTint.php @@ -16,7 +16,7 @@ class RgbTint private const TWO_THIRD = 2.0 / 3.0; private const RGBMAX = 255.0; /** - * MS excel's tint function expects that HLS is base 240. + * MS Excel's tint function expects that HLS is base 240. * * @see https://social.msdn.microsoft.com/Forums/en-US/e9d8c136-6d62-4098-9b1b-dac786149f43/excel-color-tint-algorithm-incorrect?forum=os_binaryfile#d3c2ac95-52e0-476b-86f1-e2a697f24969 */ diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 9074288a2..273e8483a 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -15,6 +15,7 @@ use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Shared\Date; use PhpOffice\PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule; use Stringable; +use Throwable; class AutoFilter implements Stringable { @@ -215,7 +216,7 @@ class AutoFilter implements Stringable } /** - * Get a specified AutoFilter Column by it's offset. + * Get a specified AutoFilter Column by its offset. * * @param int $columnOffset Column offset within range (starting from 0) */ @@ -339,7 +340,12 @@ class AutoFilter implements Stringable $timeZone = new DateTimeZone('UTC'); if (is_numeric($cellValue)) { - $dateTime = Date::excelToDateTimeObject((float) $cellValue, $timeZone); + try { + $dateTime = Date::excelToDateTimeObject((float) $cellValue, $timeZone); + } catch (Throwable) { + return false; + } + $cellValue = (float) $cellValue; if ($cellValue < 1) { // Just the time part @@ -489,7 +495,12 @@ class AutoFilter implements Stringable } if (is_numeric($cellValue)) { - $dateObject = Date::excelToDateTimeObject((float) $cellValue, new DateTimeZone('UTC')); + try { + $dateObject = Date::excelToDateTimeObject((float) $cellValue, new DateTimeZone('UTC')); + } catch (Throwable) { + return false; + } + $dateValue = (int) $dateObject->format('m'); if (in_array($dateValue, $monthSet)) { return true; @@ -1088,7 +1099,7 @@ class AutoFilter implements Stringable foreach ($value as $k => $v) { $this->{$key}[$k] = clone $v; //* @phpstan-ignore-line // attach the new cloned Column to this new cloned Autofilter object - $this->{$key}[$k]->setParent($this); + $this->{$key}[$k]->setParent($this); //* @phpstan-ignore-line } } else { $this->{$key} = $value; diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index 441204ca6..fa9768d9e 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -158,7 +158,7 @@ class Rule self::AUTOFILTER_COLUMN_RULE_TOPTEN_BOTTOM, ]; - // Unimplented Rule Operators (Numeric, Boolean etc) + // Unimplemented Rule Operators (Numeric, Boolean etc) // const AUTOFILTER_COLUMN_RULE_BETWEEN = 'between'; // greaterThanOrEqual 1 && lessThanOrEqual 2 // Rule Operators (Numeric Special) which are translated to standard numeric operators with calculated values // Rule Operators (String) which are set as wild-carded values @@ -357,7 +357,7 @@ class Rule $this->setValue($value); // Only set grouping if it's been passed in as a user-supplied argument, // otherwise we're calculating it when we setValue() and don't want to overwrite that - // If the user supplies an argumnet for grouping, then on their own head be it + // If the user supplies an argument for grouping, then on their own head be it if ($grouping !== null) { $this->setGrouping($grouping); } diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index 213351426..99a04573b 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -222,7 +222,7 @@ class Drawing extends BaseDrawing } /** - * Get Image file extention for Save. + * Get Image file extension for Save. */ public function getImageFileExtensionForSave(bool $includeDot = true): string { diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index 787b00fd2..e20f90494 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -30,7 +30,7 @@ namespace PhpOffice\PhpSpreadsheet\Worksheet; * &font size - code for "text font size", where font size is a font size in points. * &K - code for "text font color" * RGB Color is specified as RRGGBB - * Theme Color is specifed as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade + * Theme Color is specified as TTSNN where TT is the theme color Id, S is either "+" or "-" of the tint/shade * value, NN is the tint/shade value. * &S - code for "text strikethrough" on / off * &X - code for "text super script" on / off diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 4c6a53918..db23eac7b 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -576,7 +576,7 @@ class PageSetup * Get print area. * * @param int $index Identifier for a specific print area range if several ranges have been set - * Default behaviour, or a index value of 0, will return all ranges as a comma-separated string + * Default behaviour, or an index value of 0, will return all ranges as a comma-separated string * Otherwise, the specific range identified by the value of $index will be returned * Print areas are numbered from 1 */ @@ -642,7 +642,7 @@ class PageSetup * @param int $index Identifier for a specific print area range allowing several ranges to be set * When the method is "O"verwrite, then a positive integer index will overwrite that indexed * entry in the print areas list; a negative index value will identify which entry to - * overwrite working bacward through the print area to the list, with the last entry as -1. + * overwrite working backward through the print area to the list, with the last entry as -1. * Specifying an index value of 0, will overwrite all existing print ranges. * When the method is "I"nsert, then a positive index will insert after that indexed entry in * the print areas list, while a negative index will insert before the indexed entry. diff --git a/src/PhpSpreadsheet/Worksheet/Table.php b/src/PhpSpreadsheet/Worksheet/Table.php index 072beab2d..08d1641bd 100644 --- a/src/PhpSpreadsheet/Worksheet/Table.php +++ b/src/PhpSpreadsheet/Worksheet/Table.php @@ -420,7 +420,7 @@ class Table implements Stringable } /** - * Get a specified Table Column by it's offset. + * Get a specified Table Column by its offset. * * @param int $columnOffset Column offset within range (starting from 0) */ @@ -477,7 +477,7 @@ class Table implements Stringable } /** - * Shift an Table Column Rule to a different column. + * Shift a Table Column Rule to a different column. * * Note: This method bypasses validation of the destination column to ensure it is within this Table range. * Nor does it verify whether any column rule already exists at $toColumn, but will simply override any existing value. diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 64c4ec23a..3defaea16 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -3411,7 +3411,7 @@ class Worksheet public static function unApostrophizeTitle(?string $title): string { $title ??= ''; - if ($title[0] === "'" && substr($title, -1) === "'") { + if (str_starts_with($title, "'") && str_ends_with($title, "'")) { $title = str_replace("''", "'", substr($title, 1, -1)); } diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 0ec8aa472..4de9bb7ff 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -95,7 +95,7 @@ class Csv extends BaseWriter $this->setUseBOM(true); // Enforce UTF-8 BOM Header $this->setIncludeSeparatorLine(true); // Set separator line $this->setEnclosure('"'); // Set enclosure to " - $this->setDelimiter(';'); // Set delimiter to a semi-colon + $this->setDelimiter(';'); // Set delimiter to a semicolon $this->setLineEnding("\r\n"); } @@ -251,9 +251,9 @@ class Csv extends BaseWriter return $this->outputEncoding; } - public function setOutputEncoding(string $outputEnconding): self + public function setOutputEncoding(string $outputEncoding): self { - $this->outputEncoding = $outputEnconding; + $this->outputEncoding = $outputEncoding; return $this; } diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index ecf79d806..4ff5cff48 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -511,6 +511,14 @@ class Html extends BaseWriter return [$cellType, $startTag, $endTag]; } + private int $printAreaLowRow = -1; + + private int $printAreaHighRow = -1; + + private int $printAreaLowCol = -1; + + private int $printAreaHighCol = -1; + /** * Generate sheet data. */ @@ -529,6 +537,17 @@ class Html extends BaseWriter $activeSheet = $this->spreadsheet->getActiveSheetIndex(); foreach ($sheets as $sheet) { + $this->printAreaLowRow = -1; + $this->printAreaHighRow = -1; + $this->printAreaLowCol = -1; + $this->printAreaHighCol = -1; + $printArea = $sheet->getPageSetup()->getPrintArea(); + if (Preg::isMatch('/^([a-z]+)([0-9]+):([a-z]+)([0-9]+)$/i', $printArea, $matches)) { + $this->printAreaLowCol = Coordinate::columnIndexFromString($matches[1]); + $this->printAreaHighCol = Coordinate::columnIndexFromString($matches[3]); + $this->printAreaLowRow = (int) $matches[2]; + $this->printAreaHighRow = (int) $matches[4]; + } // save active cells $selectedCells = $sheet->getSelectedCells(); // Write table header @@ -745,7 +764,7 @@ class Html extends BaseWriter $dataUri = 'data:image/png;base64,' . base64_encode($contents); // Because of the nature of tables, width is more important than height. - // max-width: 100% ensures that image doesnt overflow containing cell + // max-width: 100% ensures that image doesn't overflow containing cell // However, PR #3535 broke test // 25_In_memory_image, apparently because // of the use of max-with. In addition, @@ -1308,16 +1327,18 @@ class Html extends BaseWriter $float = $this->getFloat($worksheet); $prntgrid = $worksheet->getPrintGridlines(); $viewgrid = $this->isPdf ? $prntgrid : $worksheet->getShowGridlines(); + $printArea = $worksheet->getPageSetup()->getPrintArea(); + $dataPrint = ($printArea === '') ? '' : (" data-printarea='" . htmlspecialchars($printArea) . "'"); if ($viewgrid && $prntgrid) { - $html = " " . PHP_EOL; + $html = "
" . PHP_EOL; } elseif ($viewgrid) { - $html = "
" . PHP_EOL; + $html = "
" . PHP_EOL; } elseif ($prntgrid) { - $html = "
" . PHP_EOL; + $html = "
" . PHP_EOL; } elseif ($float === '') { - $html = "
" . PHP_EOL; + $html = "
" . PHP_EOL; } else { - $html = "
" . PHP_EOL; + $html = "
" . PHP_EOL; } return $html; @@ -1327,10 +1348,12 @@ class Html extends BaseWriter { if (!$this->useInlineCss) { $rtl = $this->getDir($worksheet); + $printArea = $worksheet->getPageSetup()->getPrintArea(); + $dataPrint = ($printArea === '') ? '' : (" data-printarea='" . htmlspecialchars($printArea) . "'"); $float = $this->getFloat($worksheet); $gridlines = $worksheet->getShowGridlines() ? ' gridlines' : ''; $gridlinesp = $worksheet->getPrintGridlines() ? ' gridlinesp' : ''; - $html .= "
" . PHP_EOL; + $html .= "
" . PHP_EOL; } else { $html .= $this->generateTableTagInline($worksheet, $id); } @@ -1797,7 +1820,7 @@ class Html extends BaseWriter $colNum = $key - 1; if (!$tcpdfInited && $key !== 1) { $tempspan = ($colNum > 1) ? " colspan='$colNum'" : ''; - $html .= "\n"; + $html .= "" . PHP_EOL; } $tcpdfInited = true; } @@ -1873,17 +1896,11 @@ class Html extends BaseWriter return $html; } - /** @param string[] $matches */ - private static function replaceNonAscii(array $matches): string - { - return '&#' . mb_ord($matches[0], 'UTF-8') . ';'; - } - private static function replaceControlChars(string $convert): string { - return (string) preg_replace_callback( + return Preg::replaceCallback( '/[\x00-\x1f]/', - [self::class, 'replaceNonAscii'], + fn (array $matches) => '&#' . ord($matches[0]) . ';', $convert ); } @@ -2199,6 +2216,9 @@ class Html extends BaseWriter $htmlPage .= 'size: portrait; '; } $htmlPage .= '}' . PHP_EOL; + if (!$this->isPdf) { + $htmlPage .= $this->printAreaStyles($sheetId, $worksheet); + } ++$sheetId; } $htmlPage .= implode(PHP_EOL, [ @@ -2223,8 +2243,44 @@ class Html extends BaseWriter return $htmlPage; } + private function printAreaStyles(int $sheetId, Worksheet $worksheet): string + { + $retVal = ''; + $printArea = $worksheet->getPageSetup()->getPrintArea(); + if (Preg::isMatch('/^([a-z]+)([0-9]+):([a-z]+)([0-9]+)$/i', $printArea, $matches)) { + $lowCol = Coordinate::columnIndexFromString($matches[1]) - 1; + $highCol = Coordinate::columnIndexFromString($matches[3]) - 1; + $lowRow = (int) $matches[2] - 1; + $highRow = (int) $matches[4] - 1; + $retVal = '@media print {' . PHP_EOL; + $highDataRow = $worksheet->getHighestDataRow(); + for ($row = 0; $row < $highDataRow; ++$row) { + if ($row < $lowRow || $row > $highRow) { + $retVal .= " table.sheet$sheetId tr.row$row td { display:none }" . PHP_EOL; + } + } + $highDataColumn = $worksheet->getHighestDataColumn(); + $highDataCol = Coordinate::columnIndexFromString($highDataColumn); + for ($col = 0; $col < $highDataCol; ++$col) { + if ($col < $lowCol || $col > $highCol) { + $retVal .= " table.sheet$sheetId td.column$col { display:none }" . PHP_EOL; + } + } + $retVal .= '}' . PHP_EOL; + } + + return $retVal; + } + private function shouldGenerateRow(Worksheet $sheet, int $row): bool { + if ($this->isPdf) { + if ($this->printAreaLowRow >= 0) { + if ($row < $this->printAreaLowRow || $row > $this->printAreaHighRow) { + return false; + } + } + } if (!($this instanceof Pdf\Mpdf || $this instanceof Pdf\Tcpdf)) { return true; } @@ -2234,6 +2290,14 @@ class Html extends BaseWriter private function shouldGenerateColumn(Worksheet $sheet, string $colStr): bool { + if ($this->isPdf) { + if ($this->printAreaLowCol >= 0) { + $col = Coordinate::columnIndexFromString($colStr); + if ($col < $this->printAreaLowCol || $col > $this->printAreaHighCol) { + return false; + } + } + } if (!($this instanceof Pdf\Mpdf || $this instanceof Pdf\Tcpdf)) { return true; } diff --git a/src/PhpSpreadsheet/Writer/Ods/Formula.php b/src/PhpSpreadsheet/Writer/Ods/Formula.php index 0e470b610..a11ce5f05 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Formula.php +++ b/src/PhpSpreadsheet/Writer/Ods/Formula.php @@ -76,7 +76,7 @@ class Formula $columns = $splitRanges[6]; $rows = $splitRanges[7]; - // Replace any commas in the formula with semi-colons for Ods + // Replace any commas in the formula with semicolons for Ods // If by chance there are commas in worksheet names, then they will be "fixed" again in the loop // because we've already extracted worksheet names with our Preg::matchAllWithOffsets() $formula = str_replace(',', ';', $formula); diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 3ef9bec9b..41f54460e 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -128,7 +128,7 @@ class Xls extends BaseWriter $this->writerWorksheets[$i] = new Worksheet($this->strTotal, $this->strUnique, $this->strTable, $this->colors, $this->parser, $this->preCalculateFormulas, $this->spreadsheet->getSheet($i), $this->writerWorkbook); } - // build Escher objects. Escher objects for workbooks needs to be build before Escher object for workbook. + // build Escher objects. Escher objects for worksheets need to be built before Escher object for workbook. $this->buildWorksheetEschers(); $this->buildWorkbookEscher(); @@ -144,7 +144,7 @@ class Xls extends BaseWriter $this->writerWorkbook->addXfWriter($style, false); } - // add fonts from rich text eleemnts + // add fonts from rich text elements for ($i = 0; $i < $countSheets; ++$i) { foreach ($this->writerWorksheets[$i]->phpSheet->getCellCollection()->getCoordinates() as $coordinate) { /** @var Cell $cell */ @@ -339,7 +339,7 @@ class Xls extends BaseWriter while ($iInc <= $iNumColEnd) { ++$countShapes[$sheetIndex]; - // create an Drawing Object for the dropdown + // create a Drawing Object for the dropdown $oDrawing = new BaseDrawing(); // get the coordinates of drawing $cDrawing = Coordinate::stringFromColumnIndex($iInc) . $rangeBounds[0][1]; @@ -698,7 +698,7 @@ class Xls extends BaseWriter // value $dataProp .= 'Feuilles de calcul'; // vtUnalignedString - headingParts - // wType : 0x0003 = 32 bit signed integer + // wType : 0x0003 = 32-bit signed integer $dataProp .= pack('v', 0x0300); // padding $dataProp .= pack('v', 0x0000); diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index 55a530e6c..9a51c3f10 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -219,7 +219,7 @@ class Parser * The following hash was generated by "function_locale.pl" in the distro. * Refer to function_locale.pl for non-English function names. * - * The array elements are as follow: + * The array elements are as follows: * ptg: The Excel function ptg code. * args: The number of arguments that the function takes: * >=0 is a fixed number of arguments. @@ -1262,7 +1262,7 @@ class Parser } /** - * It parses a expression. It assumes the following rule: + * It parses an expression. It assumes the following rule: * Expr -> Term [("+" | "-") Term] * -> "string" * -> "-" Term : Negative value @@ -1622,7 +1622,7 @@ class Parser $converted_tree = $this->convert(StringHelper::convertToString($tree['right'])); $polish .= $converted_tree; } - // if it's a function convert it here (so we can set it's arguments) + // if it's a function convert it here (so we can set its arguments) /** @var string */ $treeValueString = $tree['value']; if ( diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index 4e0bf3edd..d1300f13d 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -551,7 +551,7 @@ class Workbook extends BIFFwriter if (empty($worksheet)) { if (($offset === 0) || ($definedRange[$offset - 1] !== ':')) { // We should have a worksheet - $worksheet = $definedName->getWorksheet() ? $definedName->getWorksheet()->getTitle() : null; + $worksheet = $definedName->getWorksheet()?->getTitle(); } } else { $worksheet = str_replace("''", "'", trim($worksheet, "'")); @@ -1116,7 +1116,7 @@ class Workbook extends BIFFwriter // combine into one chunk with all the blocks SST, CONTINUE,... $chunk = ''; foreach ($recordDatas as $i => $recordData) { - // first block should have the SST record header, remaing should have CONTINUE header + // first block should have the SST record header, remaining should have CONTINUE header $record = ($i == 0) ? 0x00FC : 0x003C; $header = pack('vv', $record, strlen($recordData)); diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 810abe9c4..494593d77 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -282,7 +282,7 @@ class Worksheet extends BIFFwriter // $lastcol last column on the range // $width width to set // $xfIndex The optional cell style Xf index to apply to the columns - // $hidden The optional hidden atribute + // $hidden The optional hidden attribute // $level The optional outline level $this->columnInfo[] = [$i, $i, $width, $xfIndex, $hidden, $level]; } @@ -2316,7 +2316,7 @@ class Worksheet extends BIFFwriter } /** - * Store the OBJ record that precedes an IMDATA record. This could be generalise + * Store the OBJ record that precedes an IMDATA record. This could be generalised * to support other Excel objects. * * @param int $colL Column containing upper left corner of object diff --git a/src/PhpSpreadsheet/Writer/Xls/Xf.php b/src/PhpSpreadsheet/Writer/Xls/Xf.php index bda33ed36..3e97260f6 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -219,7 +219,7 @@ class Xf $header = pack('vv', $record, $length); - //BIFF8 options: identation, shrinkToFit and text direction + //BIFF8 options: indentation, shrinkToFit and text direction $biff8_options = $this->style->getAlignment()->getIndent() & 15; $biff8_options |= (int) $this->style->getAlignment()->getShrinkToFit() << 4; $biff8_options |= $this->style->getAlignment()->getReadOrder() << 6; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index 16c7bb978..843133045 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -185,12 +185,12 @@ class ContentTypes extends WriterPart } $bgImage = $comment->getBackgroundImage(); - $bgImageExtentionKey = strtolower($bgImage->getImageFileExtensionForSave(false)); + $bgImageExtensionKey = strtolower($bgImage->getImageFileExtensionForSave(false)); - if (!isset($aMediaContentTypes[$bgImageExtentionKey])) { - $aMediaContentTypes[$bgImageExtentionKey] = $bgImage->getImageMimeType(); + if (!isset($aMediaContentTypes[$bgImageExtensionKey])) { + $aMediaContentTypes[$bgImageExtensionKey] = $bgImage->getImageMimeType(); - $this->writeDefaultContentType($objWriter, $bgImageExtentionKey, $aMediaContentTypes[$bgImageExtentionKey]); + $this->writeDefaultContentType($objWriter, $bgImageExtensionKey, $aMediaContentTypes[$bgImageExtensionKey]); } } } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index a913767dc..abcb8f262 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -148,7 +148,7 @@ class Rels extends WriterPart Namespaces::VBA, 'vbaProject.bin' ); - ++$i; //increment i if needed for an another relation + ++$i; //increment i if needed for another relation } // Metadata needed for Dynamic Arrays @@ -159,7 +159,7 @@ class Rels extends WriterPart Namespaces::RELATIONSHIPS_METADATA, 'metadata.xml' ); - ++$i; //increment i if needed for an another relation + ++$i; //increment i if needed for another relation } $objWriter->endElement(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php index 14d564d67..5caa3a10c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -33,7 +33,7 @@ class DateDifTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DATEDIF({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -104,7 +104,7 @@ class DateDifTest extends TestCase } else { $formula = "=DATEDIF({$startDate}, {$endDate}, {$methods})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index d31485173..f80e9b649 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -53,7 +53,7 @@ class DateTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DATE({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -144,7 +144,7 @@ class DateTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DATE({$year}, {$month}, {$day})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } @@ -211,7 +211,7 @@ class DateTest extends TestCase $this->expectExceptionMessage('Formulae with more than two array arguments are not supported'); $formula = "=DATE({$year}, {$month}, {$day})"; - $calculation->_calculateFormulaValue($formula); + $calculation->calculateFormula($formula); } public static function providerDateArrayException(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index 0d926f89f..856b4dee8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -78,7 +78,7 @@ class DateValueTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DATEVALUE({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); } @@ -182,7 +182,7 @@ class DateValueTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DATEVALUE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php index a1f4a6de9..04c10c96c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -46,7 +46,7 @@ class DayTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DAY({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResultExcel, $result); } @@ -92,7 +92,7 @@ class DayTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DAY({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResultOpenOffice, $result); } @@ -140,7 +140,7 @@ class DayTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DAY({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php index 6a09c3477..d53215974 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -32,7 +32,7 @@ class Days360Test extends TestCase $calculation = Calculation::getInstance(); $formula = "=DAYS360({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -103,7 +103,7 @@ class Days360Test extends TestCase } else { $formula = "=DAYS360({$startDate}, {$endDate}, {$methods})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php index 18a0ef7d1..3b9d34e96 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -31,7 +31,7 @@ class DaysTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DAYS({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -98,7 +98,7 @@ class DaysTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DAYS({$startDate}, {$endDate})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php index 41c83d7bc..a7697ca03 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EDateTest.php @@ -47,7 +47,7 @@ class EDateTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=EDATE({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -129,7 +129,7 @@ class EDateTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=EDATE({$dateValues}, {$methods})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php index 9cd51cac0..b2c2a5703 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/EoMonthTest.php @@ -47,7 +47,7 @@ class EoMonthTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=EOMONTH({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -128,7 +128,7 @@ class EoMonthTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=EOMONTH({$dateValues}, {$methods})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HelpersTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HelpersTest.php new file mode 100644 index 000000000..4a6c07492 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HelpersTest.php @@ -0,0 +1,19 @@ +expectException(CalcExp::class); + $this->expectExceptionMessage('#VALUE!'); + Helpers::getDateValue($this); + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php index 3f6efdc4a..e8ecc510b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/HourTest.php @@ -29,7 +29,7 @@ class HourTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=HOUR({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -89,7 +89,7 @@ class HourTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=HOUR({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php index 010197ba9..93e434a20 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/IsoWeekNumTest.php @@ -46,7 +46,7 @@ class IsoWeekNumTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=ISOWEEKNUM({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -120,7 +120,7 @@ class IsoWeekNumTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=ISOWEEKNUM({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php index 865e5cbf8..a29c208c4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MinuteTest.php @@ -29,7 +29,7 @@ class MinuteTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=MINUTE({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -89,7 +89,7 @@ class MinuteTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=MINUTE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php index 7dbb2b5ea..68b67ff48 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MonthTest.php @@ -29,7 +29,7 @@ class MonthTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=MONTH({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -89,7 +89,7 @@ class MonthTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=MONTH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php index bb20d0add..1ef880abd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NetworkDaysTest.php @@ -28,7 +28,7 @@ class NetworkDaysTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=NETWORKDAYS({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -93,7 +93,7 @@ class NetworkDaysTest extends TestCase } else { $formula = "=NETWORKDAYS({$startDate}, {$endDays}, {$holidays})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NowTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NowTest.php index c69239157..c26ff3272 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NowTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/NowTest.php @@ -47,7 +47,7 @@ class NowTest extends TestCase do { $dtStart = new DateTimeImmutable(); $startSecond = $dtStart->format('s'); - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); $endSecond = (new DateTimeImmutable('now'))->format('s'); } while ($startSecond !== $endSecond); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php index e59dcba76..c54067cce 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -28,7 +28,7 @@ class SecondTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=SECOND({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -88,7 +88,7 @@ class SecondTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=SECOND({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index b121c35bd..798f10357 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -53,7 +53,7 @@ class TimeTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=TIME({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } @@ -129,7 +129,7 @@ class TimeTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=TIME({$hour}, {$minute}, {$second})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } @@ -196,7 +196,7 @@ class TimeTest extends TestCase $this->expectExceptionMessage('Formulae with more than two array arguments are not supported'); $formula = "=TIME({$hour}, {$minute}, {$second})"; - $calculation->_calculateFormulaValue($formula); + $calculation->calculateFormula($formula); } public static function providerTimeArrayException(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index 55370dccb..d53680a12 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -47,7 +47,7 @@ class TimeValueTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=TIMEVALUE({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); } @@ -137,7 +137,7 @@ class TimeValueTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=TIMEVALUE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TodayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TodayTest.php index 006ac6bb9..5d2228277 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TodayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TodayTest.php @@ -47,7 +47,7 @@ class TodayTest extends TestCase do { $dtStart = new DateTimeImmutable(); $startSecond = $dtStart->format('s'); - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); $endSecond = (new DateTimeImmutable('now'))->format('s'); } while ($startSecond !== $endSecond); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php index 51927df65..6880ecb3e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -45,7 +45,7 @@ class WeekDayTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=WEEKDAY({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -114,7 +114,7 @@ class WeekDayTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=WEEKDAY({$dateValues}, {$styles})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php index 4be935efd..e21453e87 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekNumTest.php @@ -46,7 +46,7 @@ class WeekNumTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=WEEKNUM({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -120,7 +120,7 @@ class WeekNumTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=WEEKNUM({$dateValues}, {$methods})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php index d2f39854e..aaf80f89c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WorkDayTest.php @@ -28,7 +28,7 @@ class WorkDayTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=WORKDAY({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -92,7 +92,7 @@ class WorkDayTest extends TestCase } else { $formula = "=WORKDAY({$startDate}, {$endDays}, {$holidays})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php index d12f55070..579631fd2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearFracTest.php @@ -29,7 +29,7 @@ class YearFracTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=YEARFRAC({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-6); } @@ -94,7 +94,7 @@ class YearFracTest extends TestCase } else { $formula = "=YEARFRAC({$startDate}, {$endDate}, {$methods})"; } - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php index 35a423868..7b86b3baa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/YearTest.php @@ -28,7 +28,7 @@ class YearTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=YEAR({$arguments})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } @@ -88,7 +88,7 @@ class YearTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=YEAR({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php index eae76a1a6..e6352bf26 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/ErrorTypeTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class ErrorTypeTest extends TestCase @@ -16,7 +17,7 @@ class ErrorTypeTest extends TestCase self::assertSame(ExcelError::NA(), $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerErrorType')] + #[DataProvider('providerErrorType')] public function testErrorType(int|string $expectedResult, mixed $value): void { $result = ExcelError::type($value); @@ -28,14 +29,14 @@ class ErrorTypeTest extends TestCase return require 'tests/data/Calculation/Information/ERROR_TYPE.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerErrorTypeArray')] + #[DataProvider('providerErrorTypeArray')] public function testErrorTypeArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ERROR.TYPE({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerErrorTypeArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/InfoTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/InfoTest.php new file mode 100644 index 000000000..966cedc9f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/InfoTest.php @@ -0,0 +1,43 @@ +getActiveSheet(); + + $sheet->getCell('A1')->setValue('=INFO("' . $typeText . '")'); + $result = $sheet->getCell('A1')->getCalculatedValue(); + + self::assertSame($expectedResult, $result); + $spreadsheet->disconnectWorksheets(); + } + + public static function providerINFO(): array + { + return require 'tests/data/Calculation/Information/INFO.php'; + } + + public function testINFONumfileWithThreeSheets(): void + { + $spreadsheet = new Spreadsheet(); + $spreadsheet->createSheet(); + $spreadsheet->createSheet(); + $sheet = $spreadsheet->getActiveSheet(); + + $sheet->getCell('A1')->setValue('=INFO("numfile")'); + $result = $sheet->getCell('A1')->getCalculatedValue(); + + self::assertSame(3, $result); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php index 495798fd6..16b529741 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsBlankTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsBlankTest extends TestCase @@ -16,7 +17,7 @@ class IsBlankTest extends TestCase self::assertTrue($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsBlank')] + #[DataProvider('providerIsBlank')] public function testIsBlank(bool $expectedResult, mixed $value): void { $result = Value::isBlank($value); @@ -28,14 +29,14 @@ class IsBlankTest extends TestCase return require 'tests/data/Calculation/Information/IS_BLANK.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsBlankArray')] + #[DataProvider('providerIsBlankArray')] public function testIsBlankArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISBLANK({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsBlankArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php index 5b93149fb..2652276fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsErrTest extends TestCase @@ -16,7 +17,7 @@ class IsErrTest extends TestCase self::assertFalse($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsErr')] + #[DataProvider('providerIsErr')] public function testIsErr(bool $expectedResult, mixed $value): void { $result = ErrorValue::isErr($value); @@ -28,14 +29,14 @@ class IsErrTest extends TestCase return require 'tests/data/Calculation/Information/IS_ERR.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsErrArray')] + #[DataProvider('providerIsErrArray')] public function testIsErrArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISERR({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsErrArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php index 526a379cb..36a841cd4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsErrorTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsErrorTest extends TestCase @@ -16,7 +17,7 @@ class IsErrorTest extends TestCase self::assertFalse($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsError')] + #[DataProvider('providerIsError')] public function testIsError(bool $expectedResult, mixed $value): void { $result = ErrorValue::isError($value); @@ -28,14 +29,14 @@ class IsErrorTest extends TestCase return require 'tests/data/Calculation/Information/IS_ERROR.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsErrorArray')] + #[DataProvider('providerIsErrorArray')] public function testIsErrorArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISERROR({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsErrorArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php index c8293d6df..a081a500b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsEvenTest.php @@ -7,6 +7,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsEvenTest extends TestCase @@ -17,7 +18,7 @@ class IsEvenTest extends TestCase self::assertSame(ExcelError::NAME(), $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsEven')] + #[DataProvider('providerIsEven')] public function testIsEven(bool|string $expectedResult, mixed $value): void { $result = Value::isEven($value); @@ -29,14 +30,14 @@ class IsEvenTest extends TestCase return require 'tests/data/Calculation/Information/IS_EVEN.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsEvenArray')] + #[DataProvider('providerIsEvenArray')] public function testIsEvenArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISEVEN({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsEvenArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php index 2b5e0953c..bfb988b2b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsFormulaTest.php @@ -114,8 +114,8 @@ class IsFormulaTest extends TestCase $calculation = Calculation::getInstance($spreadsheet); $formula = '=ISFORMULA(A1:A7)'; - $result = $calculation->_calculateFormulaValue($formula, 'C1', $sheet->getCell('C1')); - self::assertEquals([true, false, true, false, true, false, false], $result); + $result = $calculation->calculateFormula($formula, 'C1', $sheet->getCell('C1')); + self::assertSame([true, false, true, false, true, false, false], $result); $spreadsheet->disconnectWorksheets(); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php index e00cccb3b..206e12010 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsLogicalTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsLogicalTest extends TestCase @@ -16,7 +17,7 @@ class IsLogicalTest extends TestCase self::assertFalse($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsLogical')] + #[DataProvider('providerIsLogical')] public function testIsLogical(bool $expectedResult, mixed $value): void { $result = Value::isLogical($value); @@ -28,14 +29,14 @@ class IsLogicalTest extends TestCase return require 'tests/data/Calculation/Information/IS_LOGICAL.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsLogicalArray')] + #[DataProvider('providerIsLogicalArray')] public function testIsLogicalArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISLOGICAL({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsLogicalArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php index 72b841367..97f6131c8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNaTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\ErrorValue; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsNaTest extends TestCase @@ -16,7 +17,7 @@ class IsNaTest extends TestCase self::assertFalse($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsNa')] + #[DataProvider('providerIsNa')] public function testIsNa(bool $expectedResult, mixed $value): void { $result = ErrorValue::isNa($value); @@ -28,14 +29,14 @@ class IsNaTest extends TestCase return require 'tests/data/Calculation/Information/IS_NA.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsNaArray')] + #[DataProvider('providerIsNaArray')] public function testIsNaArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISNA({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsNaArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php index c639c93a5..c603fa27a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNonTextTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsNonTextTest extends TestCase @@ -16,7 +17,7 @@ class IsNonTextTest extends TestCase self::assertTrue($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsNonText')] + #[DataProvider('providerIsNonText')] public function testIsNonText(bool $expectedResult, mixed $value): void { $result = Value::isNonText($value); @@ -28,14 +29,14 @@ class IsNonTextTest extends TestCase return require 'tests/data/Calculation/Information/IS_NONTEXT.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsNonTextArray')] + #[DataProvider('providerIsNonTextArray')] public function testIsNonTextArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISNONTEXT({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsNonTextArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php index 180fbc22d..d5cbe286a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsNumberTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsNumberTest extends TestCase @@ -16,7 +17,7 @@ class IsNumberTest extends TestCase self::assertFalse($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsNumber')] + #[DataProvider('providerIsNumber')] public function testIsNumber(bool $expectedResult, mixed $value): void { $result = Value::isNumber($value); @@ -28,14 +29,14 @@ class IsNumberTest extends TestCase return require 'tests/data/Calculation/Information/IS_NUMBER.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsNumberArray')] + #[DataProvider('providerIsNumberArray')] public function testIsNumberArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISNUMBER({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsNumberArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php index 6ff3d6ec3..c493f79e0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsOddTest.php @@ -7,6 +7,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsOddTest extends TestCase @@ -17,7 +18,7 @@ class IsOddTest extends TestCase self::assertSame(ExcelError::NAME(), $result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsOdd')] + #[DataProvider('providerIsOdd')] public function testIsOdd(bool|string $expectedResult, mixed $value): void { $result = Value::isOdd($value); @@ -29,14 +30,14 @@ class IsOddTest extends TestCase return require 'tests/data/Calculation/Information/IS_ODD.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsOddArray')] + #[DataProvider('providerIsOddArray')] public function testIsOddArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISODD({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsOddArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php index f75e2ff17..b42e8278f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/IsTextTest.php @@ -6,6 +6,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Information; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Information\Value; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IsTextTest extends TestCase @@ -16,7 +17,7 @@ class IsTextTest extends TestCase self::assertFalse($result); } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsText')] + #[DataProvider('providerIsText')] public function testIsText(bool $expectedResult, mixed $value): void { $result = Value::isText($value); @@ -28,14 +29,14 @@ class IsTextTest extends TestCase return require 'tests/data/Calculation/Information/IS_TEXT.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIsTextArray')] + #[DataProvider('providerIsTextArray')] public function testIsTextArray(array $expectedResult, string $values): void { $calculation = Calculation::getInstance(); $formula = "=ISTEXT({$values})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIsTextArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php index adb98070d..004e3bd64 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfErrorTest.php @@ -5,10 +5,11 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; +use PHPUnit\Framework\Attributes\DataProvider; class IfErrorTest extends AllSetupTeardown { - #[\PHPUnit\Framework\Attributes\DataProvider('providerIFERROR')] + #[DataProvider('providerIFERROR')] public function testIFERROR(mixed $expectedResult, mixed ...$args): void { $this->runTestCase('IFERROR', $expectedResult, ...$args); @@ -19,14 +20,14 @@ class IfErrorTest extends AllSetupTeardown return require 'tests/data/Calculation/Logical/IFERROR.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIfErrorArray')] + #[DataProvider('providerIfErrorArray')] public function testIfErrorArray(array $expectedResult, string $argument1, string $argument2): void { $calculation = Calculation::getInstance(); $formula = "=IFERROR({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIfErrorArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php index f0fb8fdaa..17cb1fca4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -5,10 +5,11 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; +use PHPUnit\Framework\Attributes\DataProvider; class IfNaTest extends AllSetupTeardown { - #[\PHPUnit\Framework\Attributes\DataProvider('providerIFNA')] + #[DataProvider('providerIFNA')] public function testIFNA(mixed $expectedResult, mixed ...$args): void { $this->runTestCase('IFNA', $expectedResult, ...$args); @@ -19,14 +20,14 @@ class IfNaTest extends AllSetupTeardown return require 'tests/data/Calculation/Logical/IFNA.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIfNaArray')] + #[DataProvider('providerIfNaArray')] public function testIfNaArray(array $expectedResult, string $argument1, string $argument2): void { $calculation = Calculation::getInstance(); $formula = "=IFNA({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIfNaArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php index ff52852d8..0bdef31fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php @@ -5,10 +5,11 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; +use PHPUnit\Framework\Attributes\DataProvider; class IfsTest extends AllSetupTeardown { - #[\PHPUnit\Framework\Attributes\DataProvider('providerIFS')] + #[DataProvider('providerIFS')] public function testIFS(mixed $expectedResult, mixed ...$args): void { $this->runTestCase('IFS', $expectedResult, ...$args); @@ -19,14 +20,14 @@ class IfsTest extends AllSetupTeardown return require 'tests/data/Calculation/Logical/IFS.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIfsArray')] + #[DataProvider('providerIfsArray')] public function testIfsArray(array $expectedResult, string $bool1, string $argument1, string $bool2, string $argument2): void { $calculation = Calculation::getInstance(); $formula = "=IFS($bool1, {" . "$argument1}, $bool2, {" . "$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIfsArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php index a4a071643..a4e9d0349 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -5,10 +5,11 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; +use PHPUnit\Framework\Attributes\DataProvider; class NotTest extends AllSetupTeardown { - #[\PHPUnit\Framework\Attributes\DataProvider('providerNOT')] + #[DataProvider('providerNOT')] public function testNOT(mixed $expectedResult, mixed ...$args): void { $this->runTestCase('NOT', $expectedResult, ...$args); @@ -19,14 +20,14 @@ class NotTest extends AllSetupTeardown return require 'tests/data/Calculation/Logical/NOT.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerNotArray')] + #[DataProvider('providerNotArray')] public function testNotArray(array $expectedResult, string $argument1): void { $calculation = Calculation::getInstance(); $formula = "=NOT({$argument1})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerNotArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php index b1311f38c..f78e41888 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -5,10 +5,11 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; +use PHPUnit\Framework\Attributes\DataProvider; class SwitchTest extends AllSetupTeardown { - #[\PHPUnit\Framework\Attributes\DataProvider('providerSwitch')] + #[DataProvider('providerSwitch')] public function testSWITCH(mixed $expectedResult, mixed ...$args): void { $this->runTestCase('SWITCH', $expectedResult, ...$args); @@ -19,14 +20,14 @@ class SwitchTest extends AllSetupTeardown return require 'tests/data/Calculation/Logical/SWITCH.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerSwitchArray')] + #[DataProvider('providerSwitchArray')] public function testIfsArray(array $expectedResult, int $expression, int $value1, string $result1, int $value2, string $result2, string $default): void { $calculation = Calculation::getInstance(); $formula = "=SWITCH($expression, $value1, {" . "$result1}, $value2, {" . "$result2}, {" . "$default})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerSwitchArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php index 0fa5b2f8d..3795de3e1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressTest.php @@ -6,11 +6,12 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class AddressTest extends TestCase { - #[\PHPUnit\Framework\Attributes\DataProvider('providerADDRESS')] + #[DataProvider('providerADDRESS')] public function testADDRESS(mixed $expectedResult, mixed ...$args): void { $result = LookupRef\Address::cell(...$args); @@ -22,14 +23,14 @@ class AddressTest extends TestCase return require 'tests/data/Calculation/LookupRef/ADDRESS.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerAddressArray')] + #[DataProvider('providerAddressArray')] public function testAddressArray(array $expectedResult, string $argument1, string $argument2): void { $calculation = Calculation::getInstance(); $formula = "=ADDRESS({$argument1}, {$argument2}, 4)"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerAddressArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php index 6301156ff..857495079 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -31,8 +31,8 @@ class ChooseTest extends TestCase $selections = implode(',', $selections); $formula = "=CHOOSE({$values}, {$selections})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerChooseArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php index 4e56896cb..8fac586c6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -30,8 +30,8 @@ class ColumnsTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=COLUMNS({$argument})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerColumnsArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php index 98d325c4f..6fd07cf66 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -109,8 +109,8 @@ class HLookupTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=HLOOKUP({$values}, {$database}, {$index}, false)"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerHLookupArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php index 930bfd8a9..6b08848e4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -7,11 +7,12 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Matrix; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IndexTest extends TestCase { - #[\PHPUnit\Framework\Attributes\DataProvider('providerINDEX')] + #[DataProvider('providerINDEX')] public function testINDEX(mixed $expectedResult, mixed $matrix, mixed $rowNum = null, mixed $colNum = null): void { if ($rowNum === null) { @@ -29,14 +30,14 @@ class IndexTest extends TestCase return require 'tests/data/Calculation/LookupRef/INDEX.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerIndexArray')] + #[DataProvider('providerIndexArray')] public function testIndexArray(array $expectedResult, string $matrix, string $rows, string $columns): void { $calculation = Calculation::getInstance(); $formula = "=INDEX({$matrix}, {$rows}, {$columns})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerIndexArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php index 6e6c67437..8c7d29244 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -7,11 +7,12 @@ namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\LookupRef; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\LookupRef; use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class LookupTest extends TestCase { - #[\PHPUnit\Framework\Attributes\DataProvider('providerLOOKUP')] + #[DataProvider('providerLOOKUP')] public function testLOOKUP(mixed $expectedResult, mixed ...$args): void { $result = LookupRef\Lookup::lookup(...$args); @@ -23,14 +24,14 @@ class LookupTest extends TestCase return require 'tests/data/Calculation/LookupRef/LOOKUP.php'; } - #[\PHPUnit\Framework\Attributes\DataProvider('providerLookupArray')] + #[DataProvider('providerLookupArray')] public function testLookupArray(array $expectedResult, string $values, string $lookup, string $return): void { $calculation = Calculation::getInstance(); $formula = "=LOOKUP({$values}, {$lookup}, {$return})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerLookupArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php index f6b03db1c..6cc30990e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -67,7 +67,7 @@ class MatchTest extends AllSetupTeardown $sheet->getCell('D1')->setValue($formula); $result = $sheet->getCell('D1')->getCalculatedValue(); - self::assertEquals($expectedResult, $result); + self::assertSame($expectedResult, $result); } public static function providerMATCH(): array @@ -81,8 +81,8 @@ class MatchTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=MATCH({$values}, {$selections}, 0)"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerMatchArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php index fc4f61d7d..a78e4dc16 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php @@ -30,8 +30,8 @@ class RowsTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=ROWS({$argument})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerRowsArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php index 612bdb3d1..ef9dde738 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/VLookupTest.php @@ -52,8 +52,8 @@ class VLookupTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=VLOOKUP({$values}, {$database}, {$index}, false)"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEquals($expectedResult, $result); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerVLookupArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php index e3561996f..42ecec72a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php @@ -34,7 +34,7 @@ class AbsTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ABS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php index c4214f587..dc6fd88e8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php @@ -30,7 +30,7 @@ class AcosTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ACOS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php index 9a31fa8d1..5e800e5cf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php @@ -30,7 +30,7 @@ class AcoshTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ACOSH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php index 3b85fff8f..0d04f7ce4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -33,7 +33,7 @@ class AcotTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ACOT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php index 1475d77d2..99e3190d4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -33,7 +33,7 @@ class AcothTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ACOTH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php index 60e108272..9a634dc1b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -30,7 +30,7 @@ class ArabicTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ARABIC({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php index cbf991494..404e139d3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php @@ -30,7 +30,7 @@ class AsinTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ASIN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php index 2795b36a8..fe3df9184 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php @@ -30,7 +30,7 @@ class AsinhTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ASINH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php index bbfa4da2d..8b04672a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -31,7 +31,7 @@ class Atan2Test extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ATAN2({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php index 7c217f81b..ce0455b04 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php @@ -30,7 +30,7 @@ class AtanTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ATAN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php index 3a121aa94..929c66e24 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php @@ -30,7 +30,7 @@ class AtanhTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ATANH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php index a1c5e4e0b..755d4a572 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -46,7 +46,7 @@ class BaseTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=BASE({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php index 78d947e17..5f1276faf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php @@ -33,7 +33,7 @@ class CeilingMathTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CEILING.MATH({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php index 922500c81..d41c1c0e1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php @@ -33,7 +33,7 @@ class CeilingPreciseTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CEILING.PRECISE({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php index 9b16ba786..60d9cde89 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -79,7 +79,7 @@ class CeilingTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CEILING({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php index 0dced2da8..9f148b2ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php @@ -35,7 +35,7 @@ class CombinATest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=COMBINA({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php index ffe44293a..3fab027eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -35,7 +35,7 @@ class CombinTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=COMBIN({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php index 538e2a964..c9c4e9617 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php @@ -30,7 +30,7 @@ class CosTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=COS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php index 40611d754..22f8e440a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php @@ -30,7 +30,7 @@ class CoshTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=COSH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php index c62a76bef..3c95eed7b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -33,7 +33,7 @@ class CotTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=COT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php index 445d97b44..ba7b1050c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -33,7 +33,7 @@ class CothTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=COTH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php index 9e835b503..a2e76008e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -33,7 +33,7 @@ class CscTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CSC({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php index 77237729e..672bde770 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -33,7 +33,7 @@ class CschTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CSCH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php index b6f546266..edbc27f83 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php @@ -34,7 +34,7 @@ class DegreesTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=DEGREES({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php index 653e4d083..3c0896039 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -29,7 +29,7 @@ class EvenTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=EVEN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php index 188acd934..5b231fee5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php @@ -36,7 +36,7 @@ class ExpTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=EXP({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php index 15f8159a2..d1ba0d275 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -30,7 +30,7 @@ class FactDoubleTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FACTDOUBLE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php index 3ff4da971..ef37da211 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -61,7 +61,7 @@ class FactTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FACT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, self::FACT_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php index 5f528cc86..34c0470fa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -33,7 +33,7 @@ class FloorMathTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FLOOR.MATH({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php index 74d3ce406..e4f433342 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -33,7 +33,7 @@ class FloorPreciseTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FLOOR.PRECISE({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php index 75c749f18..8ca3d63c2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -79,7 +79,7 @@ class FloorTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FLOOR({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php index 0e81fcafb..a0b736b26 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -33,7 +33,7 @@ class IntTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=INT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php index 774e2bc83..3da0a18b3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php @@ -36,7 +36,7 @@ class LnTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php index 52635d426..b7385c77c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php @@ -36,7 +36,7 @@ class Log10Test extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LOG10({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php index 62afdd287..5d2b1efe8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -41,7 +41,7 @@ class LogTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LOG({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php index 32020c71f..117444dd0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -33,7 +33,7 @@ class MRoundTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=MROUND({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php index bbedd1f3d..98671f181 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -41,7 +41,7 @@ class ModTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=MOD({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php index a61259643..35b456055 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -29,7 +29,7 @@ class OddTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ODD({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php index abf9f7ef3..f77fa422c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -41,7 +41,7 @@ class PowerTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=POWER({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php index eb5827d5b..7f0d4440e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -41,7 +41,7 @@ class QuotientTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=QUOTIENT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php index 63dfb7fd0..892821c41 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php @@ -34,7 +34,7 @@ class RadiansTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=RADIANS({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php index 9b64991b5..f2fcfbe96 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php @@ -52,7 +52,7 @@ class RandBetweenTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=RandBetween({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertIsArray($result); self::assertCount($expectedRows, $result); self::assertIsArray($result[0]); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php index 57096ac27..2b339e405 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -30,7 +30,7 @@ class RomanTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ROMAN({$values}, {$styles})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php index 7c440df13..05026f485 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -33,7 +33,7 @@ class RoundDownTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ROUNDDOWN({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php index c10c982d1..ad0f0eabc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php @@ -33,7 +33,7 @@ class RoundTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ROUND({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php index d7629357b..3d946bf97 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -33,7 +33,7 @@ class RoundUpTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ROUNDUP({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php index e05c99b8e..343242003 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -33,7 +33,7 @@ class SecTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SEC({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php index d2e4df742..134864b47 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -33,7 +33,7 @@ class SechTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SECH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php index 5f3469f18..53dfeec98 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SeriesSumTest.php @@ -46,7 +46,7 @@ class SeriesSumTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SERIESSUM({$x}, {$n}, {$m}, {$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php index 2a77d6eb3..b15f9ef1a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -32,7 +32,7 @@ class SignTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SIGN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php index ea7881361..ab0ec74e8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php @@ -30,7 +30,7 @@ class SinTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SIN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php index 50b7b32c4..0c5d5ff96 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php @@ -30,7 +30,7 @@ class SinhTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SINH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php index 1aecc8b6e..bd3287035 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -36,7 +36,7 @@ class SqrtPiTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SQRTPI({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php index 4e4fea06c..4a7868c52 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php @@ -34,7 +34,7 @@ class SqrtTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SQRT({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php index b58562c1c..513012205 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php @@ -30,7 +30,7 @@ class TanTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TAN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php index 31f704b22..1a77e2c57 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php @@ -30,7 +30,7 @@ class TanhTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TANH({$array})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php index 31a160794..3e6fe655e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -33,7 +33,7 @@ class TruncTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TRUNC({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php index a50693c00..223004e37 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -25,7 +25,7 @@ class BetaDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=BETADIST({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php index 7550510d1..d3a8a972c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -25,7 +25,7 @@ class BetaInvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=BETAINV({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php index 6ac55ec89..de174e6e3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php @@ -29,7 +29,7 @@ class BinomDistRangeTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=BINOM.DIST.RANGE({$trials}, {$probabilities}, {$successes})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php index 94b1b71a5..e9d2cdade 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -29,7 +29,7 @@ class BinomDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=BINOMDIST({$values}, {$trials}, {$probabilities}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php index 9cddd7462..876f40549 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php @@ -29,7 +29,7 @@ class BinomInvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=BINOM.INV({$trials}, {$probabilities}, {$alphas})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php index e0581e7f7..0b74a4668 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php @@ -26,7 +26,7 @@ class ChiDistLeftTailTest extends AllSetupTeardown $formula = "=CHISQ.DIST({$values}, {$degrees}, false)"; /** @var float|int|string */ - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php index b2a3e18f6..9414d9b92 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php @@ -25,7 +25,7 @@ class ChiDistRightTailTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CHISQ.DIST.RT({$values}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php index 475cf8887..99645c161 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php @@ -27,10 +27,10 @@ class ChiInvLeftTailTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV($probability, $degrees)"; /** @var float|int|string */ - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); $formula = "=CHISQ.DIST($result, $degrees)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($probability, $result, 1.0e-8); } @@ -40,7 +40,7 @@ class ChiInvLeftTailTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV({$probabilities}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php index a09d14be4..629bd951e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php @@ -27,10 +27,10 @@ class ChiInvRightTailTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV.RT($probability, $degrees)"; /** @var float|int|string */ - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); $formula = "=CHISQ.DIST.RT($result, $degrees)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($probability, $result, 1.0e-8); } @@ -40,7 +40,7 @@ class ChiInvRightTailTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV.RT({$probabilities}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php index 2ea9ac53d..9cc79b7ef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ConfidenceTest.php @@ -25,7 +25,7 @@ class ConfidenceTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CONFIDENCE({$alpha}, {$stdDev}, {$size})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php index 516783c6b..13fa60c75 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -25,7 +25,7 @@ class ExponDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=EXPONDIST({$values}, {$lambdas}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php index 20aad121a..ef40c4843 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php @@ -25,7 +25,7 @@ class FDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=F.DIST({$values}, {$u}, {$v}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php index 2a5eaaadd..76951e91b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -25,7 +25,7 @@ class FisherInvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FISHERINV({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php index d0f369ebd..2e37da556 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -25,7 +25,7 @@ class FisherTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FISHER({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php index 8dee25710..d5f7266a5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -30,7 +30,7 @@ class ForecastTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=FORECAST({$testValues}, {$yValues}, {$xValues})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php index 0a6379821..90b2b8670 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaDistTest.php @@ -25,7 +25,7 @@ class GammaDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=GAMMA.DIST({$values}, {$alpha}, {$beta}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php index 1b48f4998..20f0a7cfe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -25,7 +25,7 @@ class GammaInvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=GAMMA.INV({$values}, {$alpha}, {$beta})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php index d7e47b49a..50a1640ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -25,7 +25,7 @@ class GammaLnTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=GAMMALN({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php index ba246a55a..a83db1fbe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php @@ -25,7 +25,7 @@ class GammaTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=GAMMA({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php index 528d47bb3..e10120303 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php @@ -25,7 +25,7 @@ class GaussTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=GAUSS({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php index 92db287c2..fcfe07fa9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php @@ -30,7 +30,7 @@ class HypGeomDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=HYPGEOMDIST({$sampleSuccesses}, {$sampleNumber}, {$populationSuccesses}, {$populationNumber})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php index 25c5bc665..b5a7b3f82 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogInvTest.php @@ -25,7 +25,7 @@ class LogInvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LOGINV({$probabilities}, {$mean}, {$stdDev})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php index fd8f3fb4f..6220b2fc5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php @@ -25,7 +25,7 @@ class LogNormDist2Test extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LOGNORM.DIST({$values}, {$mean}, {$stdDev}, true)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php index 4820944a0..46a056fc4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php @@ -25,7 +25,7 @@ class LogNormDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LOGNORMDIST({$values}, {$mean}, {$stdDev})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php index 3a83fed89..814e06fa4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NegBinomDistTest.php @@ -29,7 +29,7 @@ class NegBinomDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=NEGBINOMDIST({$failures}, {$successes}, {$probabilities})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php index f9c444bf8..edf0ed920 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php @@ -25,7 +25,7 @@ class NormDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=NORMDIST({$values}, {$mean}, {$stdDev}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php index 14a479c6f..a19f03c2f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php @@ -25,7 +25,7 @@ class NormInvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=NORMINV({$probabilities}, {$mean}, {$stdDev})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php index ea07827d6..ad3032501 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php @@ -25,7 +25,7 @@ class NormSDist2Test extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=NORM.S.DIST({$values}, true)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php index 53b3aafe8..8971eaa80 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php @@ -25,7 +25,7 @@ class NormSDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=NORMSDIST({$values})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php index f76312331..0a83211e8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php @@ -25,7 +25,7 @@ class NormSInvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=NORMSINV({$probabilities})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php index 94223ce82..6bbd33352 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -25,7 +25,7 @@ class PermutTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=PERMUT({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php index 57cf1169a..a6be14b43 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php @@ -25,7 +25,7 @@ class PermutationATest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=PERMUTATIONA({$argument1},{$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php index 23bcbfa67..9c39418d2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php @@ -25,7 +25,7 @@ class PoissonTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=POISSON({$values}, {$mean}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php index 02846869d..2833d3e04 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php @@ -25,7 +25,7 @@ class StandardizeTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=STANDARDIZE({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php index 19811cf23..e119090d2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TDistTest.php @@ -25,7 +25,7 @@ class TDistTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TDIST({$values}, {$degrees}, {$tails})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php index bdbabebfb..a5c64123e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php @@ -25,7 +25,7 @@ class TinvTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TINV({$values}, {$degrees})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php index 66d9e9275..257087a4b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php @@ -25,7 +25,7 @@ class WeibullTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=WEIBULL({$values}, {$alpha}, {$beta}, false)"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php index b76f36b7f..04389f792 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php @@ -25,7 +25,7 @@ class ZTestTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=ZTEST({$dataSet}, {$m0})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/BahtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/BahtTest.php new file mode 100644 index 000000000..e4f530c73 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/BahtTest.php @@ -0,0 +1,37 @@ +getActiveSheet(); + + if (is_bool($number)) { + $formulaValue = $number ? 'TRUE' : 'FALSE'; + } elseif (is_string($number)) { + $formulaValue = '"' . $number . '"'; + } else { + $formulaValue = (string) $number; + } + + $sheet->getCell('A1')->setValue('=BAHTTEXT(' . $formulaValue . ')'); + $result = $sheet->getCell('A1')->getCalculatedValue(); + + self::assertSame($expectedResult, $result); + $spreadsheet->disconnectWorksheets(); + } + + public static function providerBAHTTEXT(): array + { + return require 'tests/data/Calculation/TextData/BAHTTEXT.php'; + } +} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php index 2695af5aa..7c9b80626 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CharTest.php @@ -36,8 +36,8 @@ class CharTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CHAR({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerCharArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php index 6c45269b9..764079286 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -36,8 +36,8 @@ class CleanTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CLEAN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerCleanArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php index 756e1fc64..99f467f93 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -36,8 +36,8 @@ class CodeTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CODE({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerCodeArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php index 27afb3a30..1937cb0d6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DollarTest.php @@ -40,8 +40,8 @@ class DollarTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=DOLLAR({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerDollarArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php index 94f804542..97ba2536a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -40,8 +40,8 @@ class ExactTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=EXACT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerExactArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php index e928bea4d..e63b7b953 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -45,8 +45,8 @@ class FindTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FIND({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerFindArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php index 039ae8e26..670157034 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -45,8 +45,8 @@ class FixedTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=FIXED({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerFixedArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index 2e4d38cc7..6cc32d9e6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -177,8 +177,8 @@ class LeftTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LEFT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerLeftArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php index 356145187..0fbead66a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -36,8 +36,8 @@ class LenTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LEN({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerLenArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index b19a6f6bb..6597021fa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -65,8 +65,8 @@ class LowerTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=LOWER({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerLowerArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php index 9bc670bae..e50875a28 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -199,8 +199,8 @@ class MidTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=MID({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerMidArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php index 088ad7b0d..c944d4ea6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -47,7 +47,7 @@ class NumberValueTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=NumberValue({$argument1}, {$argument2}, {$argument3})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, self::NV_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index 43838ca2a..e235cd937 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -65,8 +65,8 @@ class ProperTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=PROPER({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerProperArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php index a064ea814..478317950 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -56,8 +56,8 @@ class ReplaceTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=REPLACE({$oldText}, {$start}, {$chars}, {$newText})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerReplaceArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php index 1977b90bb..54a443dcf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php @@ -40,8 +40,8 @@ class ReptTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=REPT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerReptArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index 7e127b9cc..5da233e57 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -177,8 +177,8 @@ class RightTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=RIGHT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerRightArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php index cdb36fc81..dd5b4bf67 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -45,8 +45,8 @@ class SearchTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SEARCH({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerSearchArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php index 216aae1cc..ba3fde9e0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -51,8 +51,8 @@ class SubstituteTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=SUBSTITUTE({$oldText}, {$fromText}, {$toText})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerSubstituteArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php index 5e09eceda..6584cf5ce 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -36,7 +36,7 @@ class TTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=T({$argument})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php index 9b1d65b36..9c1036c00 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextJoinTest.php @@ -42,8 +42,8 @@ class TextJoinTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TEXTJOIN({$delimiter}, {$blanks}, {$texts})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerTextjoinArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php index 19e2b1721..3dabd9519 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -40,8 +40,8 @@ class TextTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TEXT({$argument1}, {$argument2})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerTextArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php index 89f12155d..9fce12e59 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -36,8 +36,8 @@ class TrimTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=TRIM({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerTrimArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index e0e8937e0..2810231d0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -65,8 +65,8 @@ class UpperTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=UPPER({$array})"; - $result = $calculation->_calculateFormulaValue($formula); - self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); + $result = $calculation->calculateFormula($formula); + self::assertSame($expectedResult, $result); } public static function providerUpperArray(): array diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php index a18bdf8e4..25b6caab9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -49,7 +49,7 @@ class ValueTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=VALUE({$argument})"; - $result = $calculation->_calculateFormulaValue($formula); + $result = $calculation->calculateFormula($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php b/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php index ea6397f94..0c4a99a60 100644 --- a/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php +++ b/tests/PhpSpreadsheetTests/Functional/TypeAttributePreservationTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Functional; +use PhpOffice\PhpSpreadsheet\Calculation\Information\Info; use PhpOffice\PhpSpreadsheet\Reader\Ods as ReaderOds; use PhpOffice\PhpSpreadsheet\Reader\Slk as ReaderSlk; use PhpOffice\PhpSpreadsheet\Reader\Xls as ReaderXls; @@ -15,6 +16,16 @@ use PHPUnit\Framework\Attributes\DataProvider; class TypeAttributePreservationTest extends AbstractFunctional { + protected function setUp(): void + { + Info::$infoSupported = false; + } + + protected function tearDown(): void + { + Info::$infoSupported = true; + } + public static function providerFormulae(): array { $formats = ['Xlsx']; diff --git a/tests/PhpSpreadsheetTests/Shared/Issue4696Test.php b/tests/PhpSpreadsheetTests/Shared/Issue4696Test.php new file mode 100644 index 000000000..387898406 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Shared/Issue4696Test.php @@ -0,0 +1,103 @@ +spreadsheet !== null) { + $this->spreadsheet->disconnectWorksheets(); + $this->spreadsheet = null; + } + } + + #[DataProvider('providerIsDateTime')] + public function testIsDateTime(bool $expectedResult, string $expectedFormatted, int|float|string $value): void + { + $this->spreadsheet = new Spreadsheet(); + $sheet = $this->spreadsheet->getActiveSheet(); + if (is_string($value) && $value[0] !== '=') { + $sheet->getCell('A1')->setValueExplicit($value, DataType::TYPE_STRING); + } else { + $sheet->getCell('A1')->setValue($value); + } + $sheet->getStyle('A1')->getNumberFormat() + ->setFormatCode('yyyy-mm-dd'); + self::assertSame( + $expectedResult, + Date::isDateTime($sheet->getCell('A1')) + ); + self::assertSame( + $expectedFormatted, + $sheet->getCell('A1')->getFormattedValue() + ); + } + + public static function providerIsDateTime(): array + { + return [ + 'valid integer' => [true, '1903-12-31', 1461], + 'valid integer stored as string' => [true, '1904-01-01', '1462'], + 'valid integer stored as concatenated string' => [true, '1904-01-01', '="14"&"62"'], + 'valid float' => [true, '1903-12-31', 1461.5], + 'valid float stored as string' => [true, '1903-12-31', '1461.5'], + 'out-of-range integer' => [false, '7000989091802000122', 7000989091802000122], + 'out-of-range float' => [false, '7.000989091802E+18', 7000989091802000122.1], + 'out-of-range float stored as string' => [false, '7000989091802000122.1', '7000989091802000122.1'], + 'non-numeric' => [false, 'xyz', 'xyz'], + 'issue 917' => [false, '5e8630b8-603c-43fe-b038-6154a3f893ab', '5e8630b8-603c-43fe-b038-6154a3f893ab'], + ]; + } + + #[DataProvider('providerOtherFunctions')] + public function testOtherFunctions(string $function): void + { + $this->spreadsheet = new Spreadsheet(); + $sheet = $this->spreadsheet->getActiveSheet(); + $sheet->getCell('A1')->setValue(7000989091802000122); + $sheet->getCell('A3')->setValue(39107); // 2007-01-25 + $sheet->getCell('A4')->setValue(39767); // 2008-11-15 + $sheet->getCell('A5')->setValue(2); + $sheet->getCell('A6')->setValue(1); + $sheet->getCell('B1')->setValue($function); + self::assertSame( + '#NUM!', + $sheet->getCell('B1')->getFormattedValue() + ); + } + + public static function providerOtherFunctions(): array + { + return [ + ['=YEAR(A1)'], + ['=MONTH(A1)'], + ['=DAY(A1)'], + ['=DAYS(A1,A1)'], + ['=DAYS360(A1,A1)'], + ['=DATEDIF(A1,A1,"D")'], + ['=HOUR(A1)'], + ['=MINUTE(A1)'], + ['=SECOND(A1)'], + ['=WEEKNUM(A1)'], + ['=ISOWEEKNUM(A1)'], + ['=WEEKDAY(A1)'], + ['=COUPDAYBS(A1,A4,A5,A6)'], + ['=COUPDAYS(A3,A2,A5,A6)'], + ['=COUPDAYSNC(A3,A2,A5,A6)'], + ['=COUPNCD(A3,A2,A5,A6)'], + ['=COUPNUM(A3,A2,A5,A6)'], + ['=COUPPCD(A3,A2,A5,A6)'], + ]; + } +} diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterYearTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterYearTest.php index c1e7c9ad4..3e91e3007 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterYearTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterYearTest.php @@ -47,6 +47,8 @@ class AutoFilterYearTest extends SetupTeardown } ++$row; $sheet->getCell("A$row")->setValue('=DATE(2041, 1, 1)'); // beyond epoch + ++$row; + $sheet->getCell("A$row")->setValue(7000989091802000122); // issue 4696 ++$row; // empty row at end $this->maxRow = $maxRow = $row; $autoFilter = $sheet->getAutoFilter(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php index c06cb633f..146085632 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php @@ -54,6 +54,28 @@ class DateGroupTest extends SetupTeardown self::assertEquals([6], $this->getVisible()); } + public function testIssue4696(): void + { + $year = 2011; + $sheet = $this->initSheet($year); + $sheet->getCell('A2')->setValue(7000989091802000122); + $columnFilter = $sheet->getAutoFilter()->getColumn('C'); + $columnFilter->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER); + $columnFilter->createRule() + ->setRule( + Rule::AUTOFILTER_COLUMN_RULE_EQUAL, + [ + 'year' => $year, + 'month' => 12, + 'day' => 6, + ] + ) + ->setRuleType( + Rule::AUTOFILTER_RULETYPE_DATEGROUP + ); + self::assertEquals([6], $this->getVisible()); + } + public function testYearMonthDayHourMinuteSecond1Group(): void { $year = 2011; diff --git a/tests/PhpSpreadsheetTests/Worksheet/ProtectedRangeTest.php b/tests/PhpSpreadsheetTests/Worksheet/ProtectedRangeTest.php new file mode 100644 index 000000000..4210518b5 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Worksheet/ProtectedRangeTest.php @@ -0,0 +1,59 @@ +getActiveSheet(); + $sheet->protectCells('B2:D4 J2:L4 F2:H4', name: 'ProtectedBlock1'); + $sheet->protectCells('M2:O4 Q7:R9 T1:T3'); + $sheet->protectCells('B8 C9 D1', name: 'ProtectedBlock3'); + $sheet->insertNewRowBefore(2); + $ranges = $sheet->getProtectedCellRanges(); + $rangeKeys = array_keys($ranges); + self::assertSame( + [ + 'B3:D5 J3:L5 F3:H5', + 'M3:O5 Q8:R10 T1:T4', + 'B9 C10 D1', + ], + $rangeKeys + ); + self::assertSame('ProtectedBlock1', $ranges[$rangeKeys[0]]->getName()); + self::assertSame('ProtectedBlock3', $ranges[$rangeKeys[2]]->getName()); + $spreadsheet->disconnectWorksheets(); + } + + public function testRemoveRow1(): void + { + $spreadsheet = new Spreadsheet(); + $sheet = $spreadsheet->getActiveSheet(); + $sheet->protectCells('B2:D4 J2:L4 F2:H4'); + $sheet->protectCells('M2:O4 Q7:R9 T1:T3', name: 'ProtectedBlock2'); + $sheet->protectCells('B8 C9 D1 E3'); + $sheet->removeRow(3); + $ranges = $sheet->getProtectedCellRanges(); + $rangeKeys = array_keys($ranges); + // PhpSpreadsheet has methods to merge cell addresses in a row, + // but not in a column. So the results here are not as concise as + // they might be, but they are nevertheless accurate. + self::assertSame( + [ + 'B2:B3 C2:C3 D2:D3 F2:F3 G2:G3 H2:H3 J2:J3 K2:K3 L2:L3', + 'M2:M3 N2:N3 O2:O3 Q6:Q8 R6:R8 T1:T2', + 'B7 C8 D1', + ], + $rangeKeys + ); + self::assertSame('ProtectedBlock2', $ranges[$rangeKeys[1]]->getName()); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Worksheet/Table/RemoveTableTest.php b/tests/PhpSpreadsheetTests/Worksheet/Table/RemoveTableTest.php index be46b663d..ea7a4e63b 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/Table/RemoveTableTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/Table/RemoveTableTest.php @@ -20,7 +20,7 @@ class RemoveTableTest extends SetupTeardown self::assertEquals(1, $sheet->getTableCollection()->count()); - $sheet->removeTableByName('table1'); // case insensitive + $sheet->removeTableByName('table1'); // case-insensitive self::assertEquals(0, $sheet->getTableCollection()->count()); } diff --git a/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php b/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php index 3edbe79b1..4a9160ba0 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php @@ -89,7 +89,7 @@ class TableTest extends SetupTeardown $sheet->addTable($table1); $table2 = new Table(); - $table2->setName('tABlE_1'); // case insensitive + $table2->setName('tABlE_1'); // case-insensitive $sheet->addTable($table2); } @@ -103,7 +103,7 @@ class TableTest extends SetupTeardown $sheet->addTable($table1); $table2 = new Table(); - $table2->setName('table_2'); // case insensitive + $table2->setName('table_2'); // case-insensitive $sheet->addTable($table2); $table2->setName('tAbLe_1'); } diff --git a/tests/PhpSpreadsheetTests/Writer/Dompdf/PrintAreaTest.php b/tests/PhpSpreadsheetTests/Writer/Dompdf/PrintAreaTest.php new file mode 100644 index 000000000..30927f4f4 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Dompdf/PrintAreaTest.php @@ -0,0 +1,56 @@ +getActiveSheet(); + $inArray = [ + [1, 2, 3, 4, 5], + [6, 7, 8, 9, 10], + [11, 12, 13, 14, 15], + [16, 17, 18, 19, 20], + [21, 22, 23, 24, 25], + [26, 27, 28, 29, 30], + ]; + $sheet->fromArray($inArray); + $sheet->getPageSetup()->setPrintArea('B2:D4'); + $writer = new DompdfWriter($spreadsheet); + $html = $writer->generateHtmlAll(); + $html = preg_replace('/^ +/m', '', $html) ?? $html; + $expectedArray = [ + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + ]; + $expectedString = implode(PHP_EOL, $expectedArray); + self::assertStringContainsString( + $expectedString, + $html + ); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Html/PrintAreaTest.php b/tests/PhpSpreadsheetTests/Writer/Html/PrintAreaTest.php new file mode 100644 index 000000000..cb27755d6 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Html/PrintAreaTest.php @@ -0,0 +1,57 @@ +getActiveSheet(); + $inArray = [ + [1, 2, 3, 4, 5], + [6, 7, 8, 9, 10], + [11, 12, 13, 14, 15], + [16, 17, 18, 19, 20], + [21, 22, 23, 24, 25], + [26, 27, 28, 29, 30], + ]; + $sheet->fromArray($inArray); + $sheet->getPageSetup()->setPrintArea('B2:D4'); + $writer = new HtmlWriter($spreadsheet); + $html = $writer->generateHtmlAll(); + self::assertStringContainsString( + "
789
121314
171819
", + $html + ); + $expectedArray = [ + '@media print {', + ' table.sheet0 tr.row0 td { display:none }', + ' table.sheet0 tr.row4 td { display:none }', + ' table.sheet0 tr.row5 td { display:none }', + ' table.sheet0 td.column0 { display:none }', + ' table.sheet0 td.column4 { display:none }', + '}', + ]; + $expectedString = implode(PHP_EOL, $expectedArray); + self::assertStringContainsString( + $expectedString, + $html + ); + $spreadsheet->disconnectWorksheets(); + + $reader = new HtmlReader(); + $spreadsheet2 = $reader->loadFromString($html); + $sheet2 = $spreadsheet2->getActiveSheet(); + self::assertSame('B2:D4', $sheet2->getPageSetup()->getPrintArea()); + self::assertSame($inArray, $sheet2->toArray(null, false, false)); + $spreadsheet2->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Mpdf/PrintAreaTest.php b/tests/PhpSpreadsheetTests/Writer/Mpdf/PrintAreaTest.php new file mode 100644 index 000000000..4033ef841 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Mpdf/PrintAreaTest.php @@ -0,0 +1,56 @@ +getActiveSheet(); + $inArray = [ + [1, 2, 3, 4, 5], + [6, 7, 8, 9, 10], + [11, 12, 13, 14, 15], + [16, 17, 18, 19, 20], + [21, 22, 23, 24, 25], + [26, 27, 28, 29, 30], + ]; + $sheet->fromArray($inArray); + $sheet->getPageSetup()->setPrintArea('B2:D4'); + $writer = new MpdfWriter($spreadsheet); + $html = $writer->generateHtmlAll(); + $html = preg_replace('/^ +/m', '', $html) ?? $html; + $expectedArray = [ + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + ]; + $expectedString = implode(PHP_EOL, $expectedArray); + self::assertStringContainsString( + $expectedString, + $html + ); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Tcpdf/PrintAreaTest.php b/tests/PhpSpreadsheetTests/Writer/Tcpdf/PrintAreaTest.php new file mode 100644 index 000000000..249bb2db8 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Writer/Tcpdf/PrintAreaTest.php @@ -0,0 +1,59 @@ +getActiveSheet(); + $inArray = [ + [1, 2, 3, 4, 5], + [6, 7, 8, 9, 10], + [11, 12, 13, 14, 15], + [16, 17, 18, 19, 20], + [21, 22, 23, 24, 25], + [26, 27, 28, 29, 30], + ]; + $sheet->fromArray($inArray); + $sheet->getPageSetup()->setPrintArea('B2:D4'); + $writer = new TcpdfWriter($spreadsheet); + $html = $writer->generateHtmlAll(); + $html = preg_replace('/^ +/m', '', $html) ?? $html; + $expectedArray = [ + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + ]; + $expectedString = implode(PHP_EOL, $expectedArray); + self::assertStringContainsString( + $expectedString, + $html + ); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php index 2738faa74..452e72106 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/DrawingsTest.php @@ -324,7 +324,7 @@ class DrawingsTest extends AbstractFunctional try { $drawing->getImageFileExtensionForSave(); - self::fail('Should throw exception when attempting to get image file extention for tiff'); + self::fail('Should throw exception when attempting to get image file extension for tiff'); } catch (PhpSpreadsheetException $e) { self::assertEquals($e->getMessage(), 'Unsupported image type in comment background. Supported types: PNG, JPEG, BMP, GIF.'); } diff --git a/tests/data/Calculation/Information/INFO.php b/tests/data/Calculation/Information/INFO.php new file mode 100644 index 000000000..9b46d7e31 --- /dev/null +++ b/tests/data/Calculation/Information/INFO.php @@ -0,0 +1,62 @@ +
789
121314
171819
789
121314
171819