@@ -42,10 +42,9 @@ public static function validateCellAddress($cellAddress): string
42
42
public static function validateCellOrCellRange ($ cellRange ): string
43
43
{
44
44
if (is_string ($ cellRange ) || is_numeric ($ cellRange )) {
45
- // Convert a single column reference like 'A' to 'A:A'
46
- $ cellRange = (string ) preg_replace ('/^([A-Z]+)$/ ' , '${1}:${1} ' , (string ) $ cellRange );
47
- // Convert a single row reference like '1' to '1:1'
48
- $ cellRange = (string ) preg_replace ('/^(\d+)$/ ' , '${1}:${1} ' , $ cellRange );
45
+ // Convert a single column reference like 'A' to 'A:A',
46
+ // a single row reference like '1' to '1:1'
47
+ $ cellRange = (string ) preg_replace ('/^([A-Z]+|\d+)$/ ' , '${1}:${1} ' , (string ) $ cellRange );
49
48
} elseif (is_object ($ cellRange ) && $ cellRange instanceof CellAddress) {
50
49
$ cellRange = new CellRange ($ cellRange , $ cellRange );
51
50
}
@@ -66,9 +65,12 @@ public static function validateCellRange($cellRange): string
66
65
[$ worksheet , $ addressRange ] = Worksheet::extractSheetTitle ($ cellRange , true );
67
66
68
67
// Convert Column ranges like 'A:C' to 'A1:C1048576'
69
- $ addressRange = (string ) preg_replace ('/^([A-Z]+):([A-Z]+)$/ ' , '${1}1:${2}1048576 ' , $ addressRange );
70
- // Convert Row ranges like '1:3' to 'A1:XFD3'
71
- $ addressRange = (string ) preg_replace ('/^( \\d+):( \\d+)$/ ' , 'A${1}:XFD${2} ' , $ addressRange );
68
+ // or Row ranges like '1:3' to 'A1:XFD3'
69
+ $ addressRange = (string ) preg_replace (
70
+ ['/^([A-Z]+):([A-Z]+)$/i ' , '/^( \\d+):( \\d+)$/ ' ],
71
+ ['${1}1:${2}1048576 ' , 'A${1}:XFD${2} ' ],
72
+ $ addressRange
73
+ );
72
74
73
75
return empty ($ worksheet ) ? strtoupper ($ addressRange ) : $ worksheet . '! ' . strtoupper ($ addressRange );
74
76
}
0 commit comments