@@ -42,10 +42,9 @@ public static function validateCellAddress($cellAddress): string
4242 public static function validateCellOrCellRange ($ cellRange ): string
4343 {
4444 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 );
4948 } elseif (is_object ($ cellRange ) && $ cellRange instanceof CellAddress) {
5049 $ cellRange = new CellRange ($ cellRange , $ cellRange );
5150 }
@@ -66,9 +65,12 @@ public static function validateCellRange($cellRange): string
6665 [$ worksheet , $ addressRange ] = Worksheet::extractSheetTitle ($ cellRange , true );
6766
6867 // 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+ );
7274
7375 return empty ($ worksheet ) ? strtoupper ($ addressRange ) : $ worksheet . '! ' . strtoupper ($ addressRange );
7476 }
0 commit comments