You are here

private static function PHPExcel_Calculation::_translateFormula in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php \PHPExcel_Calculation::_translateFormula()
2 calls to PHPExcel_Calculation::_translateFormula()
PHPExcel_Calculation::_translateFormulaToEnglish in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php
PHPExcel_Calculation::_translateFormulaToLocale in vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php, line 2055

Class

PHPExcel_Calculation
PHPExcel_Calculation (Multiton)

Code

private static function _translateFormula($from, $to, $formula, $fromSeparator, $toSeparator) {

  //	Convert any Excel function names to the required language
  if (self::$_localeLanguage !== 'en_us') {
    $inBraces = FALSE;

    //	If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
    if (strpos($formula, '"') !== FALSE) {

      //	So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
      //		the formula
      $temp = explode('"', $formula);
      $i = FALSE;
      foreach ($temp as &$value) {

        //	Only count/replace in alternating array entries
        if ($i = !$i) {
          $value = preg_replace($from, $to, $value);
          $value = self::_translateSeparator($fromSeparator, $toSeparator, $value, $inBraces);
        }
      }
      unset($value);

      //	Then rebuild the formula string
      $formula = implode('"', $temp);
    }
    else {

      //	If there's no quoted strings, then we do a simple count/replace
      $formula = preg_replace($from, $to, $formula);
      $formula = self::_translateSeparator($fromSeparator, $toSeparator, $formula, $inBraces);
    }
  }
  return $formula;
}