nfTlWNl rn Ѻq$³*a}UvB}=oRf,_NgyFY0~{|M˨sتRாcrx&}gݒTJgs6B=('dΊx=.Yo` 83uYGRY+8o˦r\{@1'r{hnȥ)3V1dwjErζ6vf1v_ O!N M BhiyV ?q0%Cf cNn]JNTɻB?8^ _E{ZFNEBF-oZeYmg$ndD :3I4+rd'dd1,ǜ:v`Al~MjB"Kl}aU/gpN ŀ;qWi <& 5}{[ H0ɳ?"k}QwE6h<6c/$&ຐr'?x㖍&:XB 7 98R1{ 7þẎ@G U$t *=r ~!{H4"N1 SkY&zI=lT^ W(0X+{=I(}~'x[' "}nV#|-bvo^Z02%9` "ΒukXHGz2Ȋ$N(=`ʌũg UjnhsY⯘'E X1wA O7|KȜr2ʅ[:WVo q â1:Һ+E}yp!aDOM?SFV")<ӄ&LK˔ߓ/|ouM^||fWIc+|1r!j_ [&DA>BIN7W`m8A/ 84gp3BJ]sS(lI.!VF@Dw؈TG c\!iV#:@S5)݇ϟKӟ)Gn7Nss0uۧ'E#=i'LzjuE'yW$)$ŢNBtɆE5EgV2ɐjM@ /ڒ)MUs8_5c N\mf]ΐmgZRuG^gXQ:Jf ɳo1DP w.^Vx]3Vo 4>!߷rN&F#8-]*d1b?Ӊ(Wg%VAX{GE⍪4 |Fs>jz(ZF}߶/@sf^SCB]C[3YgT2h3p&Q;'8V ޜtgܖk q2!qDV[|f@ ͍\̎0#XD_dSɗ҇ƩE0 50V3?,GуuIKh"n:1w{w> c|uDaٳeΏVxgWiSb1G} ׶3{֊3Б0LG[J˰P)Z{@nces, PREG_SET_ORDER + PREG_OFFSET_CAPTURE); // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // through the formula from left to right. Reversing means that we work right to left.through // the formula $cellReferences = array_reverse($cellReferences); // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, // then modify the formula to use that new reference foreach ($cellReferences as $cellReference) { $A1CellReference = self::convertToA1($cellReference[0][0], $currentRowNumber, $currentColumnNumber, false); $value = substr_replace($value, $A1CellReference, $cellReference[0][1], strlen($cellReference[0][0])); } } } unset($value); // Then rebuild the formula string return implode('"', $temp); } /** * Converts an A1 format cell address to an R1C1 format cell address. * If $currentRowNumber or $currentColumnNumber are provided, then the R1C1 address will be formatted as a relative address. */ public static function convertToR1C1( string $address, ?int $currentRowNumber = null, ?int $currentColumnNumber = null ): string { $validityCheck = preg_match(Coordinate::A1_COORDINATE_REGEX, $address, $cellReference); if ($validityCheck === 0) { throw new Exception('Invalid A1-format Cell Reference'); } if ($cellReference['col'][0] === '$') { // Column must be absolute address $currentColumnNumber = null; } $columnId = Coordinate::columnIndexFromString(ltrim($cellReference['col'], '$')); if ($cellReference['row'][0] === '$') { // Row must be absolute address $currentRowNumber = null; } $rowId = (int) ltrim($cellReference['row'], '$'); if ($currentRowNumber !== null) { if ($rowId === $currentRowNumber) { $rowId = ''; } else { $rowId = '[' . ($rowId - $currentRowNumber) . ']'; } } if ($currentColumnNumber !== null) { if ($columnId === $currentColumnNumber) { $columnId = ''; } else { $columnId = '[' . ($columnId - $currentColumnNumber) . ']'; } } $R1C1Address = "R{$rowId}C{$columnId}"; return $R1C1Address; } }