1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpOffice\PhpSpreadsheet\Writer\Xlsx; |
4
|
|
|
|
5
|
|
|
class FunctionPrefix |
6
|
|
|
{ |
7
|
|
|
const XLFNREGEXP = '/(?:_xlfn\.)?((?:_xlws\.)?(' |
8
|
|
|
// functions added with Excel 2010 |
9
|
|
|
. 'beta[.]dist' |
10
|
|
|
. '|beta[.]inv' |
11
|
|
|
. '|binom[.]dist' |
12
|
|
|
. '|binom[.]inv' |
13
|
|
|
. '|ceiling[.]precise' |
14
|
|
|
. '|chisq[.]dist' |
15
|
|
|
. '|chisq[.]dist[.]rt' |
16
|
|
|
. '|chisq[.]inv' |
17
|
|
|
. '|chisq[.]inv[.]rt' |
18
|
|
|
. '|chisq[.]test' |
19
|
|
|
. '|confidence[.]norm' |
20
|
|
|
. '|confidence[.]t' |
21
|
|
|
. '|covariance[.]p' |
22
|
|
|
. '|covariance[.]s' |
23
|
|
|
. '|erf[.]precise' |
24
|
|
|
. '|erfc[.]precise' |
25
|
|
|
. '|expon[.]dist' |
26
|
|
|
. '|f[.]dist' |
27
|
|
|
. '|f[.]dist[.]rt' |
28
|
|
|
. '|f[.]inv' |
29
|
|
|
. '|f[.]inv[.]rt' |
30
|
|
|
. '|f[.]test' |
31
|
|
|
. '|floor[.]precise' |
32
|
|
|
. '|gamma[.]dist' |
33
|
|
|
. '|gamma[.]inv' |
34
|
|
|
. '|gammaln[.]precise' |
35
|
|
|
. '|lognorm[.]dist' |
36
|
|
|
. '|lognorm[.]inv' |
37
|
|
|
. '|mode[.]mult' |
38
|
|
|
. '|mode[.]sngl' |
39
|
|
|
. '|negbinom[.]dist' |
40
|
|
|
. '|networkdays[.]intl' |
41
|
|
|
. '|norm[.]dist' |
42
|
|
|
. '|norm[.]inv' |
43
|
|
|
. '|norm[.]s[.]dist' |
44
|
|
|
. '|norm[.]s[.]inv' |
45
|
|
|
. '|percentile[.]exc' |
46
|
|
|
. '|percentile[.]inc' |
47
|
|
|
. '|percentrank[.]exc' |
48
|
|
|
. '|percentrank[.]inc' |
49
|
|
|
. '|poisson[.]dist' |
50
|
|
|
. '|quartile[.]exc' |
51
|
|
|
. '|quartile[.]inc' |
52
|
|
|
. '|rank[.]avg' |
53
|
|
|
. '|rank[.]eq' |
54
|
|
|
. '|stdev[.]p' |
55
|
|
|
. '|stdev[.]s' |
56
|
|
|
. '|t[.]dist' |
57
|
|
|
. '|t[.]dist[.]2t' |
58
|
|
|
. '|t[.]dist[.]rt' |
59
|
|
|
. '|t[.]inv' |
60
|
|
|
. '|t[.]inv[.]2t' |
61
|
|
|
. '|t[.]test' |
62
|
|
|
. '|var[.]p' |
63
|
|
|
. '|var[.]s' |
64
|
|
|
. '|weibull[.]dist' |
65
|
|
|
. '|z[.]test' |
66
|
|
|
// functions added with Excel 2013 |
67
|
|
|
. '|acot' |
68
|
|
|
. '|acoth' |
69
|
|
|
. '|arabic' |
70
|
|
|
. '|averageifs' |
71
|
|
|
. '|binom[.]dist[.]range' |
72
|
|
|
. '|bitand' |
73
|
|
|
. '|bitlshift' |
74
|
|
|
. '|bitor' |
75
|
|
|
. '|bitrshift' |
76
|
|
|
. '|bitxor' |
77
|
|
|
. '|ceiling[.]math' |
78
|
|
|
. '|combina' |
79
|
|
|
. '|cot' |
80
|
|
|
. '|coth' |
81
|
|
|
. '|csc' |
82
|
|
|
. '|csch' |
83
|
|
|
. '|days' |
84
|
|
|
. '|dbcs' |
85
|
|
|
. '|decimal' |
86
|
|
|
. '|encodeurl' |
87
|
|
|
. '|filterxml' |
88
|
|
|
. '|floor[.]math' |
89
|
|
|
. '|formulatext' |
90
|
|
|
. '|gamma' |
91
|
|
|
. '|gauss' |
92
|
|
|
. '|ifna' |
93
|
|
|
. '|imcosh' |
94
|
|
|
. '|imcot' |
95
|
|
|
. '|imcsc' |
96
|
|
|
. '|imcsch' |
97
|
|
|
. '|imsec' |
98
|
|
|
. '|imsech' |
99
|
|
|
. '|imsinh' |
100
|
|
|
. '|imtan' |
101
|
|
|
. '|isformula' |
102
|
|
|
. '|iso[.]ceiling' |
103
|
|
|
. '|isoweeknum' |
104
|
|
|
. '|munit' |
105
|
|
|
. '|numbervalue' |
106
|
|
|
. '|pduration' |
107
|
|
|
. '|permutationa' |
108
|
|
|
. '|phi' |
109
|
|
|
. '|rri' |
110
|
|
|
. '|sec' |
111
|
|
|
. '|sech' |
112
|
|
|
. '|sheet' |
113
|
|
|
. '|sheets' |
114
|
|
|
. '|skew[.]p' |
115
|
|
|
. '|unichar' |
116
|
|
|
. '|unicode' |
117
|
|
|
. '|webservice' |
118
|
|
|
. '|xor' |
119
|
|
|
// functions added with Excel 2016 |
120
|
|
|
. '|forecast[.]et2' |
121
|
|
|
. '|forecast[.]ets[.]confint' |
122
|
|
|
. '|forecast[.]ets[.]seasonality' |
123
|
|
|
. '|forecast[.]ets[.]stat' |
124
|
|
|
. '|forecast[.]linear' |
125
|
|
|
. '|switch' |
126
|
|
|
// functions added with Excel 2019 |
127
|
|
|
. '|concat' |
128
|
|
|
. '|countifs' |
129
|
|
|
. '|ifs' |
130
|
|
|
. '|maxifs' |
131
|
|
|
. '|minifs' |
132
|
|
|
. '|sumifs' |
133
|
|
|
. '|textjoin' |
134
|
|
|
// functions added with Excel 365 |
135
|
|
|
. '|filter' |
136
|
|
|
. '|randarray' |
137
|
|
|
. '|anchorarray' |
138
|
|
|
. '|sequence' |
139
|
|
|
. '|sort' |
140
|
|
|
. '|sortby' |
141
|
|
|
. '|unique' |
142
|
|
|
. '|xlookup' |
143
|
|
|
. '|xmatch' |
144
|
|
|
. '|arraytotext' |
145
|
|
|
. '|call' |
146
|
|
|
. '|let' |
147
|
|
|
. '|lambda' |
148
|
|
|
. '|single' |
149
|
|
|
. '|register[.]id' |
150
|
|
|
. '|textafter' |
151
|
|
|
. '|textbefore' |
152
|
|
|
. '|textsplit' |
153
|
|
|
. '|valuetotext' |
154
|
|
|
. '))\s*\(/Umui'; |
155
|
|
|
|
156
|
|
|
const XLWSREGEXP = '/(?<!_xlws\.)(' |
157
|
|
|
// functions added with Excel 365 |
158
|
|
|
. 'filter' |
159
|
|
|
. '|sort' |
160
|
|
|
. ')\s*\(/mui'; |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Prefix function name in string with _xlfn. where required. |
164
|
|
|
*/ |
165
|
|
|
protected static function addXlfnPrefix(string $functionString): string |
166
|
|
|
{ |
167
|
|
|
return (string) preg_replace(self::XLFNREGEXP, '_xlfn.$1(', $functionString); |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Prefix function name in string with _xlws. where required. |
172
|
|
|
*/ |
173
|
|
|
protected static function addXlwsPrefix(string $functionString): string |
174
|
|
|
{ |
175
|
|
|
return (string) preg_replace(self::XLWSREGEXP, '_xlws.$1(', $functionString); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Prefix function name in string with _xlfn. where required. |
180
|
|
|
*/ |
181
|
|
|
public static function addFunctionPrefix(string $functionString): string |
182
|
|
|
{ |
183
|
|
|
return self::addXlwsPrefix(self::addXlfnPrefix($functionString)); |
184
|
|
|
} |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Prefix function name in string with _xlfn. where required. |
188
|
|
|
* Leading character, expected to be equals sign, is stripped. |
189
|
|
|
*/ |
190
|
|
|
public static function addFunctionPrefixStripEquals(string $functionString): string |
191
|
|
|
{ |
192
|
|
|
return self::addFunctionPrefix(substr($functionString, 1)); |
193
|
|
|
} |
194
|
|
|
} |
195
|
|
|
|