当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPExcel_Shared_String::convertToNumberIfFraction方法代码示例

本文整理汇总了PHP中PHPExcel_Shared_String::convertToNumberIfFraction方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPExcel_Shared_String::convertToNumberIfFraction方法的具体用法?PHP PHPExcel_Shared_String::convertToNumberIfFraction怎么用?PHP PHPExcel_Shared_String::convertToNumberIfFraction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPExcel_Shared_String的用法示例。


在下文中一共展示了PHPExcel_Shared_String::convertToNumberIfFraction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: power

 /**
  *    power
  *
  *    A = A ^ B
  *    @param mixed $B Matrix/Array
  *    @return Matrix Sum
  */
 public function power()
 {
     if (func_num_args() > 0) {
         $args = func_get_args();
         $match = implode(",", array_map('gettype', $args));
         switch ($match) {
             case 'object':
                 if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) {
                     $M = $args[0];
                 } else {
                     throw new PHPExcel_Calculation_Exception(self::ARGUMENT_TYPE_EXCEPTION);
                 }
                 break;
             case 'array':
                 $M = new PHPExcel_Shared_JAMA_Matrix($args[0]);
                 break;
             default:
                 throw new PHPExcel_Calculation_Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
                 break;
         }
         $this->checkMatrixDimensions($M);
         for ($i = 0; $i < $this->m; ++$i) {
             for ($j = 0; $j < $this->n; ++$j) {
                 $validValues = true;
                 $value = $M->get($i, $j);
                 if (is_string($this->A[$i][$j]) && strlen($this->A[$i][$j]) > 0 && !is_numeric($this->A[$i][$j])) {
                     $this->A[$i][$j] = trim($this->A[$i][$j], '"');
                     $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
                 }
                 if (is_string($value) && strlen($value) > 0 && !is_numeric($value)) {
                     $value = trim($value, '"');
                     $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
                 }
                 if ($validValues) {
                     $this->A[$i][$j] = pow($this->A[$i][$j], $value);
                 } else {
                     $this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
                 }
             }
         }
         return $this;
     } else {
         throw new PHPExcel_Calculation_Exception(self::POLYMORPHIC_ARGUMENT_EXCEPTION);
     }
 }
开发者ID:alyayazilim,项目名称:E-Ticaret-2015,代码行数:52,代码来源:Matrix.php

示例2: _validateBinaryOperand

 private function _validateBinaryOperand($cellID, &$operand, &$stack)
 {
     if (is_array($operand)) {
         if (count($operand, COUNT_RECURSIVE) - count($operand) == 1) {
             do {
                 $operand = array_pop($operand);
             } while (is_array($operand));
         }
     }
     //	Numbers, matrices and booleans can pass straight through, as they're already valid
     if (is_string($operand)) {
         //	We only need special validations for the operand if it is a string
         //	Start by stripping off the quotation marks we use to identify true excel string values internally
         if ($operand > '' && $operand[0] == '"') {
             $operand = self::_unwrapResult($operand);
         }
         //	If the string is a numeric value, we treat it as a numeric, so no further testing
         if (!is_numeric($operand)) {
             //	If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
             if ($operand > '' && $operand[0] == '#') {
                 $stack->push('Value', $operand);
                 $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($operand));
                 return FALSE;
             } elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) {
                 //	If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations
                 $stack->push('Value', '#VALUE!');
                 $this->_debugLog->writeDebugLog('Evaluation Result is a ', $this->_showTypeDetails('#VALUE!'));
                 return FALSE;
             }
         }
     }
     //	return a true if the value of the operand is one that we can use in normal binary operations
     return TRUE;
 }
开发者ID:Princelo,项目名称:bioerp,代码行数:34,代码来源:Calculation.php

示例3: power

	/**
	 *	power
	 *
	 *	A = A ^ B
	 *	@param mixed $B Matrix/Array
	 *	@return Matrix Sum
	 */
	public function power() {
		if (func_num_args() > 0) {
			$args = func_get_args();
			$match = implode(",", array_map('gettype', $args));

			switch($match) {
				case 'object':
						if ($args[0] instanceof Matrix) { $M = $args[0]; } else { throw new Exception(JAMAError(ArgumentTypeException)); }
						break;
				case 'array':
						$M = new Matrix($args[0]);
						break;
				default:
						throw new Exception(JAMAError(PolymorphicArgumentException));
						break;
			}
			$this->checkMatrixDimensions($M);
			for($i = 0; $i < $this->m; ++$i) {
				for($j = 0; $j < $this->n; ++$j) {
					$validValues = True;
					$value = $M->get($i, $j);
					if ((is_string($this->A[$i][$j])) && (strlen($this->A[$i][$j]) > 0) && (!is_numeric($this->A[$i][$j]))) {
						$this->A[$i][$j] = trim($this->A[$i][$j],'"');
						$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($this->A[$i][$j]);
					}
					if ((is_string($value)) && (strlen($value) > 0) && (!is_numeric($value))) {
						$value = trim($value,'"');
						$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
					}
					if ($validValues) {
						$this->A[$i][$j] = pow($this->A[$i][$j],$value);
					} else {
						$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
					}
				}
			}
			return $this;
		} else {
			throw new Exception(JAMAError(PolymorphicArgumentException));
		}
	}	//	function power()
开发者ID:Opmantek,项目名称:open-audit,代码行数:48,代码来源:Matrix.php


注:本文中的PHPExcel_Shared_String::convertToNumberIfFraction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。