You are here

private function PHPExcel_Reader_Excel2007::_castToFormula in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php \PHPExcel_Reader_Excel2007::_castToFormula()
1 call to PHPExcel_Reader_Excel2007::_castToFormula()
PHPExcel_Reader_Excel2007::load in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php
* Loads PHPExcel from file * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/Excel2007.php, line 270

Class

PHPExcel_Reader_Excel2007
PHPExcel_Reader_Excel2007

Code

private function _castToFormula($c, $r, &$cellDataType, &$value, &$calculatedValue, &$sharedFormulas, $castBaseType) {

  //		echo 'Formula', PHP_EOL;
  //		echo '$c->f is ', $c->f, PHP_EOL;
  $cellDataType = 'f';
  $value = "={$c->f}";
  $calculatedValue = self::$castBaseType($c);

  // Shared formula?
  if (isset($c->f['t']) && strtolower((string) $c->f['t']) == 'shared') {

    //			echo 'SHARED FORMULA', PHP_EOL;
    $instance = (string) $c->f['si'];

    //			echo 'Instance ID = ', $instance, PHP_EOL;
    //
    //			echo 'Shared Formula Array:', PHP_EOL;
    //			print_r($sharedFormulas);
    if (!isset($sharedFormulas[(string) $c->f['si']])) {

      //				echo 'SETTING NEW SHARED FORMULA', PHP_EOL;
      //				echo 'Master is ', $r, PHP_EOL;
      //				echo 'Formula is ', $value, PHP_EOL;
      $sharedFormulas[$instance] = array(
        'master' => $r,
        'formula' => $value,
      );

      //				echo 'New Shared Formula Array:', PHP_EOL;
      //				print_r($sharedFormulas);
    }
    else {

      //				echo 'GETTING SHARED FORMULA', PHP_EOL;
      //				echo 'Master is ', $sharedFormulas[$instance]['master'], PHP_EOL;
      //				echo 'Formula is ', $sharedFormulas[$instance]['formula'], PHP_EOL;
      $master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
      $current = PHPExcel_Cell::coordinateFromString($r);
      $difference = array(
        0,
        0,
      );
      $difference[0] = PHPExcel_Cell::columnIndexFromString($current[0]) - PHPExcel_Cell::columnIndexFromString($master[0]);
      $difference[1] = $current[1] - $master[1];
      $value = $this->_referenceHelper
        ->updateFormulaReferences($sharedFormulas[$instance]['formula'], 'A1', $difference[0], $difference[1]);

      //				echo 'Adjusted Formula is ', $value, PHP_EOL;
    }
  }
}