Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Xls/Parser.php
private function getRefIndex($ext_ref)
    {
        $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading  ' if any.
        $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
        $ext_ref = str_replace('\'\'', '\'', $ext_ref); // Replace escaped '' with '

        // Check if there is a sheet range eg., Sheet1:Sheet2.
        if (preg_match('/:/', $ext_ref)) {
            list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);

            $sheet1 = $this->getSheetIndex($sheet_name1);
            if ($sheet1 == -1) {
                throw new WriterException("Unknown sheet name $sheet_name1 in formula");
            }
            $sheet2 = $this->getSheetIndex($sheet_name2);
            if ($sheet2 == -1) {
                throw new WriterException("Unknown sheet name $sheet_name2 in formula");
            }

            // Reverse max and min sheet numbers if necessary
            if ($sheet1 > $sheet2) {
                list($sheet1, $sheet2) = [$sheet2, $sheet1];
            }
        } else { // Single sheet name only.
            $sheet1 = $this->getSheetIndex($ext_ref);
            if ($sheet1 == -1) {
                throw new WriterException("Unknown sheet name $ext_ref in formula");
            }
            $sheet2 = $sheet1;
        }

        // assume all references belong to this document
        $supbook_index = 0x00;
        $ref = pack('vvv', $supbook_index, $sheet1, $sheet2);
        $totalreferences = count($this->references);
        $index = -1;
        for ($i = 0; $i < $totalreferences; ++$i) {
            if ($ref == $this->references[$i]) {
                $index = $i;

                break;
            }
        }
        // if REF was not found add it to references array
        if ($index == -1) {
            $this->references[$totalreferences] = $ref;
            $index = $totalreferences;
        }

        return pack('v', $index);
    }
private function getRefIndex($ext_ref)
    {
        $ext_ref = preg_replace("/^'/", '', $ext_ref); // Remove leading  ' if any.
        $ext_ref = preg_replace("/'$/", '', $ext_ref); // Remove trailing ' if any.
        $ext_ref = str_replace('\'\'', '\'', $ext_ref); // Replace escaped '' with '

        // Check if there is a sheet range eg., Sheet1:Sheet2.
        if (preg_match('/:/', $ext_ref)) {
            list($sheet_name1, $sheet_name2) = explode(':', $ext_ref);

            $sheet1 = $this->getSheetIndex($sheet_name1);
            if ($sheet1 == -1) {
                throw new WriterException("Unknown sheet name $sheet_name1 in formula");
            }
            $sheet2 = $this->getSheetIndex($sheet_name2);
            if ($sheet2 == -1) {
                throw new WriterException("Unknown sheet name $sheet_name2 in formula");
            }

            // Reverse max and min sheet numbers if necessary
            if ($sheet1 > $sheet2) {
                list($sheet1, $sheet2) = [$sheet2, $sheet1];
            }
        } else { // Single sheet name only.
            $sheet1 = $this->getSheetIndex($ext_ref);
            if ($sheet1 == -1) {
                throw new WriterException("Unknown sheet name $ext_ref in formula");
            }
            $sheet2 = $sheet1;
        }

        // assume all references belong to this document
        $supbook_index = 0x00;
        $ref = pack('vvv', $supbook_index, $sheet1, $sheet2);
        $totalreferences = count($this->references);
        $index = -1;
        for ($i = 0; $i < $totalreferences; ++$i) {
            if ($ref == $this->references[$i]) {
                $index = $i;

                break;
            }
        }
        // if REF was not found add it to references array
        if ($index == -1) {
            $this->references[$totalreferences] = $ref;
            $index = $totalreferences;
        }

        return pack('v', $index);
    }
private function getRefIndex ( $ ext_ref ) { $ ext_ref = preg_replace ( "/^'/" , '' , $ ext_ref ) ; // Remove leading  ' if any. $ ext_ref = preg_replace ( "/'$/" , '' , $ ext_ref ) ; // Remove trailing ' if any. $ ext_ref = str_replace ( '\'\'' , '\'' , $ ext_ref ) ; // Replace escaped '' with ' // Check if there is a sheet range eg., Sheet1:Sheet2. if ( preg_match ( '/:/' , $ ext_ref ) ) { list ( $ sheet_name1 , $ sheet_name2 ) = explode ( ':' , $ ext_ref ) ; $ sheet1 = $ this -> getSheetIndex ( $ sheet_name1 ) ; if ( $ sheet1 == - 1 ) { throw new WriterException ( "Unknown sheet name $sheet_name1 in formula" ) ; } $ sheet2 = $ this -> getSheetIndex ( $ sheet_name2 ) ; if ( $ sheet2 == - 1 ) { throw new WriterException ( "Unknown sheet name $sheet_name2 in formula" ) ; } // Reverse max and min sheet numbers if necessary if ( $ sheet1 > $ sheet2 ) { list ( $ sheet1 , $ sheet2 ) = [ $ sheet2 , $ sheet1 ] ; } } else { // Single sheet name only. $ sheet1 = $ this -> getSheetIndex ( $ ext_ref ) ; if ( $ sheet1 == - 1 ) { throw new WriterException ( "Unknown sheet name $ext_ref in formula" ) ; } $ sheet2 = $ sheet1 ; } // assume all references belong to this document $ supbook_index = 0x00 ; $ ref = pack ( 'vvv' , $ supbook_index , $ sheet1 , $ sheet2 ) ; $ totalreferences = count ( $ this -> references ) ; $ index = - 1 ; for ( $ i = 0 ; $ i < $ totalreferences ; ++ $ i ) { if ( $ ref == $ this -> references [ $ i ] ) { $ index = $ i ; break ; } } // if REF was not found add it to references array if ( $ index == - 1 ) { $ this -> references [ $ totalreferences ] = $ ref ; $ index = $ totalreferences ; } return pack ( 'v' , $ index ) ; }
Look up the REF index that corresponds to an external sheet name
(or range). If it doesn't exist yet add it to the workbook's references
array. It assumes all sheet names given must exist.

@param string $ext_ref The name of the external reference

@return mixed The reference index in packed() format on success
Look up the REF index that corresponds to an external sheet name ( or range ) . If it doesn t exist yet add it to the workbook s references array . It assumes all sheet names given must exist .