本文整理汇总了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);
}
}
示例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;
}
示例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()