You are here

public static function PHPExcel_Calculation_LookupRef::CHOOSE in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php \PHPExcel_Calculation_LookupRef::CHOOSE()

* CHOOSE * * Uses lookup_value to return a value from the list of value arguments. * Use CHOOSE to select one of up to 254 values based on the lookup_value. * * Excel Function: * =CHOOSE(index_num, value1, [value2], ...) * *

Parameters

index_num Specifies which value argument is selected.: * Index_num must be a number between 1 and 254, or a formula or reference to a cell containing a number * between 1 and 254. * @param value1... Value1 is required, subsequent values are optional. * Between 1 to 254 value arguments from which CHOOSE selects a value or an action to perform based on * index_num. The arguments can be numbers, cell references, defined names, formulas, functions, or * text. * @return mixed The selected value

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/LookupRef.php, line 451

Class

PHPExcel_Calculation_LookupRef
PHPExcel_Calculation_LookupRef

Code

public static function CHOOSE() {
  $chooseArgs = func_get_args();
  $chosenEntry = PHPExcel_Calculation_Functions::flattenArray(array_shift($chooseArgs));
  $entryCount = count($chooseArgs) - 1;
  if (is_array($chosenEntry)) {
    $chosenEntry = array_shift($chosenEntry);
  }
  if (is_numeric($chosenEntry) && !is_bool($chosenEntry)) {
    --$chosenEntry;
  }
  else {
    return PHPExcel_Calculation_Functions::VALUE();
  }
  $chosenEntry = floor($chosenEntry);
  if ($chosenEntry < 0 || $chosenEntry > $entryCount) {
    return PHPExcel_Calculation_Functions::VALUE();
  }
  if (is_array($chooseArgs[$chosenEntry])) {
    return PHPExcel_Calculation_Functions::flattenArray($chooseArgs[$chosenEntry]);
  }
  else {
    return $chooseArgs[$chosenEntry];
  }
}