You are here

public static function PHPExcel_Calculation_LookupRef::INDIRECT in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php \PHPExcel_Calculation_LookupRef::INDIRECT()

* INDIRECT * * Returns the reference specified by a text string. * References are immediately evaluated to display their contents. * * Excel Function: * =INDIRECT(cellAddress) * * NOTE - INDIRECT() does not yet support the optional a1 parameter introduced in Excel 2010 * *

Parameters

cellAddress $cellAddress The cell address of the current cell (containing this formula): * @param PHPExcel_Cell $pCell The current cell (containing this formula) * @return mixed The cells referenced by cellAddress * * @todo Support for the optional a1 parameter introduced in Excel 2010 *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php, line 298

Class

PHPExcel_Calculation_LookupRef
PHPExcel_Calculation_LookupRef

Code

public static function INDIRECT($cellAddress = NULL, PHPExcel_Cell $pCell = NULL) {
  $cellAddress = PHPExcel_Calculation_Functions::flattenSingleValue($cellAddress);
  if (is_null($cellAddress) || $cellAddress === '') {
    return PHPExcel_Calculation_Functions::REF();
  }
  $cellAddress1 = $cellAddress;
  $cellAddress2 = NULL;
  if (strpos($cellAddress, ':') !== false) {
    list($cellAddress1, $cellAddress2) = explode(':', $cellAddress);
  }
  if (!preg_match('/^' . PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches) || !is_null($cellAddress2) && !preg_match('/^' . PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)) {
    if (!preg_match('/^' . PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) {
      return PHPExcel_Calculation_Functions::REF();
    }
    if (strpos($cellAddress, '!') !== FALSE) {
      list($sheetName, $cellAddress) = explode('!', $cellAddress);
      $sheetName = trim($sheetName, "'");
      $pSheet = $pCell
        ->getWorksheet()
        ->getParent()
        ->getSheetByName($sheetName);
    }
    else {
      $pSheet = $pCell
        ->getWorksheet();
    }
    return PHPExcel_Calculation::getInstance()
      ->extractNamedRange($cellAddress, $pSheet, FALSE);
  }
  if (strpos($cellAddress, '!') !== FALSE) {
    list($sheetName, $cellAddress) = explode('!', $cellAddress);
    $sheetName = trim($sheetName, "'");
    $pSheet = $pCell
      ->getWorksheet()
      ->getParent()
      ->getSheetByName($sheetName);
  }
  else {
    $pSheet = $pCell
      ->getWorksheet();
  }
  return PHPExcel_Calculation::getInstance()
    ->extractCellRange($cellAddress, $pSheet, FALSE);
}