@@ -102,26 +102,22 @@ public static function convertToR1C1(
102102 ?int $ currentRowNumber = null ,
103103 ?int $ currentColumnNumber = null
104104 ): string {
105- $ validityCheck = preg_match ('/^(\$?[A-Z]{1,3})(\$?\d{1,7})$/i ' , $ address , $ cellReference );
105+ $ validityCheck = preg_match ('/^(\$?)( [A-Z]{1,3})(\$?)( \d{1,7})$/i ' , $ address , $ cellReference );
106106
107107 if ($ validityCheck === 0 ) {
108108 throw new Exception ('Invalid A1-format Cell Reference ' );
109109 }
110110
111- if ($ cellReference [1 ][ 0 ] === ' $ ' ) {
112- $ columnId = Coordinate:: columnIndexFromString ( substr ( $ cellReference [1 ], 1 ));
111+ $ columnId = Coordinate:: columnIndexFromString ($ cellReference [2 ]);
112+ if ( $ cellReference [1 ] === ' $ ' ) {
113113 // Column must be absolute address
114114 $ currentColumnNumber = null ;
115- } else {
116- $ columnId = Coordinate::columnIndexFromString ($ cellReference [1 ]);
117115 }
118116
119- if ( $ cellReference [ 2 ][ 0 ] === ' $ ' ) {
120- $ rowId = ( int ) substr ( $ cellReference [2 ], 1 );
117+ $ rowId = ( int ) $ cellReference [ 4 ];
118+ if ( $ cellReference [3 ] === ' $ ' ) {
121119 // Row must be absolute address
122120 $ currentRowNumber = null ;
123- } else {
124- $ rowId = (int ) $ cellReference [2 ];
125121 }
126122
127123 if ($ currentRowNumber !== null ) {
0 commit comments