You are here

function PHPExcel_Writer_Excel5_Parser::_packExtRef in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php \PHPExcel_Writer_Excel5_Parser::_packExtRef()

* Convert the sheet name part of an external reference, for example "Sheet1" or * "Sheet1:Sheet2", to a packed structure. * * @access private *

Parameters

string $ext_ref The name of the external reference: * @return string The reference index in packed() format

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Parser.php, line 804

Class

PHPExcel_Writer_Excel5_Parser
PHPExcel_Writer_Excel5_Parser

Code

function _packExtRef($ext_ref) {
  $ext_ref = preg_replace("/^'/", '', $ext_ref);

  // Remove leading  ' if any.
  $ext_ref = preg_replace("/'\$/", '', $ext_ref);

  // Remove trailing ' if any.
  // 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 PHPExcel_Writer_Exception("Unknown sheet name {$sheet_name1} in formula");
    }
    $sheet2 = $this
      ->_getSheetIndex($sheet_name2);
    if ($sheet2 == -1) {
      throw new PHPExcel_Writer_Exception("Unknown sheet name {$sheet_name2} in formula");
    }

    // Reverse max and min sheet numbers if necessary
    if ($sheet1 > $sheet2) {
      list($sheet1, $sheet2) = array(
        $sheet2,
        $sheet1,
      );
    }
  }
  else {

    // Single sheet name only.
    $sheet1 = $this
      ->_getSheetIndex($ext_ref);
    if ($sheet1 == -1) {
      throw new PHPExcel_Writer_Exception("Unknown sheet name {$ext_ref} in formula");
    }
    $sheet2 = $sheet1;
  }

  // References are stored relative to 0xFFFF.
  $offset = -1 - $sheet1;
  return pack('vdvv', $offset, 0x0, $sheet1, $sheet2);
}