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


PHP PHPExcel_Calculation_Functions::_ifCondition方法代码示例

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


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

示例1: __filter

	private static function __filter($database, $criteria) {
		$fieldNames = array_shift ( $database );
		$criteriaNames = array_shift ( $criteria );
		
		// Convert the criteria into a set of AND/OR conditions with
		// [:placeholders]
		$testConditions = $testValues = array ();
		$testConditionsCount = 0;
		foreach ( $criteriaNames as $key => $criteriaName ) {
			$testCondition = array ();
			$testConditionCount = 0;
			foreach ( $criteria as $row => $criterion ) {
				if ($criterion [$key] > '') {
					$testCondition [] = '[:' . $criteriaName . ']' . PHPExcel_Calculation_Functions::_ifCondition ( $criterion [$key] );
					$testConditionCount ++;
				}
			}
			if ($testConditionCount > 1) {
				$testConditions [] = 'OR(' . implode ( ',', $testCondition ) . ')';
				$testConditionsCount ++;
			} elseif ($testConditionCount == 1) {
				$testConditions [] = $testCondition [0];
				$testConditionsCount ++;
			}
		}
		if ($testConditionsCount > 1) {
			$testConditionSet = 'AND(' . implode ( ',', $testConditions ) . ')';
		} elseif ($testConditionsCount == 1) {
			$testConditionSet = $testConditions [0];
		}
		
		// Loop through each row of the database
		foreach ( $database as $dataRow => $dataValues ) {
			// Substitute actual values from the database row for our
			// [:placeholders]
			$testConditionList = $testConditionSet;
			foreach ( $criteriaNames as $key => $criteriaName ) {
				$k = array_search ( $criteriaName, $fieldNames );
				if (isset ( $dataValues [$k] )) {
					$dataValue = $dataValues [$k];
					$dataValue = (is_string ( $dataValue )) ? PHPExcel_Calculation::_wrapResult ( strtoupper ( $dataValue ) ) : $dataValue;
					$testConditionList = str_replace ( '[:' . $criteriaName . ']', $dataValue, $testConditionList );
				}
			}
			// evaluate the criteria against the row data
			$result = PHPExcel_Calculation::getInstance ()->_calculateFormulaValue ( '=' . $testConditionList );
			// If the row failed to meet the criteria, remove it from the
			// database
			if (! $result) {
				unset ( $database [$dataRow] );
			}
		}
		
		return $database;
	}
开发者ID:nanpeixoto,项目名称:cide,代码行数:55,代码来源:Database.php

示例2: MINIF

 /**
  *	MINIF
  *
  *	Returns the minimum value within a range of cells that contain numbers within the list of arguments
  *
  *	Excel Function:
  *		MINIF(value1[,value2[, ...]],condition)
  *
  *	@access	public
  *	@category Mathematical and Trigonometric Functions
  *	@param	mixed		$arg,...		Data values
  *	@param	string		$condition		The criteria that defines which cells will be checked.
  *	@return	float
  */
 public static function MINIF($aArgs, $condition, $sumArgs = array())
 {
     // Return value
     $returnValue = null;
     $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
     $sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
     if (count($sumArgs) == 0) {
         $sumArgs = $aArgs;
     }
     $condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
     // Loop through arguments
     foreach ($aArgs as $key => $arg) {
         if (!is_numeric($arg)) {
             $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg));
         }
         $testCondition = '=' . $arg . $condition;
         if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
             if (is_null($returnValue) || $arg < $returnValue) {
                 $returnValue = $arg;
             }
         }
     }
     // Return
     return $returnValue;
 }
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:39,代码来源:Statistical.php

示例3: SUMIF

 /**
  * SUMIF
  *
  * Counts the number of cells that contain numbers within the list of arguments
  *
  * Excel Function:
  *		SUMIF(value1[,value2[, ...]],condition)
  *
  * @access	public
  * @category Mathematical and Trigonometric Functions
  * @param	mixed		$arg,...		Data values
  * @param	string		$condition		The criteria that defines which cells will be summed.
  * @return	float
  */
 public static function SUMIF($aArgs, $condition, $sumArgs = array())
 {
     // Return value
     $returnValue = 0;
     $aArgs = PHPExcel_Calculation_Functions::flattenArray($aArgs);
     $sumArgs = PHPExcel_Calculation_Functions::flattenArray($sumArgs);
     if (empty($sumArgs)) {
         $sumArgs = $aArgs;
     }
     $condition = PHPExcel_Calculation_Functions::_ifCondition($condition);
     // Loop through arguments
     foreach ($aArgs as $key => $arg) {
         if (!is_numeric($arg)) {
             $arg = str_replace('"', '""', $arg);
             $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg));
         }
         $testCondition = '=' . $arg . $condition;
         if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
             // Is it a value within our criteria
             $returnValue += $sumArgs[$key];
         }
     }
     // Return
     return $returnValue;
 }
开发者ID:Princelo,项目名称:bioerp,代码行数:39,代码来源:MathTrig.php


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