2
2
3
3
namespace PhpOffice \PhpSpreadsheet \Calculation \LookupRef ;
4
4
5
+ use PhpOffice \PhpSpreadsheet \Calculation \ArrayEnabled ;
5
6
use PhpOffice \PhpSpreadsheet \Calculation \Functions ;
6
7
use PhpOffice \PhpSpreadsheet \Cell \Coordinate ;
7
8
8
9
class Address
9
10
{
11
+ use ArrayEnabled;
12
+
10
13
public const ADDRESS_ABSOLUTE = 1 ;
11
14
public const ADDRESS_COLUMN_RELATIVE = 2 ;
12
15
public const ADDRESS_ROW_RELATIVE = 3 ;
@@ -24,26 +27,44 @@ class Address
24
27
* =ADDRESS(row, column, [relativity], [referenceStyle], [sheetText])
25
28
*
26
29
* @param mixed $row Row number (integer) to use in the cell reference
30
+ * Or can be an array of values
27
31
* @param mixed $column Column number (integer) to use in the cell reference
32
+ * Or can be an array of values
28
33
* @param mixed $relativity Integer flag indicating the type of reference to return
29
34
* 1 or omitted Absolute
30
35
* 2 Absolute row; relative column
31
36
* 3 Relative row; absolute column
32
37
* 4 Relative
38
+ * Or can be an array of values
33
39
* @param mixed $referenceStyle A logical (boolean) value that specifies the A1 or R1C1 reference style.
34
40
* TRUE or omitted ADDRESS returns an A1-style reference
35
41
* FALSE ADDRESS returns an R1C1-style reference
42
+ * Or can be an array of values
36
43
* @param mixed $sheetName Optional Name of worksheet to use
44
+ * Or can be an array of values
37
45
*
38
- * @return string
46
+ * @return array|string
47
+ * If an array of values is passed as the $testValue argument, then the returned result will also be
48
+ * an array with the same dimensions
39
49
*/
40
50
public static function cell ($ row , $ column , $ relativity = 1 , $ referenceStyle = true , $ sheetName = '' )
41
51
{
42
- $ row = Functions::flattenSingleValue ($ row );
43
- $ column = Functions::flattenSingleValue ($ column );
44
- $ relativity = ($ relativity === null ) ? 1 : Functions::flattenSingleValue ($ relativity );
45
- $ referenceStyle = ($ referenceStyle === null ) ? true : Functions::flattenSingleValue ($ referenceStyle );
46
- $ sheetName = Functions::flattenSingleValue ($ sheetName );
52
+ if (
53
+ is_array ($ row ) || is_array ($ column ) ||
54
+ is_array ($ relativity ) || is_array ($ referenceStyle ) || is_array ($ sheetName )
55
+ ) {
56
+ return self ::evaluateArrayArguments (
57
+ [self ::class, __FUNCTION__ ],
58
+ $ row ,
59
+ $ column ,
60
+ $ relativity ,
61
+ $ referenceStyle ,
62
+ $ sheetName
63
+ );
64
+ }
65
+
66
+ $ relativity = $ relativity ?? 1 ;
67
+ $ referenceStyle = $ referenceStyle ?? true ;
47
68
48
69
if (($ row < 1 ) || ($ column < 1 )) {
49
70
return Functions::VALUE ();
0 commit comments