2
2
3
3
namespace PhpOffice \PhpSpreadsheet \Calculation \LookupRef ;
4
4
5
- use PhpOffice \PhpSpreadsheet \Calculation \Functions ;
5
+ use PhpOffice \PhpSpreadsheet \Calculation \ArrayEnabled ;
6
6
use PhpOffice \PhpSpreadsheet \Calculation \Information \ExcelError ;
7
7
use PhpOffice \PhpSpreadsheet \Cell \Coordinate ;
8
8
9
9
class Address
10
10
{
11
+ use ArrayEnabled;
12
+
11
13
public const ADDRESS_ABSOLUTE = 1 ;
12
14
public const ADDRESS_COLUMN_RELATIVE = 2 ;
13
15
public const ADDRESS_ROW_RELATIVE = 3 ;
@@ -25,26 +27,44 @@ class Address
25
27
* =ADDRESS(row, column, [relativity], [referenceStyle], [sheetText])
26
28
*
27
29
* @param mixed $row Row number (integer) to use in the cell reference
30
+ * Or can be an array of values
28
31
* @param mixed $column Column number (integer) to use in the cell reference
32
+ * Or can be an array of values
29
33
* @param mixed $relativity Integer flag indicating the type of reference to return
30
34
* 1 or omitted Absolute
31
35
* 2 Absolute row; relative column
32
36
* 3 Relative row; absolute column
33
37
* 4 Relative
38
+ * Or can be an array of values
34
39
* @param mixed $referenceStyle A logical (boolean) value that specifies the A1 or R1C1 reference style.
35
40
* TRUE or omitted ADDRESS returns an A1-style reference
36
41
* FALSE ADDRESS returns an R1C1-style reference
42
+ * Or can be an array of values
37
43
* @param mixed $sheetName Optional Name of worksheet to use
44
+ * Or can be an array of values
38
45
*
39
- * @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
40
49
*/
41
50
public static function cell ($ row , $ column , $ relativity = 1 , $ referenceStyle = true , $ sheetName = '' )
42
51
{
43
- $ row = Functions::flattenSingleValue ($ row );
44
- $ column = Functions::flattenSingleValue ($ column );
45
- $ relativity = ($ relativity === null ) ? 1 : Functions::flattenSingleValue ($ relativity );
46
- $ referenceStyle = ($ referenceStyle === null ) ? true : Functions::flattenSingleValue ($ referenceStyle );
47
- $ 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 ;
48
68
49
69
if (($ row < 1 ) || ($ column < 1 )) {
50
70
return ExcelError::VALUE ();
0 commit comments