From 80f5e8fd1eed823d5ce38fdc32395cd8de832ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=E4=B8=8B=E5=85=8B=E5=BD=A6?= Date: Fri, 21 Feb 2020 14:39:11 +0900 Subject: [PATCH 1/6] added IFS, NETWORKDAYS.INTL and WORKDAY.INTL as dummy EXCEL function they are listed on the doc --- .../Calculation/Calculation.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 4ebce2ae..344bc323 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -1042,6 +1042,11 @@ class Calculation 'functionCall' => [Logical::class, 'IFNA'], 'argumentCount' => '2', ], + 'IFS' => [ + 'category' => Category::CATEGORY_LOGICAL, + 'functionCall' => [Functions::class, 'DUMMY'], + 'argumentCount' => '2+', + ], 'IMABS' => [ 'category' => Category::CATEGORY_ENGINEERING, 'functionCall' => [Engineering::class, 'IMABS'], @@ -1498,7 +1503,12 @@ class Calculation 'NETWORKDAYS' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, 'functionCall' => [DateTime::class, 'NETWORKDAYS'], - 'argumentCount' => '2+', + 'argumentCount' => '2-3', + ], + 'NETWORKDAYS.INTL' => [ + 'category' => Category::CATEGORY_DATE_AND_TIME, + 'functionCall' => [Functions::class, 'DUMMY'], + 'argumentCount' => '2-4', ], 'NOMINAL' => [ 'category' => Category::CATEGORY_FINANCIAL, @@ -2167,7 +2177,12 @@ class Calculation 'WORKDAY' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, 'functionCall' => [DateTime::class, 'WORKDAY'], - 'argumentCount' => '2+', + 'argumentCount' => '2-3', + ], + 'WORKDAY.INTL' => [ + 'category' => Category::CATEGORY_DATE_AND_TIME, + 'functionCall' => [Functions::class, 'DUMMY'], + 'argumentCount' => '2-4', ], 'XIRR' => [ 'category' => Category::CATEGORY_FINANCIAL, From b98c19ca281f1c163517edc014a08169cc6729f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=E4=B8=8B=E5=85=8B=E5=BD=A6?= Date: Fri, 21 Feb 2020 14:39:39 +0900 Subject: [PATCH 2/6] update function-list-by-* to sync with $phpSpreadsheetFunctions --- docs/references/function-list-by-category.md | 44 +++++++++++--------- docs/references/function-list-by-name.md | 43 +++++++++---------- 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/docs/references/function-list-by-category.md b/docs/references/function-list-by-category.md index effe9e97..9f768459 100644 --- a/docs/references/function-list-by-category.md +++ b/docs/references/function-list-by-category.md @@ -69,12 +69,12 @@ BESSELK | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELK BESSELY | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELY BIN2DEC | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTODEC BIN2HEX | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOHEX -BIN2OCT | \PhpOffice\PhpSpreadsheet\Calculation\Engineeri +BIN2OCT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BINTOOCT BITAND | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITAND BITLSHIFT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITLSHIFT BITOR | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITOR BITRSHIFT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITRSHIFT -BITXOR | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITXOR +BITXOR | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITOR COMPLEX | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::COMPLEX CONVERT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::CONVERTUOM DEC2BIN | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::DECTOBIN @@ -184,21 +184,21 @@ YIELDMAT | \PhpOffice\PhpSpreadsheet\Calculation\Financial::YIELDMAT Excel Function | PhpSpreadsheet Function --------------------|------------------------------------------- CELL | **Not yet Implemented** -ERROR.TYPE | \PhpOffice\PhpSpreadsheet\Calculation\Functions::ERROR_TYPE +ERROR.TYPE | \PhpOffice\PhpSpreadsheet\Calculation\Functions::errorType INFO | **Not yet Implemented** -ISBLANK | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_BLANK -ISERR | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_ERR -ISERROR | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_ERROR -ISEVEN | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_EVEN -ISFORMULA | \PhpOffice\PhpSpreadsheet\Calculation\Functions::ISFORMULA -ISLOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_LOGICAL -ISNA | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_NA -ISNONTEXT | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_NONTEXT -ISNUMBER | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_NUMBER -ISODD | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_ODD +ISBLANK | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isBlank +ISERR | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isErr +ISERROR | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isError +ISEVEN | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isEven +ISFORMULA | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isFormula +ISLOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isLogical +ISNA | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNa +ISNONTEXT | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNonText +ISNUMBER | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNumber +ISODD | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isOdd ISREF | **Not yet Implemented** -ISTEXT | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_TEXT -N | \PhpOffice\PhpSpreadsheet\Calculation\Functions::N +ISTEXT | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isText +N | \PhpOffice\PhpSpreadsheet\Calculation\Functions::n NA | \PhpOffice\PhpSpreadsheet\Calculation\Functions::NA TYPE | \PhpOffice\PhpSpreadsheet\Calculation\Functions::TYPE @@ -208,11 +208,13 @@ Excel Function | PhpSpreadsheet Function --------------------|------------------------------------------- AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd FALSE | \PhpOffice\PhpSpreadsheet\Calculation\Logical::FALSE -IF | \PhpOffice\PhpSpreadsheet\Calculation\Logical::STATEMENT_IF +IF | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementIf IFERROR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFERROR IFNA | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFNA +IFS | **Not yet Implemented** NOT | \PhpOffice\PhpSpreadsheet\Calculation\Logical::NOT OR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalOr +SWITCH | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementSwitch TRUE | \PhpOffice\PhpSpreadsheet\Calculation\Logical::TRUE XOR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalXor @@ -220,7 +222,7 @@ XOR | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalXor Excel Function | PhpSpreadsheet Function --------------------|------------------------------------------- -ADDRESS | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::CELL_ADDRESS +ADDRESS | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::cellAddress AREAS | **Not yet Implemented** CHOOSE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::CHOOSE COLUMN | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::COLUMN @@ -249,11 +251,13 @@ ACOS | acos ACOSH | acosh ACOT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOT ACOTH | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOTH +ARABIC | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ARABIC ASIN | asin ASINH | asinh ATAN | atan -ATAN2 | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::REVERSE_ATAN2 +ATAN2 | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ATAN2 ATANH | atanh +BASE | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::BASE CEILING | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::CEILING COMBIN | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::COMBIN COS | cos @@ -272,7 +276,7 @@ GCD | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::GCD INT | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::INT LCM | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::LCM LN | log -LOG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::LOG_BASE +LOG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::logBase LOG10 | log10 MDETERM | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MDETERM MINVERSE | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::MINVERSE @@ -389,8 +393,8 @@ SLOPE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SLOPE SMALL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::SMALL STANDARDIZE | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STANDARDIZE STDEV | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV -STDEV.S | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV STDEV.P | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP +STDEV.S | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV STDEVA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVA STDEVP | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP STDEVPA | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVPA diff --git a/docs/references/function-list-by-name.md b/docs/references/function-list-by-name.md index e974c316..709b4b1d 100644 --- a/docs/references/function-list-by-name.md +++ b/docs/references/function-list-by-name.md @@ -11,16 +11,17 @@ ACOS | CATEGORY_MATH_AND_TRIG | acos ACOSH | CATEGORY_MATH_AND_TRIG | acosh ACOT | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOT ACOTH | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ACOTH -ADDRESS | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::CELL_ADDRESS +ADDRESS | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::cellAddress AMORDEGRC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::AMORDEGRC AMORLINC | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::AMORLINC AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd +ARABIC | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ARABIC AREAS | CATEGORY_LOOKUP_AND_REFERENCE | **Not yet Implemented** ASC | CATEGORY_TEXT_AND_DATA | **Not yet Implemented** ASIN | CATEGORY_MATH_AND_TRIG | asin ASINH | CATEGORY_MATH_AND_TRIG | asinh ATAN | CATEGORY_MATH_AND_TRIG | atan -ATAN2 | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::REVERSE_ATAN2 +ATAN2 | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::ATAN2 ATANH | CATEGORY_MATH_AND_TRIG | atanh AVEDEV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::AVEDEV AVERAGE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::AVERAGE @@ -33,6 +34,7 @@ AVERAGEIFS | CATEGORY_STATISTICAL | **Not yet Implemented** Excel Function | Category | PhpSpreadsheet Function --------------------|--------------------------------|------------------------------------------- BAHTTEXT | CATEGORY_TEXT_AND_DATA | **Not yet Implemented** +BASE | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::BASE BESSELI | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELI BESSELJ | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELJ BESSELK | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BESSELK @@ -47,7 +49,7 @@ BITAND | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet BITLSHIFT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITLSHIFT BITOR | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITOR BITRSHIFT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITRSHIFT -BITXOR | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITXOR +BITXOR | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::BITOR ## C @@ -147,7 +149,7 @@ ERF | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet ERF.PRECISE | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERFPRECISE ERFC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERFC ERFC.PRECISE | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::ERFC -ERROR.TYPE | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::ERROR_TYPE +ERROR.TYPE | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::errorType EVEN | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::EVEN EXACT | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::EXACT EXP | CATEGORY_MATH_AND_TRIG | exp @@ -205,7 +207,7 @@ HYPGEOMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet Excel Function | Category | PhpSpreadsheet Function --------------------|--------------------------------|------------------------------------------- -IF | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::STATEMENT_IF +IF | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementIf IFERROR | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFERROR IFNA | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::IFNA IFS | CATEGORY_LOGICAL | **Not yet Implemented** @@ -242,20 +244,20 @@ INTERCEPT | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet INTRATE | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::INTRATE IPMT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::IPMT IRR | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::IRR -ISBLANK | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_BLANK -ISERR | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_ERR -ISERROR | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_ERROR -ISEVEN | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_EVEN -ISFORMULA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::ISFORMULA -ISLOGICAL | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_LOGICAL -ISNA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_NA -ISNONTEXT | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_NONTEXT -ISNUMBER | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_NUMBER -ISODD | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_ODD +ISBLANK | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isBlank +ISERR | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isErr +ISERROR | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isError +ISEVEN | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isEven +ISFORMULA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isFormula +ISLOGICAL | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isLogical +ISNA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNa +ISNONTEXT | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNonText +ISNUMBER | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isNumber +ISODD | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isOdd ISOWEEKNUM | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::ISOWEEKNUM ISPMT | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::ISPMT ISREF | CATEGORY_INFORMATION | **Not yet Implemented** -ISTEXT | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::IS_TEXT +ISTEXT | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::isText ## J @@ -281,7 +283,7 @@ LEN | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet LENB | CATEGORY_TEXT_AND_DATA | \PhpOffice\PhpSpreadsheet\Calculation\TextData::STRINGLENGTH LINEST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LINEST LN | CATEGORY_MATH_AND_TRIG | log -LOG | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::LOG_BASE +LOG | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::logBase LOG10 | CATEGORY_MATH_AND_TRIG | log10 LOGEST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGEST LOGINV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::LOGINV @@ -321,7 +323,7 @@ MULTINOMIAL | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet Excel Function | Category | PhpSpreadsheet Function --------------------|--------------------------------|------------------------------------------- -N | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::N +N | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::n NA | CATEGORY_INFORMATION | \PhpOffice\PhpSpreadsheet\Calculation\Functions::NA NEGBINOMDIST | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::NEGBINOMDIST NETWORKDAYS | CATEGORY_DATE_AND_TIME | \PhpOffice\PhpSpreadsheet\Calculation\DateTime::NETWORKDAYS @@ -428,8 +430,8 @@ SQRT | CATEGORY_MATH_AND_TRIG | sqrt SQRTPI | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SQRTPI STANDARDIZE | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STANDARDIZE STDEV | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV -STDEV.S | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV STDEV.P | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP +STDEV.S | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEV STDEVA | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVA STDEVP | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVP STDEVPA | CATEGORY_STATISTICAL | \PhpOffice\PhpSpreadsheet\Calculation\Statistical::STDEVPA @@ -444,7 +446,7 @@ SUMSQ | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet SUMX2MY2 | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SUMX2MY2 SUMX2PY2 | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SUMX2PY2 SUMXMY2 | CATEGORY_MATH_AND_TRIG | \PhpOffice\PhpSpreadsheet\Calculation\MathTrig::SUMXMY2 -SWITCH | CATEGORY_LOGICAL | **Not yet Implemented** +SWITCH | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::statementSwitch SYD | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::SYD ## T @@ -514,7 +516,6 @@ XIRR | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet XNPV | CATEGORY_FINANCIAL | \PhpOffice\PhpSpreadsheet\Calculation\Financial::XNPV XOR | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalXor - ## Y Excel Function | Category | PhpSpreadsheet Function From e11202168f9c36ee92e28969e44e6875d429573d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=E4=B8=8B=E5=85=8B=E5=BD=A6?= Date: Fri, 21 Feb 2020 14:56:43 +0900 Subject: [PATCH 3/6] bin/generate-document generates function-list-by-* --- bin/generate-document | 14 ++++ src/PhpSpreadsheet/DocumentGenerator.php | 102 +++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100755 bin/generate-document create mode 100644 src/PhpSpreadsheet/DocumentGenerator.php diff --git a/bin/generate-document b/bin/generate-document new file mode 100755 index 00000000..a68a1361 --- /dev/null +++ b/bin/generate-document @@ -0,0 +1,14 @@ +#!/usr/bin/env php + $category) { + echo "\n"; + echo "## {$categoryConstant}\n"; + echo "\n"; + echo "Excel Function | PhpSpreadsheet Function\n"; + echo "--------------------|-------------------------------------------\n"; + foreach ($phpSpreadsheetFunctions as $function => $functionInfo) { + if ($category === $functionInfo['category']) { + echo str_pad($function, 20) + . '| ' . self::getPhpSpreadsheetFunctionText($functionInfo['functionCall']) . "\n"; + } + } + } + } finally { + file_put_contents(__DIR__ . '/../../docs/references/function-list-by-category.md', ob_get_clean()); + } + } + + /** + * @return mixed + * @throws ReflectionException + */ + private static function getPhpSpreadsheetFunctions() { + $phpSpreadsheetFunctionsProperty = (new ReflectionClass(Calculation::class))->getProperty('phpSpreadsheetFunctions'); + $phpSpreadsheetFunctionsProperty->setAccessible(true); + $phpSpreadsheetFunctions = $phpSpreadsheetFunctionsProperty->getValue(); + ksort($phpSpreadsheetFunctions); + return $phpSpreadsheetFunctions; + } + + /** + * @return array + * @throws ReflectionException + */ + private static function getCategories(): array { + return (new ReflectionClass(Category::class))->getConstants(); + } + + private static function getPhpSpreadsheetFunctionText($functionCall): string { + if (is_string($functionCall)) { + return $functionCall; + } + if ($functionCall === [Functions::class, 'DUMMY']) { + return '**Not yet Implemented**'; + } + if (is_array($functionCall)) { + return "\\{$functionCall[0]}::{$functionCall[1]}"; + } + throw new UnexpectedValueException('$functionCall is of type ' . gettype($functionCall) . '. string or array expected'); + } + + /** + * @throws ReflectionException + */ + public static function generateFunctionListByName(): void { + $categoryConstants = array_flip(self::getCategories()); + ob_start(); + try { + echo "# Function list by name\n"; + $phpSpreadsheetFunctions = self::getPhpSpreadsheetFunctions(); + $lastAlphabet = null; + foreach ($phpSpreadsheetFunctions as $function => $functionInfo) { + if ($lastAlphabet !== $function[0]) { + $lastAlphabet = $function[0]; + echo "\n"; + echo "## {$lastAlphabet}\n"; + echo "\n"; + echo "Excel Function | Category | PhpSpreadsheet Function\n"; + echo "--------------------|--------------------------------|-------------------------------------------\n"; + } + echo str_pad($function, 20) + . '| ' . str_pad($categoryConstants[$functionInfo['category']], 31) + . '| ' . self::getPhpSpreadsheetFunctionText($functionInfo['functionCall']) + . "\n"; + } + } finally { + file_put_contents(__DIR__ . '/../../docs/references/function-list-by-name.md', ob_get_clean()); + } + } +} \ No newline at end of file From fe83f070aa404bc954c515fc8b440c7a618a3147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=E4=B8=8B=E5=85=8B=E5=BD=A6?= Date: Sun, 23 Feb 2020 12:30:18 +0900 Subject: [PATCH 4/6] improve testability --- bin/generate-document | 14 ++- src/PhpSpreadsheet/DocumentGenerator.php | 127 ++++++++++++----------- 2 files changed, 80 insertions(+), 61 deletions(-) diff --git a/bin/generate-document b/bin/generate-document index a68a1361..10ac8118 100755 --- a/bin/generate-document +++ b/bin/generate-document @@ -1,13 +1,23 @@ #!/usr/bin/env php getProperty('phpSpreadsheetFunctions'); + $phpSpreadsheetFunctionsProperty->setAccessible(true); + $phpSpreadsheetFunctions = $phpSpreadsheetFunctionsProperty->getValue(); + ksort($phpSpreadsheetFunctions); + + file_put_contents(__DIR__ . '/../docs/references/function-list-by-category.md', + DocumentGenerator::generateFunctionListByCategory($phpSpreadsheetFunctions) + ); + file_put_contents(__DIR__ . '/../docs/references/function-list-by-name.md', + DocumentGenerator::generateFunctionListByName($phpSpreadsheetFunctions) + ); } catch (ReflectionException $e) { fwrite(STDERR, (string)$e); exit(1); diff --git a/src/PhpSpreadsheet/DocumentGenerator.php b/src/PhpSpreadsheet/DocumentGenerator.php index 010d1325..de6f313f 100644 --- a/src/PhpSpreadsheet/DocumentGenerator.php +++ b/src/PhpSpreadsheet/DocumentGenerator.php @@ -1,64 +1,69 @@ $category) { - echo "\n"; - echo "## {$categoryConstant}\n"; - echo "\n"; - echo "Excel Function | PhpSpreadsheet Function\n"; - echo "--------------------|-------------------------------------------\n"; - foreach ($phpSpreadsheetFunctions as $function => $functionInfo) { - if ($category === $functionInfo['category']) { - echo str_pad($function, 20) - . '| ' . self::getPhpSpreadsheetFunctionText($functionInfo['functionCall']) . "\n"; - } + public static function generateFunctionListByCategory(array $phpSpreadsheetFunctions): string + { + $result = "# Function list by category\n"; + foreach (self::getCategories() as $categoryConstant => $category) { + $result .= "\n"; + $result .= "## {$categoryConstant}\n"; + $result .= "\n"; + $lengths = [20, 42]; + $result .= self::tableRow($lengths, ['Excel Function', 'PhpSpreadsheet Function']) . "\n"; + $result .= self::tableRow($lengths, null) . "\n"; + foreach ($phpSpreadsheetFunctions as $excelFunction => $functionInfo) { + if ($category === $functionInfo['category']) { + $phpFunction = self::getPhpSpreadsheetFunctionText($functionInfo['functionCall']); + $result .= self::tableRow($lengths, [$excelFunction, $phpFunction]) . "\n"; } } - } finally { - file_put_contents(__DIR__ . '/../../docs/references/function-list-by-category.md', ob_get_clean()); } + + return $result; } /** - * @return mixed * @throws ReflectionException - */ - private static function getPhpSpreadsheetFunctions() { - $phpSpreadsheetFunctionsProperty = (new ReflectionClass(Calculation::class))->getProperty('phpSpreadsheetFunctions'); - $phpSpreadsheetFunctionsProperty->setAccessible(true); - $phpSpreadsheetFunctions = $phpSpreadsheetFunctionsProperty->getValue(); - ksort($phpSpreadsheetFunctions); - return $phpSpreadsheetFunctions; - } - - /** + * * @return array - * @throws ReflectionException */ - private static function getCategories(): array { + private static function getCategories(): array + { return (new ReflectionClass(Category::class))->getConstants(); } - private static function getPhpSpreadsheetFunctionText($functionCall): string { + private static function tableRow(array $lengths, array $values = null): string + { + $result = ''; + foreach (array_map(null, $lengths, $values ?? []) as $i => [$length, $value]) { + $pad = $value === null ? '-' : ' '; + if ($i > 0) { + $result .= '|' . $pad; + } + $result .= str_pad($value ?? '', $length, $pad); + } + + return rtrim($result, ' '); + } + + private static function getPhpSpreadsheetFunctionText($functionCall): string + { if (is_string($functionCall)) { return $functionCall; } @@ -68,35 +73,39 @@ class DocumentGenerator { if (is_array($functionCall)) { return "\\{$functionCall[0]}::{$functionCall[1]}"; } - throw new UnexpectedValueException('$functionCall is of type ' . gettype($functionCall) . '. string or array expected'); + + throw new UnexpectedValueException( + '$functionCall is of type ' . gettype($functionCall) . '. string or array expected' + ); } /** + * @param array[] $phpSpreadsheetFunctions + * * @throws ReflectionException + * + * @return string */ - public static function generateFunctionListByName(): void { + public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string + { $categoryConstants = array_flip(self::getCategories()); - ob_start(); - try { - echo "# Function list by name\n"; - $phpSpreadsheetFunctions = self::getPhpSpreadsheetFunctions(); - $lastAlphabet = null; - foreach ($phpSpreadsheetFunctions as $function => $functionInfo) { - if ($lastAlphabet !== $function[0]) { - $lastAlphabet = $function[0]; - echo "\n"; - echo "## {$lastAlphabet}\n"; - echo "\n"; - echo "Excel Function | Category | PhpSpreadsheet Function\n"; - echo "--------------------|--------------------------------|-------------------------------------------\n"; - } - echo str_pad($function, 20) - . '| ' . str_pad($categoryConstants[$functionInfo['category']], 31) - . '| ' . self::getPhpSpreadsheetFunctionText($functionInfo['functionCall']) - . "\n"; + $result = "# Function list by name\n"; + $lastAlphabet = null; + foreach ($phpSpreadsheetFunctions as $excelFunction => $functionInfo) { + $lengths = [20, 31, 42]; + if ($lastAlphabet !== $excelFunction[0]) { + $lastAlphabet = $excelFunction[0]; + $result .= "\n"; + $result .= "## {$lastAlphabet}\n"; + $result .= "\n"; + $result .= self::tableRow($lengths, ['Excel Function', 'Category', 'PhpSpreadsheet Function']) . "\n"; + $result .= self::tableRow($lengths, null) . "\n"; } - } finally { - file_put_contents(__DIR__ . '/../../docs/references/function-list-by-name.md', ob_get_clean()); + $category = $categoryConstants[$functionInfo['category']]; + $phpFunction = self::getPhpSpreadsheetFunctionText($functionInfo['functionCall']); + $result .= self::tableRow($lengths, [$excelFunction, $category, $phpFunction]) . "\n"; } + + return $result; } -} \ No newline at end of file +} From 32a8ef5e33638668d6a399a5b3e65aba45dbbaa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=E4=B8=8B=E5=85=8B=E5=BD=A6?= Date: Tue, 25 Feb 2020 09:52:32 +0900 Subject: [PATCH 5/6] DocumentGeneratorTest --- .../DocumentGeneratorTest.php | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 tests/PhpSpreadsheetTests/DocumentGeneratorTest.php diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php new file mode 100644 index 00000000..da0eb4bd --- /dev/null +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -0,0 +1,141 @@ + ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'], + 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']], + 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']], + ], + <<<'EXPECTED' +# Function list by name + +## A + +Excel Function | Category | PhpSpreadsheet Function +--------------------|--------------------------------|------------------------------------------- +ABS | CATEGORY_MATH_AND_TRIG | abs +AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd + +## I + +Excel Function | Category | PhpSpreadsheet Function +--------------------|--------------------------------|------------------------------------------- +IFS | CATEGORY_LOGICAL | **Not yet Implemented** + +EXPECTED + + ], + ]; + } + + public function providerGenerateFunctionListByCategory(): array + { + return [ + [ + [ + 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'], + 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']], + 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']], + ], + <<<'EXPECTED' +# Function list by category + +## CATEGORY_CUBE + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_DATABASE + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_DATE_AND_TIME + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_ENGINEERING + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_FINANCIAL + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_INFORMATION + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_LOGICAL + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- +AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd +IFS | **Not yet Implemented** + +## CATEGORY_LOOKUP_AND_REFERENCE + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_MATH_AND_TRIG + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- +ABS | abs + +## CATEGORY_STATISTICAL + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +## CATEGORY_TEXT_AND_DATA + +Excel Function | PhpSpreadsheet Function +--------------------|------------------------------------------- + +EXPECTED + + ], + ]; + } +} From 23f26fa6162c23f17d4700ca9c96e5b6f166827c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=E4=B8=8B=E5=85=8B=E5=BD=A6?= Date: Tue, 25 Feb 2020 10:41:00 +0900 Subject: [PATCH 6/6] phpcs fix --- tests/PhpSpreadsheetTests/DocumentGeneratorTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php index da0eb4bd..b0aed466 100644 --- a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -12,8 +12,10 @@ class DocumentGeneratorTest extends TestCase { /** * @dataProvider providerGenerateFunctionListByName + * * @param array $phpSpreadsheetFunctions * @param string $expected + * * @throws \ReflectionException */ public function testGenerateFunctionListByName(array $phpSpreadsheetFunctions, string $expected): void @@ -23,8 +25,10 @@ class DocumentGeneratorTest extends TestCase /** * @dataProvider providerGenerateFunctionListByCategory + * * @param array $phpSpreadsheetFunctions * @param string $expected + * * @throws \ReflectionException */ public function testGenerateFunctionListByCategory(array $phpSpreadsheetFunctions, string $expected): void