Skip to content

Commit 1b96c95

Browse files
author
Mark Baker
authored
Add new Complex Number Functions introduced in MS Excel 2013 (#601)
* - Refactored Complex Engineering Functions to use external complex number library - Added calculation engine support for the new complex number functions that were added in MS Excel 2013 - IMCOSH() Returns the hyperbolic cosine of a complex number - IMCOT() Returns the cotangent of a complex number - IMCSC() Returns the cosecant of a complex number - IMCSCH() Returns the hyperbolic cosecant of a complex number - IMSEC() Returns the secant of a complex number - IMSECH() Returns the hyperbolic secant of a complex number - IMSINH() Returns the hyperbolic sine of a complex number - IMTAN() Returns the tangent of a complex number * Simplified the parseComplex() method in the PhpOffice\PhpSpreadsheet\Calculation\Engineering class, using Complex\Complex; and docblock flagged as deprecated
1 parent 57a0297 commit 1b96c95

23 files changed

+1598
-522
lines changed

CHANGELOG.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Support workbook view attributes for Xlsx format - [#523](https://github.com/PHPOffice/PhpSpreadsheet/issues/523)
1414
- Read and write hyperlink for drawing image - [#490](https://github.com/PHPOffice/PhpSpreadsheet/pull/490)
1515
- Added calculation engine support for the new bitwise functions that were added in MS Excel 2013
16-
- BITAND() Returns a Bitwise 'And' of two numbers
17-
- BITOR() Returns a Bitwise 'Or' of two number
18-
- BITXOR() Returns a Bitwise 'Exclusive Or' of two numbers
19-
- BITLSHIFT() Returns a number shifted left by a specified number of bits
20-
- BITRSHIFT() Returns a number shifted right by a specified number of bits
16+
- BITAND() Returns a Bitwise 'And' of two numbers
17+
- BITOR() Returns a Bitwise 'Or' of two number
18+
- BITXOR() Returns a Bitwise 'Exclusive Or' of two numbers
19+
- BITLSHIFT() Returns a number shifted left by a specified number of bits
20+
- BITRSHIFT() Returns a number shifted right by a specified number of bits
2121
- Added calculation engine support for other new functions that were added in MS Excel 2013 and MS Excel 2016
2222
- Text Functions
2323
- CONCAT() Synonym for CONCATENATE()
@@ -46,6 +46,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
4646
- COTH() Returns the hyperbolic cotangent of an angle
4747
- ACOT() Returns the cotangent of an angle
4848
- ACOTH() Returns the hyperbolic cotangent of an angle
49+
- Refactored Complex Engineering Functions to use external complex number library
50+
- Added calculation engine support for the new complex number functions that were added in MS Excel 2013
51+
- IMCOSH() Returns the hyperbolic cosine of a complex number
52+
- IMCOT() Returns the cotangent of a complex number
53+
- IMCSC() Returns the cosecant of a complex number
54+
- IMCSCH() Returns the hyperbolic cosecant of a complex number
55+
- IMSEC() Returns the secant of a complex number
56+
- IMSECH() Returns the hyperbolic secant of a complex number
57+
- IMSINH() Returns the hyperbolic sine of a complex number
58+
- IMTAN() Returns the tangent of a complex number
4959

5060
### Fixed
5161

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"ext-xmlwriter": "*",
4747
"ext-zip": "*",
4848
"ext-zlib": "*",
49-
"psr/simple-cache": "^1.0"
49+
"psr/simple-cache": "^1.0",
50+
"markbaker/complex": "^1.4.1"
5051
},
5152
"require-dev": {
5253
"tecnickcom/tcpdf": "^6.2",

composer.lock

+96-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/references/function-list-by-category.md

+8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ IMAGINARY | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMAGINA
8686
IMARGUMENT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMARGUMENT
8787
IMCONJUGATE | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCONJUGATE
8888
IMCOS | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCOS
89+
IMCOSH | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCOSH
90+
IMCOT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCOT
91+
IMCSC | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCSC
92+
IMCSCH | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCSCH
8993
IMDIV | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMDIV
9094
IMEXP | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMEXP
9195
IMLN | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMLN
@@ -94,10 +98,14 @@ IMLOG2 | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMLOG2
9498
IMPOWER | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMPOWER
9599
IMPRODUCT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMPRODUCT
96100
IMREAL | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMREAL
101+
IMSEC | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSEC
102+
IMSECH | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSECH
97103
IMSIN | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSIN
104+
IMSINH | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSINH
98105
IMSQRT | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSQRT
99106
IMSUB | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSUB
100107
IMSUM | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSUM
108+
IMTAN | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMTAN
101109
OCT2BIN | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::OCTTOBIN
102110
OCT2DEC | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::OCTTODEC
103111
OCT2HEX | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::OCTTOHEX

docs/references/function-list-by-name.md

+8
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ IMAGINARY | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet
206206
IMARGUMENT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMARGUMENT
207207
IMCONJUGATE | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCONJUGATE
208208
IMCOS | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCOS
209+
IMCOSH | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCOSH
210+
IMCOT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCOT
211+
IMCSC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCSC
212+
IMCSCH | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMCSCH
209213
IMDIV | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMDIV
210214
IMEXP | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMEXP
211215
IMLN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMLN
@@ -214,10 +218,14 @@ IMLOG2 | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet
214218
IMPOWER | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMPOWER
215219
IMPRODUCT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMPRODUCT
216220
IMREAL | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMREAL
221+
IMSEC | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSEC
222+
IMSECH | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSECH
217223
IMSIN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSIN
224+
IMSINH | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSINH
218225
IMSQRT | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSQRT
219226
IMSUB | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSUB
220227
IMSUM | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMSUM
228+
IMTAN | CATEGORY_ENGINEERING | \PhpOffice\PhpSpreadsheet\Calculation\Engineering::IMTAN
221229
INDEX | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::INDEX
222230
INDIRECT | CATEGORY_LOOKUP_AND_REFERENCE | \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::INDIRECT
223231
INFO | CATEGORY_INFORMATION | **Not yet Implemented**

src/PhpSpreadsheet/Calculation/Calculation.php

+40
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,26 @@ class Calculation
10381038
'functionCall' => [Engineering::class, 'IMCOS'],
10391039
'argumentCount' => '1',
10401040
],
1041+
'IMCOSH' => [
1042+
'category' => Category::CATEGORY_ENGINEERING,
1043+
'functionCall' => [Engineering::class, 'IMCOSH'],
1044+
'argumentCount' => '1',
1045+
],
1046+
'IMCOT' => [
1047+
'category' => Category::CATEGORY_ENGINEERING,
1048+
'functionCall' => [Engineering::class, 'IMCOT'],
1049+
'argumentCount' => '1',
1050+
],
1051+
'IMCSC' => [
1052+
'category' => Category::CATEGORY_ENGINEERING,
1053+
'functionCall' => [Engineering::class, 'IMCSC'],
1054+
'argumentCount' => '1',
1055+
],
1056+
'IMCSCH' => [
1057+
'category' => Category::CATEGORY_ENGINEERING,
1058+
'functionCall' => [Engineering::class, 'IMCSCH'],
1059+
'argumentCount' => '1',
1060+
],
10411061
'IMDIV' => [
10421062
'category' => Category::CATEGORY_ENGINEERING,
10431063
'functionCall' => [Engineering::class, 'IMDIV'],
@@ -1078,11 +1098,26 @@ class Calculation
10781098
'functionCall' => [Engineering::class, 'IMREAL'],
10791099
'argumentCount' => '1',
10801100
],
1101+
'IMSEC' => [
1102+
'category' => Category::CATEGORY_ENGINEERING,
1103+
'functionCall' => [Engineering::class, 'IMSEC'],
1104+
'argumentCount' => '1',
1105+
],
1106+
'IMSECH' => [
1107+
'category' => Category::CATEGORY_ENGINEERING,
1108+
'functionCall' => [Engineering::class, 'IMSECH'],
1109+
'argumentCount' => '1',
1110+
],
10811111
'IMSIN' => [
10821112
'category' => Category::CATEGORY_ENGINEERING,
10831113
'functionCall' => [Engineering::class, 'IMSIN'],
10841114
'argumentCount' => '1',
10851115
],
1116+
'IMSINH' => [
1117+
'category' => Category::CATEGORY_ENGINEERING,
1118+
'functionCall' => [Engineering::class, 'IMSINH'],
1119+
'argumentCount' => '1',
1120+
],
10861121
'IMSQRT' => [
10871122
'category' => Category::CATEGORY_ENGINEERING,
10881123
'functionCall' => [Engineering::class, 'IMSQRT'],
@@ -1098,6 +1133,11 @@ class Calculation
10981133
'functionCall' => [Engineering::class, 'IMSUM'],
10991134
'argumentCount' => '1+',
11001135
],
1136+
'IMTAN' => [
1137+
'category' => Category::CATEGORY_ENGINEERING,
1138+
'functionCall' => [Engineering::class, 'IMTAN'],
1139+
'argumentCount' => '1',
1140+
],
11011141
'INDEX' => [
11021142
'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,
11031143
'functionCall' => [LookupRef::class, 'INDEX'],

0 commit comments

Comments
 (0)