ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Calculation_Functions Class Reference
+ Collaboration diagram for PHPExcel_Calculation_Functions:

Static Public Member Functions

static setCompatibilityMode ($compatibilityMode)
static getCompatibilityMode ()
static setReturnDateType ($returnDateType)
static getReturnDateType ()
static DUMMY ()
static NA ()
static NaN ()
static NAME ()
static REF ()
static LOGICAL_AND ()
static LOGICAL_OR ()
static LOGICAL_FALSE ()
static LOGICAL_TRUE ()
static LOGICAL_NOT ($logical)
static STATEMENT_IF ($condition=true, $returnIfTrue=0, $returnIfFalse=False)
 STATEMENT_IF.
static STATEMENT_IFERROR ($value= '', $errorpart= '')
 STATEMENT_IFERROR.
static REVERSE_ATAN2 ($xCoordinate, $yCoordinate)
static LOG_BASE ($number, $base=10)
static SUM ()
static SUMSQ ()
static PRODUCT ()
static QUOTIENT ()
static MIN ()
static MINA ()
static SMALL ()
static MAX ()
static MAXA ()
static LARGE ()
static PERCENTILE ()
static QUARTILE ()
static COUNT ()
static COUNTBLANK ()
static COUNTA ()
static COUNTIF ($aArgs, $condition)
static SUMIF ($aArgs, $condition, $sumArgs=array())
static AVERAGE ()
static AVERAGEA ()
static MEDIAN ()
static MODE ()
static DEVSQ ()
static AVEDEV ()
static GEOMEAN ()
static HARMEAN ()
static TRIMMEAN ()
static STDEV ()
static STDEVA ()
static STDEVP ()
static STDEVPA ()
static VARFunc ()
static VARA ()
static VARP ()
static VARPA ()
static RANK ($value, $valueSet, $order=0)
 RANK.
static PERCENTRANK ($valueSet, $value, $significance=3)
 PERCENTRANK.
static INTERCEPT ($yValues, $xValues)
 INTERCEPT.
static RSQ ($yValues, $xValues)
 RSQ.
static SLOPE ($yValues, $xValues)
 SLOPE.
static STEYX ($yValues, $xValues)
 STEYX.
static COVAR ($yValues, $xValues)
 COVAR.
static CORREL ($yValues, $xValues)
 CORREL.
static LINEST ($yValues, $xValues, $const =True, $stats=False)
 LINEST.
static LOGEST ($yValues, $xValues, $const =True, $stats=False)
 LOGEST.
static FORECAST ($xValue, $yValues, $xValues)
 FORECAST.
static TREND ($yValues, $xValues=array(), $newValues=array(), $const =True)
 TREND.
static GROWTH ($yValues, $xValues=array(), $newValues=array(), $const =True)
 GROWTH.
static ROMAN ($aValue, $style=0)
static SUBTOTAL ()
 SUBTOTAL.
static SQRTPI ($number)
 SQRTPI.
static FACT ($factVal)
 FACT.
static FACTDOUBLE ($factVal)
 FACTDOUBLE.
static MULTINOMIAL ()
 MULTINOMIAL.
static CEILING ($number, $significance=null)
 CEILING.
static EVEN ($number)
 EVEN.
static ODD ($number)
 ODD.
static INTVALUE ($number)
 INTVALUE.
static ROUNDUP ($number, $digits)
 ROUNDUP.
static ROUNDDOWN ($number, $digits)
 ROUNDDOWN.
static MROUND ($number, $multiple)
 MROUND.
static SIGN ($number)
 SIGN.
static FLOOR ($number, $significance=null)
 FLOOR.
static PERMUT ($numObjs, $numInSet)
 PERMUT.
static COMBIN ($numObjs, $numInSet)
 COMBIN.
static SERIESSUM ()
 SERIESSUM.
static STANDARDIZE ($value, $mean, $stdDev)
 STANDARDIZE.
static LCM ()
 LCM.
static GCD ()
 GCD.
static BINOMDIST ($value, $trials, $probability, $cumulative)
 BINOMDIST.
static NEGBINOMDIST ($failures, $successes, $probability)
 NEGBINOMDIST.
static CRITBINOM ($trials, $probability, $alpha)
 CRITBINOM.
static CHIDIST ($value, $degrees)
 CHIDIST.
static CHIINV ($probability, $degrees)
 CHIINV.
static EXPONDIST ($value, $lambda, $cumulative)
 EXPONDIST.
static FISHER ($value)
 FISHER.
static FISHERINV ($value)
 FISHERINV.
static BETADIST ($value, $alpha, $beta, $rMin=0, $rMax=1)
 BETADIST.
static BETAINV ($probability, $alpha, $beta, $rMin=0, $rMax=1)
 BETAINV.
static GAMMADIST ($value, $a, $b, $cumulative)
 GAMMADIST.
static GAMMAINV ($probability, $alpha, $beta)
 GAMMAINV.
static GAMMALN ($value)
 GAMMALN.
static NORMDIST ($value, $mean, $stdDev, $cumulative)
 NORMDIST.
static NORMSDIST ($value)
 NORMSDIST.
static LOGNORMDIST ($value, $mean, $stdDev)
 LOGNORMDIST.
static NORMINV ($probability, $mean, $stdDev)
 NORMINV.
static NORMSINV ($value)
 NORMSINV.
static LOGINV ($probability, $mean, $stdDev)
 LOGINV.
static HYPGEOMDIST ($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber)
 HYPGEOMDIST.
static TDIST ($value, $degrees, $tails)
 TDIST.
static TINV ($probability, $degrees)
 TINV.
static CONFIDENCE ($alpha, $stdDev, $size)
 CONFIDENCE.
static POISSON ($value, $mean, $cumulative)
 POISSON.
static WEIBULL ($value, $alpha, $beta, $cumulative)
 WEIBULL.
static SKEW ()
 SKEW.
static KURT ()
 KURT.
static RAND ($min=0, $max=0)
 RAND.
static MOD ($a=1, $b=1)
 MOD.
static CHARACTER ($character)
 CHARACTER.
static ASCIICODE ($characters)
 ASCIICODE.
static CONCATENATE ()
 CONCATENATE.
static STRINGLENGTH ($value= '')
 STRINGLENGTH.
static SEARCHSENSITIVE ($needle, $haystack, $offset=1)
 SEARCHSENSITIVE.
static SEARCHINSENSITIVE ($needle, $haystack, $offset=1)
 SEARCHINSENSITIVE.
static LEFT ($value= '', $chars=1)
 LEFT.
static RIGHT ($value= '', $chars=1)
 RIGHT.
static MID ($value= '', $start=1, $chars=null)
 MID.
static REPLACE ($oldText= '', $start=1, $chars=null, $newText)
 REPLACE.
static RETURNSTRING ($testValue= '')
 RETURNSTRING.
static FIXEDFORMAT ($value, $decimals=2, $no_commas=false)
 FIXEDFORMAT.
static TEXTFORMAT ($value, $format)
 TEXTFORMAT.
static TRIMSPACES ($stringValue= '')
 TRIMSPACES.
static TRIMNONPRINTABLE ($stringValue= '')
 TRIMNONPRINTABLE.
static ERROR_TYPE ($value= '')
 ERROR_TYPE.
static IS_BLANK ($value=null)
 IS_BLANK.
static IS_ERR ($value= '')
 IS_ERR.
static IS_ERROR ($value= '')
 IS_ERROR.
static IS_NA ($value= '')
 IS_NA.
static IS_EVEN ($value=0)
 IS_EVEN.
static IS_ODD ($value=null)
 IS_ODD.
static IS_NUMBER ($value=0)
 IS_NUMBER.
static IS_LOGICAL ($value=true)
 IS_LOGICAL.
static IS_TEXT ($value= '')
 IS_TEXT.
static IS_NONTEXT ($value= '')
 IS_NONTEXT.
static VERSION ()
 VERSION.
static DATE ($year=0, $month=1, $day=1)
 DATE.
static TIME ($hour=0, $minute=0, $second=0)
 TIME.
static DATEVALUE ($dateValue=1)
 DATEVALUE.
static TIMEVALUE ($timeValue)
 TIMEVALUE.
static DATETIMENOW ()
 DATETIMENOW.
static DATENOW ()
 DATENOW.
static DAYS360 ($startDate=0, $endDate=0, $method=false)
 DAYS360.
static DATEDIF ($startDate=0, $endDate=0, $unit= 'D')
 DATEDIF.
static YEARFRAC ($startDate=0, $endDate=0, $method=0)
 YEARFRAC.
static NETWORKDAYS ($startDate, $endDate)
 NETWORKDAYS.
static WORKDAY ($startDate, $endDays)
 WORKDAY.
static DAYOFMONTH ($dateValue=1)
 DAYOFMONTH.
static DAYOFWEEK ($dateValue=1, $style=1)
 DAYOFWEEK.
static WEEKOFYEAR ($dateValue=1, $method=1)
 WEEKOFYEAR.
static MONTHOFYEAR ($dateValue=1)
 MONTHOFYEAR.
static YEAR ($dateValue=1)
 YEAR.
static HOUROFDAY ($timeValue=0)
 HOUROFDAY.
static MINUTEOFHOUR ($timeValue=0)
 MINUTEOFHOUR.
static SECONDOFMINUTE ($timeValue=0)
 SECONDOFMINUTE.
static EDATE ($dateValue=1, $adjustmentMonths=0)
 EDATE.
static EOMONTH ($dateValue=1, $adjustmentMonths=0)
 EOMONTH.
static TRUNC ($value=0, $number_digits=0)
 TRUNC.
static POWER ($x=0, $y=2)
 POWER.
static BINTODEC ($x)
 BINTODEC.
static BINTOHEX ($x, $places=null)
 BINTOHEX.
static BINTOOCT ($x, $places=null)
 BINTOOCT.
static DECTOBIN ($x, $places=null)
 DECTOBIN.
static DECTOOCT ($x, $places=null)
 DECTOOCT.
static DECTOHEX ($x, $places=null)
 DECTOHEX.
static HEXTOBIN ($x, $places=null)
 HEXTOBIN.
static HEXTOOCT ($x, $places=null)
 HEXTOOCT.
static HEXTODEC ($x)
 HEXTODEC.
static OCTTOBIN ($x, $places=null)
 OCTTOBIN.
static OCTTODEC ($x)
 OCTTODEC.
static OCTTOHEX ($x, $places=null)
 OCTTOHEX.
static _parseComplex ($complexNumber)
static COMPLEX ($realNumber=0.0, $imaginary=0.0, $suffix='i')
 COMPLEX.
static IMAGINARY ($complexNumber)
 IMAGINARY.
static IMREAL ($complexNumber)
 IMREAL.
static IMABS ($complexNumber)
 IMABS.
static IMARGUMENT ($complexNumber)
 IMARGUMENT.
static IMCONJUGATE ($complexNumber)
 IMCONJUGATE.
static IMCOS ($complexNumber)
 IMCOS.
static IMSIN ($complexNumber)
 IMSIN.
static IMSQRT ($complexNumber)
 IMSQRT.
static IMLN ($complexNumber)
 IMLN.
static IMLOG10 ($complexNumber)
 IMLOG10.
static IMLOG2 ($complexNumber)
 IMLOG2.
static IMEXP ($complexNumber)
 IMEXP.
static IMPOWER ($complexNumber, $realNumber)
 IMPOWER.
static IMDIV ($complexDividend, $complexDivisor)
 IMDIV.
static IMSUB ($complexNumber1, $complexNumber2)
 IMSUB.
static IMSUM ()
 IMSUM.
static IMPRODUCT ()
 IMPRODUCT.
static getConversionGroups ()
 getConversionGroups
static getConversionGroupUnits ($group=NULL)
 getConversionGroupUnits
static getConversionGroupUnitDetails ($group=NULL)
 getConversionGroupUnitDetails
static getConversionMultipliers ()
 getConversionGroups
static CONVERTUOM ($value, $fromUOM, $toUOM)
 CONVERTUOM.
static BESSELI ($x, $n)
 BESSELI.
static BESSELJ ($x, $n)
 BESSELJ.
static BESSELK ($x, $ord)
 BESSELK.
static BESSELY ($x, $ord)
 BESSELY.
static DELTA ($a, $b=0)
 DELTA.
static GESTEP ($number, $step=0)
 GESTEP.
static ERF ($lower, $upper=null)
 ERF.
static ERFC ($x)
 ERFC.
static LOWERCASE ($mixedCaseString)
 LOWERCASE.
static UPPERCASE ($mixedCaseString)
 UPPERCASE.
static PROPERCASE ($mixedCaseString)
 PROPERCASE.
static DOLLAR ($value=0, $decimals=2)
 DOLLAR.
static DOLLARDE ($fractional_dollar=Null, $fraction=0)
 DOLLARDE.
static DOLLARFR ($decimal_dollar=Null, $fraction=0)
 DOLLARFR.
static EFFECT ($nominal_rate=0, $npery=0)
 EFFECT.
static NOMINAL ($effect_rate=0, $npery=0)
 NOMINAL.
static PV ($rate=0, $nper=0, $pmt=0, $fv=0, $type=0)
 PV.
static FV ($rate=0, $nper=0, $pmt=0, $pv=0, $type=0)
 FV.
static PMT ($rate=0, $nper=0, $pv=0, $fv=0, $type=0)
 PMT.
static NPER ($rate=0, $pmt=0, $pv=0, $fv=0, $type=0)
 NPER.
static IPMT ($rate, $per, $nper, $pv, $fv=0, $type=0)
 IPMT.
static CUMIPMT ($rate, $nper, $pv, $start, $end, $type=0)
 CUMIPMT.
static PPMT ($rate, $per, $nper, $pv, $fv=0, $type=0)
 PPMT.
static CUMPRINC ($rate, $nper, $pv, $start, $end, $type=0)
 CUMPRINC.
static NPV ()
 NPV.
static DB ($cost, $salvage, $life, $period, $month=12)
 DB.
static DDB ($cost, $salvage, $life, $period, $factor=2.0)
 DDB.
static ACCRINT ($issue, $firstinter, $settlement, $rate, $par=1000, $frequency=1, $basis=0)
 ACCRINT.
static ACCRINTM ($issue, $settlement, $rate, $par=1000, $basis=0)
 ACCRINTM.
static AMORDEGRC ($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0)
static AMORLINC ($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis=0)
static DISC ($settlement, $maturity, $price, $redemption, $basis=0)
 DISC.
static PRICEDISC ($settlement, $maturity, $discount, $redemption, $basis=0)
 PRICEDISC.
static PRICEMAT ($settlement, $maturity, $issue, $rate, $yield, $basis=0)
 PRICEMAT.
static RECEIVED ($settlement, $maturity, $investment, $discount, $basis=0)
 RECEIVED.
static INTRATE ($settlement, $maturity, $investment, $redemption, $basis=0)
 INTRATE.
static TBILLEQ ($settlement, $maturity, $discount)
 TBILLEQ.
static TBILLPRICE ($settlement, $maturity, $discount)
 TBILLPRICE.
static TBILLYIELD ($settlement, $maturity, $price)
 TBILLYIELD.
static SLN ($cost, $salvage, $life)
 SLN.
static YIELDMAT ($settlement, $maturity, $issue, $rate, $price, $basis=0)
 YIELDMAT.
static YIELDDISC ($settlement, $maturity, $price, $redemption, $basis=0)
 YIELDDISC.
static CELL_ADDRESS ($row, $column, $relativity=1, $referenceStyle=True, $sheetText='')
 CELL_ADDRESS.
static COLUMN ($cellAddress=Null)
static ROW ($cellAddress=Null)
static OFFSET ($cellAddress=Null, $rows=0, $columns=0, $height=null, $width=null)
static CHOOSE ()
static MATCH ($lookup_value, $lookup_array, $match_type=1)
 MATCH The MATCH function searches for a specified item in a range of cells.
static INDEX ($arrayValues, $rowNum=0, $columnNum=0)
 Uses an index to choose a value from a reference or array implemented: Return the value of a specified cell or array of cells Array form not implemented: Return a reference to specified cells Reference form.
static SYD ($cost, $salvage, $life, $period)
 SYD.
static TRANSPOSE ($matrixData)
 TRANSPOSE.
static MMULT ($matrixData1, $matrixData2)
 MMULT.
static MINVERSE ($matrixValues)
 MINVERSE.
static MDETERM ($matrixValues)
 MDETERM.
static SUMX2MY2 ($matrixData1, $matrixData2)
 SUMX2MY2.
static SUMX2PY2 ($matrixData1, $matrixData2)
 SUMX2PY2.
static SUMXMY2 ($matrixData1, $matrixData2)
 SUMXMY2.
static VLOOKUP ($lookup_value, $lookup_array, $index_number, $not_exact_match=true)
 VLOOKUP The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number.
static LOOKUP ($lookup_value, $lookup_vector, $result_vector=null)
 LOOKUP The LOOKUP function searches for value either from a one-row or one-column range or from an array.
static flattenArray ($array)
 Flatten multidemensional array.
static flattenSingleValue ($value= '')
 Convert an array with one element to a flat value.

Data Fields

const COMPATIBILITY_EXCEL = 'Excel'
 constants
const COMPATIBILITY_GNUMERIC = 'Gnumeric'
const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc'
const RETURNDATE_PHP_NUMERIC = 'P'
const RETURNDATE_PHP_OBJECT = 'O'
const RETURNDATE_EXCEL = 'E'

Static Private Member Functions

static _modeCalc ($data)
static _checkTrendArray ($values)
static _romanCut ($num, $n)
static _factors ($value)
static _logBeta ($p, $q)
 The natural logarithm of the beta function.
static _betaFraction ($x, $p, $q)
 Evaluates of continued fraction part of incomplete beta function.
static _logGamma ($x)
static _beta ($p, $q)
 Beta function.
static _incompleteBeta ($x, $p, $q)
 Incomplete beta function.
static _incompleteGamma ($a, $x)
static _gamma ($data)
static _inverse_ncdf ($p)
static _inverse_ncdf2 ($prob)
static _inverse_ncdf3 ($p)
static _getDateValue ($dateValue)
 _getDateValue
static _getTimeValue ($timeValue)
 _getTimeValue
static _isLeapYear ($year)
static _dateDiff360 ($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, $methodUS)
static _adjustDateByMonths ($dateValue=0, $adjustmentMonths=0)
static _nbrConversionFormat ($xVal, $places)
static _cleanComplex ($complexNumber)
static _Besselk0 ($fNum)
static _Besselk1 ($fNum)
static _Bessely0 ($fNum)
static _Bessely1 ($fNum)
static _erfVal ($x)
static _erfcVal ($x)
static _interestAndPrincipal ($rate=0, $per=0, $nper=0, $pv=0, $fv=0, $type=0)
static _daysPerYear ($year, $basis)

Static Private Attributes

static $compatibilityMode = self::COMPATIBILITY_EXCEL
static $ReturnDateType = self::RETURNDATE_EXCEL
static $_errorCodes
static $_logBetaCache_p = 0.0
static $_logBetaCache_q = 0.0
static $_logBetaCache_result = 0.0
static $_logGammaCache_result = 0.0
 logGamma function
static $_logGammaCache_x = 0.0
static $_invalidChars = Null
static $_conversionUnits
static $_conversionMultipliers
static $_unitConversions
static $_two_sqrtpi = 1.128379167095512574
static $_rel_error = 1E-15
static $_one_sqrtpi = 0.564189583547756287

Detailed Description

Definition at line 91 of file Functions.php.

Member Function Documentation

static PHPExcel_Calculation_Functions::_adjustDateByMonths (   $dateValue = 0,
  $adjustmentMonths = 0 
)
staticprivate

Definition at line 6192 of file Functions.php.

References PHPExcel_Shared_Date\ExcelToPHPObject().

Referenced by EDATE(), and EOMONTH().

{
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
$oMonth = (int) $PHPDateObject->format('m');
$oYear = (int) $PHPDateObject->format('Y');
$adjustmentMonthsString = (string) $adjustmentMonths;
if ($adjustmentMonths > 0) {
$adjustmentMonthsString = '+'.$adjustmentMonths;
}
if ($adjustmentMonths != 0) {
$PHPDateObject->modify($adjustmentMonthsString.' months');
}
$nMonth = (int) $PHPDateObject->format('m');
$nYear = (int) $PHPDateObject->format('Y');
$monthDiff = ($nMonth - $oMonth) + (($nYear - $oYear) * 12);
if ($monthDiff != $adjustmentMonths) {
$adjustDays = (int) $PHPDateObject->format('d');
$adjustDaysString = '-'.$adjustDays.' days';
$PHPDateObject->modify($adjustDaysString);
}
return $PHPDateObject;
} // function _adjustDateByMonths()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_Besselk0 (   $fNum)
staticprivate

Definition at line 8173 of file Functions.php.

References $y, and BESSELI().

Referenced by BESSELK().

{
if ($fNum <= 2) {
$fNum2 = $fNum * 0.5;
$y = pow($fNum2,2);
$fRet = -log($fNum2) * self::BESSELI($fNum, 0) +
(-0.57721566 + $y * (0.42278420 + $y * (0.23069756 + $y * (0.3488590e-1 + $y * (0.262698e-2 + $y *
(0.10750e-3 + $y * 0.74e-5))))));
} else {
$y = 2 / $fNum;
$fRet = exp(-$fNum) / sqrt($fNum) *
(1.25331414 + $y * (-0.7832358e-1 + $y * (0.2189568e-1 + $y * (-0.1062446e-1 + $y *
(0.587872e-2 + $y * (-0.251540e-2 + $y * 0.53208e-3))))));
}
return $fRet;
} // function _Besselk0()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_Besselk1 (   $fNum)
staticprivate

Definition at line 8190 of file Functions.php.

References $y, and BESSELI().

Referenced by BESSELK().

{
if ($fNum <= 2) {
$fNum2 = $fNum * 0.5;
$y = pow($fNum2,2);
$fRet = log($fNum2) * self::BESSELI($fNum, 1) +
(1 + $y * (0.15443144 + $y * (-0.67278579 + $y * (-0.18156897 + $y * (-0.1919402e-1 + $y *
(-0.110404e-2 + $y * (-0.4686e-4))))))) / $fNum;
} else {
$y = 2 / $fNum;
$fRet = exp(-$fNum) / sqrt($fNum) *
(1.25331414 + $y * (0.23498619 + $y * (-0.3655620e-1 + $y * (0.1504268e-1 + $y * (-0.780353e-2 + $y *
(0.325614e-2 + $y * (-0.68245e-3)))))));
}
return $fRet;
} // function _Besselk1()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_Bessely0 (   $fNum)
staticprivate

Definition at line 8245 of file Functions.php.

References $y, and BESSELJ().

Referenced by BESSELY().

{
if ($fNum < 8.0) {
$y = pow($fNum,2);
$f1 = -2957821389.0 + $y * (7062834065.0 + $y * (-512359803.6 + $y * (10879881.29 + $y * (-86327.92757 + $y * 228.4622733))));
$f2 = 40076544269.0 + $y * (745249964.8 + $y * (7189466.438 + $y * (47447.26470 + $y * (226.1030244 + $y))));
$fRet = $f1 / $f2 + 0.636619772 * self::BESSELJ($fNum, 0) * log($fNum);
} else {
$z = 8.0 / $fNum;
$y = pow($z,2);
$xx = $fNum - 0.785398164;
$f1 = 1 + $y * (-0.1098628627e-2 + $y * (0.2734510407e-4 + $y * (-0.2073370639e-5 + $y * 0.2093887211e-6)));
$f2 = -0.1562499995e-1 + $y * (0.1430488765e-3 + $y * (-0.6911147651e-5 + $y * (0.7621095161e-6 + $y * (-0.934945152e-7))));
$fRet = sqrt(0.636619772 / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
}
return $fRet;
} // function _Bessely0()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_Bessely1 (   $fNum)
staticprivate

Definition at line 8263 of file Functions.php.

References $y, and BESSELJ().

Referenced by BESSELY().

{
if ($fNum < 8.0) {
$y = pow($fNum,2);
$f1 = $fNum * (-0.4900604943e13 + $y * (0.1275274390e13 + $y * (-0.5153438139e11 + $y * (0.7349264551e9 + $y *
(-0.4237922726e7 + $y * 0.8511937935e4)))));
$f2 = 0.2499580570e14 + $y * (0.4244419664e12 + $y * (0.3733650367e10 + $y * (0.2245904002e8 + $y *
(0.1020426050e6 + $y * (0.3549632885e3 + $y)))));
$fRet = $f1 / $f2 + 0.636619772 * ( self::BESSELJ($fNum, 1) * log($fNum) - 1 / $fNum);
} else {
$z = 8.0 / $fNum;
$y = pow($z,2);
$xx = $fNum - 2.356194491;
$f1 = 1 + $y * (0.183105e-2 + $y * (-0.3516396496e-4 + $y * (0.2457520174e-5 + $y * (-0.240337019e6))));
$f2 = 0.04687499995 + $y * (-0.2002690873e-3 + $y * (0.8449199096e-5 + $y * (-0.88228987e-6 + $y * 0.105787412e-6)));
$fRet = sqrt(0.636619772 / $fNum) * (sin($xx) * $f1 + $z * cos($xx) * $f2);
#i12430# ...but this seems to work much better.
// $fRet = sqrt(0.636619772 / $fNum) * sin($fNum - 2.356194491);
}
return $fRet;
} // function _Bessely1()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_beta (   $p,
  $q 
)
staticprivate

Beta function.

Author
Jaco van Kooten
Parameters
prequire p>0
qrequire q>0
Returns
0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow

Definition at line 3758 of file Functions.php.

References $q, and LOG_GAMMA_X_MAX_VALUE.

{
if ($p <= 0.0 || $q <= 0.0 || ($p + $q) > LOG_GAMMA_X_MAX_VALUE) {
return 0.0;
} else {
return exp(self::_logBeta($p, $q));
}
} // function _beta()
static PHPExcel_Calculation_Functions::_betaFraction (   $x,
  $p,
  $q 
)
staticprivate

Evaluates of continued fraction part of incomplete beta function.

Based on an idea from Numerical Recipes (W.H. Press et al, 1992).

Author
Jaco van Kooten

Definition at line 3496 of file Functions.php.

References $d, $q, $x, MAX_ITERATIONS, PRECISION, and XMININ.

Referenced by _incompleteBeta().

{
$c = 1.0;
$sum_pq = $p + $q;
$p_plus = $p + 1.0;
$p_minus = $p - 1.0;
$h = 1.0 - $sum_pq * $x / $p_plus;
if (abs($h) < XMININ) {
$h = XMININ;
}
$h = 1.0 / $h;
$frac = $h;
$m = 1;
$delta = 0.0;
while ($m <= MAX_ITERATIONS && abs($delta-1.0) > PRECISION ) {
$m2 = 2 * $m;
// even index for d
$d = $m * ($q - $m) * $x / ( ($p_minus + $m2) * ($p + $m2));
$h = 1.0 + $d * $h;
if (abs($h) < XMININ) {
$h = XMININ;
}
$h = 1.0 / $h;
$c = 1.0 + $d / $c;
if (abs($c) < XMININ) {
$c = XMININ;
}
$frac *= $h * $c;
// odd index for d
$d = -($p + $m) * ($sum_pq + $m) * $x / (($p + $m2) * ($p_plus + $m2));
$h = 1.0 + $d * $h;
if (abs($h) < XMININ) {
$h = XMININ;
}
$h = 1.0 / $h;
$c = 1.0 + $d / $c;
if (abs($c) < XMININ) {
$c = XMININ;
}
$delta = $h * $c;
$frac *= $delta;
++$m;
}
return $frac;
} // function _betaFraction()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_checkTrendArray (   $values)
staticprivate

Definition at line 2043 of file Functions.php.

References $key, and elseif().

Referenced by CORREL(), COVAR(), FORECAST(), INTERCEPT(), LINEST(), LOGEST(), RSQ(), SLOPE(), and STEYX().

{
foreach($values as $key => $value) {
if ((is_bool($value)) || ((is_string($value)) && (trim($value) == ''))) {
unset($values[$key]);
} elseif (is_string($value)) {
if (is_numeric($value)) {
$values[$key] = (float) $value;
} else {
unset($values[$key]);
}
}
}
return $values;
} // function _checkTrendArray()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_cleanComplex (   $complexNumber)
staticprivate

Definition at line 6769 of file Functions.php.

Referenced by IMCONJUGATE(), and IMDIV().

{
if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1);
if ($complexNumber{0} == '0') $complexNumber = substr($complexNumber,1);
if ($complexNumber{0} == '.') $complexNumber = '0'.$complexNumber;
if ($complexNumber{0} == '+') $complexNumber = substr($complexNumber,1);
return $complexNumber;
}

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_dateDiff360 (   $startDay,
  $startMonth,
  $startYear,
  $endDay,
  $endMonth,
  $endYear,
  $methodUS 
)
staticprivate

Definition at line 5596 of file Functions.php.

References elseif().

Referenced by DAYS360().

{
if ($startDay == 31) {
--$startDay;
} elseif ($methodUS && ($startMonth == 2 && ($startDay == 29 || ($startDay == 28 && !self::_isLeapYear($startYear))))) {
$startDay = 30;
}
if ($endDay == 31) {
if ($methodUS && $startDay != 30) {
$endDay = 1;
if ($endMonth == 12) {
++$endYear;
$endMonth = 1;
} else {
++$endMonth;
}
} else {
$endDay = 30;
}
}
return $endDay + $endMonth * 30 + $endYear * 360 - $startDay - $startMonth * 30 - $startYear * 360;
} // function _dateDiff360()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_daysPerYear (   $year,
  $basis 
)
staticprivate

Definition at line 9089 of file Functions.php.

Referenced by ACCRINT(), ACCRINTM(), PRICEMAT(), YIELDDISC(), and YIELDMAT().

{
switch ($basis) {
case 0 :
case 2 :
case 4 :
$daysPerYear = 360;
break;
case 3 :
$daysPerYear = 365;
break;
case 1 :
if (self::_isLeapYear(self::YEAR($year))) {
$daysPerYear = 366;
} else {
$daysPerYear = 365;
}
break;
default :
return self::$_errorCodes['num'];
}
return $daysPerYear;
} // function _daysPerYear()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_erfcVal (   $x)
staticprivate

Definition at line 8422 of file Functions.php.

References $d, $n, $t, $x, and _erfVal().

Referenced by _erfVal(), and ERFC().

{
if (abs($x) < 2.2) {
return 1 - self::_erfVal($x);
}
if ($x < 0) {
return 2 - self::erfc(-$x);
}
$a = $n = 1;
$b = $c = $x;
$d = pow($x,2) + 0.5;
$q1 = $q2 = $b / $d;
$t = 0;
do {
$t = $a * $n + $b * $x;
$a = $b;
$b = $t;
$t = $c * $n + $d * $x;
$c = $d;
$d = $t;
$n += 0.5;
$q1 = $q2;
$q2 = $b / $d;
} while ((abs($q1 - $q2) / $q2) > self::$_rel_error);
return self::$_one_sqrtpi * exp(-$x * $x) * $q2;
} // function _erfcVal()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_erfVal (   $x)
staticprivate

Definition at line 8363 of file Functions.php.

References $_rel_error, $x, and _erfcVal().

Referenced by _erfcVal(), ERF(), and NORMDIST().

{
if (abs($x) > 2.2) {
return 1 - self::_erfcVal($x);
}
$sum = $term = $x;
$xsqr = pow($x,2);
$j = 1;
do {
$term *= $xsqr / $j;
$sum -= $term / (2 * $j + 1);
++$j;
$term *= $xsqr / $j;
$sum += $term / (2 * $j + 1);
++$j;
if ($sum == 0) {
break;
}
} while (abs($term / $sum) > self::$_rel_error);
return self::$_two_sqrtpi * $sum;
} // function _erfVal()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_factors (   $value)
staticprivate

Definition at line 2981 of file Functions.php.

Referenced by GCD(), and LCM().

{
$startVal = floor(sqrt($value));
$factorArray = array();
for ($i = $startVal; $i > 1; --$i) {
if (($value % $i) == 0) {
$factorArray = array_merge($factorArray,self::_factors($value / $i));
$factorArray = array_merge($factorArray,self::_factors($i));
if ($i <= sqrt($value)) {
break;
}
}
}
if (count($factorArray) > 0) {
rsort($factorArray);
return $factorArray;
} else {
return array((integer) $value);
}
} // function _factors()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_gamma (   $data)
staticprivate

Definition at line 3905 of file Functions.php.

References $data, $x, and $y.

Referenced by CHIDIST(), and GAMMADIST().

{
if ($data == 0.0) return 0;
static $p0 = 1.000000000190015;
static $p = array ( 1 => 76.18009172947146,
2 => -86.50532032941677,
3 => 24.01409824083091,
4 => -1.231739572450155,
5 => 1.208650973866179e-3,
6 => -5.395239384953e-6
);
$y = $x = $data;
$tmp = $x + 5.5;
$tmp -= ($x + 0.5) * log($tmp);
$summer = $p0;
for ($j=1;$j<=6;++$j) {
$summer += ($p[$j] / ++$y);
}
return exp(0 - $tmp + log(2.5066282746310005 * $summer / $x));
} // function _gamma()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_getDateValue (   $dateValue)
staticprivate

_getDateValue

Parameters
string$dateValue
Returns
mixed Excel date/time serial value, or string if error

Definition at line 5479 of file Functions.php.

References PHPExcel_Shared_Date\$dateTimeObjectType, DATEVALUE(), getReturnDateType(), PHPExcel_Shared_Date\PHPToExcel(), and setReturnDateType().

{
if (!is_numeric($dateValue)) {
if ((is_string($dateValue)) && (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC)) {
return self::$_errorCodes['value'];
}
if ((is_object($dateValue)) && ($dateValue instanceof PHPExcel_Shared_Date::$dateTimeObjectType)) {
$dateValue = PHPExcel_Shared_Date::PHPToExcel($dateValue);
} else {
$saveReturnDateType = self::getReturnDateType();
self::setReturnDateType(self::RETURNDATE_EXCEL);
$dateValue = self::DATEVALUE($dateValue);
self::setReturnDateType($saveReturnDateType);
}
}
return $dateValue;
} // function _getDateValue()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::_getTimeValue (   $timeValue)
staticprivate

_getTimeValue

Parameters
string$timeValue
Returns
mixed Excel date/time serial value, or string if error

Definition at line 5533 of file Functions.php.

References getReturnDateType(), setReturnDateType(), and TIMEVALUE().

Referenced by HOUROFDAY(), MINUTEOFHOUR(), and SECONDOFMINUTE().

{
$saveReturnDateType = self::getReturnDateType();
self::setReturnDateType(self::RETURNDATE_EXCEL);
$timeValue = self::TIMEVALUE($timeValue);
self::setReturnDateType($saveReturnDateType);
return $timeValue;
} // function _getTimeValue()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_incompleteBeta (   $x,
  $p,
  $q 
)
staticprivate

Incomplete beta function.

Author
Jaco van Kooten
Paul Meagher

The computation is based on formulas from Numerical Recipes, Chapter 6.4 (W.H. Press et al, 1992).

Parameters
xrequire 0<=x<=1
prequire p>0
qrequire q>0
Returns
0 if x<0, p<=0, q<=0 or p+q>2.55E305 and 1 if x>1 to avoid errors and over/underflow

Definition at line 3779 of file Functions.php.

References $q, $x, _betaFraction(), elseif(), and LOG_GAMMA_X_MAX_VALUE.

Referenced by BETADIST().

{
if ($x <= 0.0) {
return 0.0;
} elseif ($x >= 1.0) {
return 1.0;
} elseif (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) {
return 0.0;
}
$beta_gam = exp((0 - self::_logBeta($p, $q)) + $p * log($x) + $q * log(1.0 - $x));
if ($x < ($p + 1.0) / ($p + $q + 2.0)) {
return $beta_gam * self::_betaFraction($x, $p, $q) / $p;
} else {
return 1.0 - ($beta_gam * self::_betaFraction(1 - $x, $q, $p) / $q);
}
} // function _incompleteBeta()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_incompleteGamma (   $a,
  $x 
)
staticprivate

Definition at line 3888 of file Functions.php.

References $n, and $x.

Referenced by CHIDIST(), and GAMMADIST().

{
static $max = 32;
$summer = 0;
for ($n=0; $n<=$max; ++$n) {
$divisor = $a;
for ($i=1; $i<=$n; ++$i) {
$divisor *= ($a + $i);
}
$summer += (pow($x,$n) / $divisor);
}
return pow($x,$a) * exp(0-$x) * $summer;
} // function _incompleteGamma()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_interestAndPrincipal (   $rate = 0,
  $per = 0,
  $nper = 0,
  $pv = 0,
  $fv = 0,
  $type = 0 
)
staticprivate

Definition at line 8805 of file Functions.php.

References $type, and PMT().

Referenced by IPMT(), and PPMT().

{
$pmt = self::PMT($rate, $nper, $pv, $fv, $type);
$capital = $pv;
for ($i = 1; $i<= $per; ++$i) {
$interest = ($type && $i == 1)? 0 : -$capital * $rate;
$principal = $pmt - $interest;
$capital += $principal;
}
return array($interest, $principal);
} // function _interestAndPrincipal()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_inverse_ncdf (   $p)
staticprivate

Definition at line 4132 of file Functions.php.

References $d, $q, and elseif().

{
// Inverse ncdf approximation by Peter J. Acklam, implementation adapted to
// PHP by Michael Nickerson, using Dr. Thomas Ziegler's C implementation as
// a guide. http://home.online.no/~pjacklam/notes/invnorm/index.html
// I have not checked the accuracy of this implementation. Be aware that PHP
// will truncate the coeficcients to 14 digits.
// You have permission to use and distribute this function freely for
// whatever purpose you want, but please show common courtesy and give credit
// where credit is due.
// Input paramater is $p - probability - where 0 < p < 1.
// Coefficients in rational approximations
static $a = array( 1 => -3.969683028665376e+01,
2 => 2.209460984245205e+02,
3 => -2.759285104469687e+02,
4 => 1.383577518672690e+02,
5 => -3.066479806614716e+01,
6 => 2.506628277459239e+00
);
static $b = array( 1 => -5.447609879822406e+01,
2 => 1.615858368580409e+02,
3 => -1.556989798598866e+02,
4 => 6.680131188771972e+01,
5 => -1.328068155288572e+01
);
static $c = array( 1 => -7.784894002430293e-03,
2 => -3.223964580411365e-01,
3 => -2.400758277161838e+00,
4 => -2.549732539343734e+00,
5 => 4.374664141464968e+00,
6 => 2.938163982698783e+00
);
static $d = array( 1 => 7.784695709041462e-03,
2 => 3.224671290700398e-01,
3 => 2.445134137142996e+00,
4 => 3.754408661907416e+00
);
// Define lower and upper region break-points.
$p_low = 0.02425; //Use lower region approx. below this
$p_high = 1 - $p_low; //Use upper region approx. above this
if (0 < $p && $p < $p_low) {
// Rational approximation for lower region.
$q = sqrt(-2 * log($p));
return ((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q + $c[5]) * $q + $c[6]) /
(((($d[1] * $q + $d[2]) * $q + $d[3]) * $q + $d[4]) * $q + 1);
} elseif ($p_low <= $p && $p <= $p_high) {
// Rational approximation for central region.
$q = $p - 0.5;
$r = $q * $q;
return ((((($a[1] * $r + $a[2]) * $r + $a[3]) * $r + $a[4]) * $r + $a[5]) * $r + $a[6]) * $q /
((((($b[1] * $r + $b[2]) * $r + $b[3]) * $r + $b[4]) * $r + $b[5]) * $r + 1);
} elseif ($p_high < $p && $p < 1) {
// Rational approximation for upper region.
$q = sqrt(-2 * log(1 - $p));
return -((((($c[1] * $q + $c[2]) * $q + $c[3]) * $q + $c[4]) * $q + $c[5]) * $q + $c[6]) /
(((($d[1] * $q + $d[2]) * $q + $d[3]) * $q + $d[4]) * $q + 1);
}
// If 0 < p < 1, return a null value
return self::$_errorCodes['null'];
} // function _inverse_ncdf()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::_inverse_ncdf2 (   $prob)
staticprivate

Definition at line 4201 of file Functions.php.

References $y.

{
// Approximation of inverse standard normal CDF developed by
// B. Moro, "The Full Monte," Risk 8(2), Feb 1995, 57-58.
$a1 = 2.50662823884;
$a2 = -18.61500062529;
$a3 = 41.39119773534;
$a4 = -25.44106049637;
$b1 = -8.4735109309;
$b2 = 23.08336743743;
$b3 = -21.06224101826;
$b4 = 3.13082909833;
$c1 = 0.337475482272615;
$c2 = 0.976169019091719;
$c3 = 0.160797971491821;
$c4 = 2.76438810333863E-02;
$c5 = 3.8405729373609E-03;
$c6 = 3.951896511919E-04;
$c7 = 3.21767881768E-05;
$c8 = 2.888167364E-07;
$c9 = 3.960315187E-07;
$y = $prob - 0.5;
if (abs($y) < 0.42) {
$z = pow($y,2);
$z = $y * ((($a4 * $z + $a3) * $z + $a2) * $z + $a1) / (((($b4 * $z + $b3) * $z + $b2) * $z + $b1) * $z + 1);
} else {
if ($y > 0) {
$z = log(-log(1 - $prob));
} else {
$z = log(-log($prob));
}
$z = $c1 + $z * ($c2 + $z * ($c3 + $z * ($c4 + $z * ($c5 + $z * ($c6 + $z * ($c7 + $z * ($c8 + $z * $c9)))))));
if ($y < 0) {
$z = -$z;
}
}
return $z;
} // function _inverse_ncdf2()
static PHPExcel_Calculation_Functions::_inverse_ncdf3 (   $p)
staticprivate

Definition at line 4244 of file Functions.php.

References $q.

{
// ALGORITHM AS241 APPL. STATIST. (1988) VOL. 37, NO. 3.
// Produces the normal deviate Z corresponding to a given lower
// tail area of P; Z is accurate to about 1 part in 10**16.
//
// This is a PHP version of the original FORTRAN code that can
// be found at http://lib.stat.cmu.edu/apstat/
$split1 = 0.425;
$split2 = 5;
$const1 = 0.180625;
$const2 = 1.6;
// coefficients for p close to 0.5
$a0 = 3.3871328727963666080;
$a1 = 1.3314166789178437745E+2;
$a2 = 1.9715909503065514427E+3;
$a3 = 1.3731693765509461125E+4;
$a4 = 4.5921953931549871457E+4;
$a5 = 6.7265770927008700853E+4;
$a6 = 3.3430575583588128105E+4;
$a7 = 2.5090809287301226727E+3;
$b1 = 4.2313330701600911252E+1;
$b2 = 6.8718700749205790830E+2;
$b3 = 5.3941960214247511077E+3;
$b4 = 2.1213794301586595867E+4;
$b5 = 3.9307895800092710610E+4;
$b6 = 2.8729085735721942674E+4;
$b7 = 5.2264952788528545610E+3;
// coefficients for p not close to 0, 0.5 or 1.
$c0 = 1.42343711074968357734;
$c1 = 4.63033784615654529590;
$c2 = 5.76949722146069140550;
$c3 = 3.64784832476320460504;
$c4 = 1.27045825245236838258;
$c5 = 2.41780725177450611770E-1;
$c6 = 2.27238449892691845833E-2;
$c7 = 7.74545014278341407640E-4;
$d1 = 2.05319162663775882187;
$d2 = 1.67638483018380384940;
$d3 = 6.89767334985100004550E-1;
$d4 = 1.48103976427480074590E-1;
$d5 = 1.51986665636164571966E-2;
$d6 = 5.47593808499534494600E-4;
$d7 = 1.05075007164441684324E-9;
// coefficients for p near 0 or 1.
$e0 = 6.65790464350110377720;
$e1 = 5.46378491116411436990;
$e2 = 1.78482653991729133580;
$e3 = 2.96560571828504891230E-1;
$e4 = 2.65321895265761230930E-2;
$e5 = 1.24266094738807843860E-3;
$e6 = 2.71155556874348757815E-5;
$e7 = 2.01033439929228813265E-7;
$f1 = 5.99832206555887937690E-1;
$f2 = 1.36929880922735805310E-1;
$f3 = 1.48753612908506148525E-2;
$f4 = 7.86869131145613259100E-4;
$f5 = 1.84631831751005468180E-5;
$f6 = 1.42151175831644588870E-7;
$f7 = 2.04426310338993978564E-15;
$q = $p - 0.5;
// computation for p close to 0.5
if (abs($q) <= split1) {
$R = $const1 - $q * $q;
$z = $q * ((((((($a7 * $R + $a6) * $R + $a5) * $R + $a4) * $R + $a3) * $R + $a2) * $R + $a1) * $R + $a0) /
((((((($b7 * $R + $b6) * $R + $b5) * $R + $b4) * $R + $b3) * $R + $b2) * $R + $b1) * $R + 1);
} else {
if ($q < 0) {
$R = $p;
} else {
$R = 1 - $p;
}
$R = pow(-log($R),2);
// computation for p not close to 0, 0.5 or 1.
If ($R <= $split2) {
$R = $R - $const2;
$z = ((((((($c7 * $R + $c6) * $R + $c5) * $R + $c4) * $R + $c3) * $R + $c2) * $R + $c1) * $R + $c0) /
((((((($d7 * $R + $d6) * $R + $d5) * $R + $d4) * $R + $d3) * $R + $d2) * $R + $d1) * $R + 1);
} else {
// computation for p near 0 or 1.
$R = $R - $split2;
$z = ((((((($e7 * $R + $e6) * $R + $e5) * $R + $e4) * $R + $e3) * $R + $e2) * $R + $e1) * $R + $e0) /
((((((($f7 * $R + $f6) * $R + $f5) * $R + $f4) * $R + $f3) * $R + $f2) * $R + $f1) * $R + 1);
}
if ($q < 0) {
$z = -$z;
}
}
return $z;
} // function _inverse_ncdf3()
static PHPExcel_Calculation_Functions::_isLeapYear (   $year)
staticprivate

Definition at line 5591 of file Functions.php.

{
return ((($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0));
} // function _isLeapYear()
static PHPExcel_Calculation_Functions::_logBeta (   $p,
  $q 
)
staticprivate

The natural logarithm of the beta function.

Parameters
prequire p>0
qrequire q>0
Returns
0 if p<=0, q<=0 or p+q>2.55E305 to avoid errors and over/underflow
Author
Jaco van Kooten

Definition at line 3477 of file Functions.php.

References $_logBetaCache_result, $q, _logGamma(), and LOG_GAMMA_X_MAX_VALUE.

{
if ($p != self::$_logBetaCache_p || $q != self::$_logBetaCache_q) {
self::$_logBetaCache_p = $p;
self::$_logBetaCache_q = $q;
if (($p <= 0.0) || ($q <= 0.0) || (($p + $q) > LOG_GAMMA_X_MAX_VALUE)) {
self::$_logBetaCache_result = 0.0;
} else {
self::$_logBetaCache_result = self::_logGamma($p) + self::_logGamma($q) - self::_logGamma($p + $q);
}
}
} // function _logBeta()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::_logGamma (   $x)
staticprivate

Definition at line 3589 of file Functions.php.

References $_logGammaCache_result, $res, $x, $y, elseif(), EPS, LOG_GAMMA_X_MAX_VALUE, MAX_VALUE, and SQRT2PI.

Referenced by _logBeta().

{
// Log Gamma related constants
static $lg_d1 = -0.5772156649015328605195174;
static $lg_d2 = 0.4227843350984671393993777;
static $lg_d4 = 1.791759469228055000094023;
static $lg_p1 = array( 4.945235359296727046734888,
201.8112620856775083915565,
2290.838373831346393026739,
11319.67205903380828685045,
28557.24635671635335736389,
38484.96228443793359990269,
26377.48787624195437963534,
7225.813979700288197698961 );
static $lg_p2 = array( 4.974607845568932035012064,
542.4138599891070494101986,
15506.93864978364947665077,
184793.2904445632425417223,
1088204.76946882876749847,
3338152.967987029735917223,
5106661.678927352456275255,
3074109.054850539556250927 );
static $lg_p4 = array( 14745.02166059939948905062,
2426813.369486704502836312,
121475557.4045093227939592,
2663432449.630976949898078,
29403789566.34553899906876,
170266573776.5398868392998,
492612579337.743088758812,
560625185622.3951465078242 );
static $lg_q1 = array( 67.48212550303777196073036,
1113.332393857199323513008,
7738.757056935398733233834,
27639.87074403340708898585,
54993.10206226157329794414,
61611.22180066002127833352,
36351.27591501940507276287,
8785.536302431013170870835 );
static $lg_q2 = array( 183.0328399370592604055942,
7765.049321445005871323047,
133190.3827966074194402448,
1136705.821321969608938755,
5267964.117437946917577538,
13467014.54311101692290052,
17827365.30353274213975932,
9533095.591844353613395747 );
static $lg_q4 = array( 2690.530175870899333379843,
639388.5654300092398984238,
41355999.30241388052042842,
1120872109.61614794137657,
14886137286.78813811542398,
101680358627.2438228077304,
341747634550.7377132798597,
446315818741.9713286462081 );
static $lg_c = array( -0.001910444077728,
8.4171387781295e-4,
-5.952379913043012e-4,
7.93650793500350248e-4,
-0.002777777777777681622553,
0.08333333333333333331554247,
0.0057083835261 );
// Rough estimate of the fourth root of logGamma_xBig
static $lg_frtbig = 2.25e76;
static $pnt68 = 0.6796875;
if ($x == self::$_logGammaCache_x) {
}
$y = $x;
if ($y > 0.0 && $y <= LOG_GAMMA_X_MAX_VALUE) {
if ($y <= EPS) {
$res = -log(y);
} elseif ($y <= 1.5) {
// ---------------------
// EPS .LT. X .LE. 1.5
// ---------------------
if ($y < $pnt68) {
$corr = -log($y);
$xm1 = $y;
} else {
$corr = 0.0;
$xm1 = $y - 1.0;
}
if ($y <= 0.5 || $y >= $pnt68) {
$xden = 1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm1 + $lg_p1[$i];
$xden = $xden * $xm1 + $lg_q1[$i];
}
$res = $corr + $xm1 * ($lg_d1 + $xm1 * ($xnum / $xden));
} else {
$xm2 = $y - 1.0;
$xden = 1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm2 + $lg_p2[$i];
$xden = $xden * $xm2 + $lg_q2[$i];
}
$res = $corr + $xm2 * ($lg_d2 + $xm2 * ($xnum / $xden));
}
} elseif ($y <= 4.0) {
// ---------------------
// 1.5 .LT. X .LE. 4.0
// ---------------------
$xm2 = $y - 2.0;
$xden = 1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm2 + $lg_p2[$i];
$xden = $xden * $xm2 + $lg_q2[$i];
}
$res = $xm2 * ($lg_d2 + $xm2 * ($xnum / $xden));
} elseif ($y <= 12.0) {
// ----------------------
// 4.0 .LT. X .LE. 12.0
// ----------------------
$xm4 = $y - 4.0;
$xden = -1.0;
$xnum = 0.0;
for ($i = 0; $i < 8; ++$i) {
$xnum = $xnum * $xm4 + $lg_p4[$i];
$xden = $xden * $xm4 + $lg_q4[$i];
}
$res = $lg_d4 + $xm4 * ($xnum / $xden);
} else {
// ---------------------------------
// Evaluate for argument .GE. 12.0
// ---------------------------------
$res = 0.0;
if ($y <= $lg_frtbig) {
$res = $lg_c[6];
$ysq = $y * $y;
for ($i = 0; $i < 6; ++$i)
$res = $res / $ysq + $lg_c[$i];
}
$res /= $y;
$corr = log($y);
$res = $res + log(SQRT2PI) - 0.5 * $corr;
$res += $y * ($corr - 1.0);
}
} else {
// --------------------------
// Return for bad arguments
// --------------------------
}
// ------------------------------
// Final adjustments and return
// ------------------------------
self::$_logGammaCache_x = $x;
self::$_logGammaCache_result = $res;
return $res;
} // function _logGamma()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_modeCalc (   $data)
staticprivate

Definition at line 1324 of file Functions.php.

References $data, $key, and NA().

Referenced by MODE().

{
$frequencyArray = array();
foreach($data as $datum) {
$found = False;
foreach($frequencyArray as $key => $value) {
if ((string) $value['value'] == (string) $datum) {
++$frequencyArray[$key]['frequency'];
$found = True;
break;
}
}
if (!$found) {
$frequencyArray[] = array('value' => $datum,
'frequency' => 1 );
}
}
foreach($frequencyArray as $key => $value) {
$frequencyList[$key] = $value['frequency'];
$valueList[$key] = $value['value'];
}
array_multisort($frequencyList, SORT_DESC, $valueList, SORT_ASC, SORT_NUMERIC, $frequencyArray);
if ($frequencyArray[0]['frequency'] == 1) {
return self::NA();
}
return $frequencyArray[0]['value'];
} // function _modeCalc()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_nbrConversionFormat (   $xVal,
  $places 
)
staticprivate

Definition at line 6347 of file Functions.php.

Referenced by BINTOHEX(), BINTOOCT(), DECTOBIN(), DECTOHEX(), DECTOOCT(), HEXTOOCT(), OCTTOBIN(), and OCTTOHEX().

{
if (!is_null($places)) {
if (strlen($xVal) <= $places) {
return substr(str_pad($xVal,$places,'0',STR_PAD_LEFT),-10);
} else {
return self::$_errorCodes['num'];
}
}
return substr($xVal,-10);
} // function _nbrConversionFormat()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_parseComplex (   $complexNumber)
static

Definition at line 6720 of file Functions.php.

References elseif().

Referenced by IMABS(), IMAGINARY(), IMARGUMENT(), IMCONJUGATE(), IMCOS(), IMDIV(), IMEXP(), IMLN(), IMLOG10(), IMLOG2(), IMPOWER(), IMPRODUCT(), IMREAL(), IMSIN(), IMSQRT(), IMSUB(), and IMSUM().

{
$workString = (string) $complexNumber;
$realNumber = $imaginary = 0;
// Extract the suffix, if there is one
$suffix = substr($workString,-1);
if (!is_numeric($suffix)) {
$workString = substr($workString,0,-1);
} else {
$suffix = '';
}
// Split the input into its Real and Imaginary components
$leadingSign = 0;
if (strlen($workString) > 0) {
$leadingSign = (($workString{0} == '+') || ($workString{0} == '-')) ? 1 : 0;
}
$power = '';
$realNumber = strtok($workString, '+-');
if (strtoupper(substr($realNumber,-1)) == 'E') {
$power = strtok('+-');
++$leadingSign;
}
$realNumber = substr($workString,0,strlen($realNumber)+strlen($power)+$leadingSign);
if ($suffix != '') {
$imaginary = substr($workString,strlen($realNumber));
if (($imaginary == '') && (($realNumber == '') || ($realNumber == '+') || ($realNumber == '-'))) {
$imaginary = $realNumber.'1';
$realNumber = '0';
} else if ($imaginary == '') {
$imaginary = $realNumber;
$realNumber = '0';
} elseif (($imaginary == '+') || ($imaginary == '-')) {
$imaginary .= '1';
}
}
$complexArray = array( 'real' => $realNumber,
'imaginary' => $imaginary,
'suffix' => $suffix
);
return $complexArray;
} // function _parseComplex()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::_romanCut (   $num,
  $n 
)
staticprivate

Definition at line 2434 of file Functions.php.

References $n.

Referenced by ROMAN().

{
return ($num - ($num % $n ) ) / $n;
} // function _romanCut()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::ACCRINT (   $issue,
  $firstinter,
  $settlement,
  $rate,
  $par = 1000,
  $frequency = 1,
  $basis = 0 
)
static

ACCRINT.

Returns the discount rate for a security.

Parameters
mixedissue The security's issue date.
mixedfirstinter The security's first interest date.
mixedsettlement The security's settlement date.
floatrate The security's annual coupon rate.
floatpar The security's par value.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9131 of file Functions.php.

References _daysPerYear(), flattenSingleValue(), and YEARFRAC().

{
$issue = self::flattenSingleValue($issue);
$firstinter = self::flattenSingleValue($firstinter);
$settlement = self::flattenSingleValue($settlement);
$rate = (float) self::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : (float) self::flattenSingleValue($par);
$frequency = (is_null($frequency)) ? 1 : (int) self::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
if (($rate <= 0) || ($par <= 0)) {
return self::$_errorCodes['num'];
}
$daysBetweenIssueAndSettlement = self::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
return $daysBetweenIssueAndSettlement;
}
$daysPerYear = self::_daysPerYear(self::YEAR($issue),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
return $par * $rate * ($daysBetweenIssueAndSettlement / $daysPerYear);
}
return self::$_errorCodes['value'];
} // function ACCRINT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ACCRINTM (   $issue,
  $settlement,
  $rate,
  $par = 1000,
  $basis = 0 
)
static

ACCRINTM.

Returns the discount rate for a security.

Parameters
mixedissue The security's issue date.
mixedsettlement The security's settlement date.
floatrate The security's annual coupon rate.
floatpar The security's par value.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9178 of file Functions.php.

References _daysPerYear(), flattenSingleValue(), and YEARFRAC().

{
$issue = self::flattenSingleValue($issue);
$settlement = self::flattenSingleValue($settlement);
$rate = (float) self::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : (float) self::flattenSingleValue($par);
$basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
if (($rate <= 0) || ($par <= 0)) {
return self::$_errorCodes['num'];
}
$daysBetweenIssueAndSettlement = self::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
return $daysBetweenIssueAndSettlement;
}
$daysPerYear = self::_daysPerYear(self::YEAR($issue),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
return $par * $rate * ($daysBetweenIssueAndSettlement / $daysPerYear);
}
return self::$_errorCodes['value'];
} // function ACCRINTM()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::AMORDEGRC (   $cost,
  $purchased,
  $firstPeriod,
  $salvage,
  $period,
  $rate,
  $basis = 0 
)
static

Definition at line 9206 of file Functions.php.

{
} // function AMORDEGRC()
static PHPExcel_Calculation_Functions::AMORLINC (   $cost,
  $purchased,
  $firstPeriod,
  $salvage,
  $period,
  $rate,
  $basis = 0 
)
static

Definition at line 9210 of file Functions.php.

{
} // function AMORLINC()
static PHPExcel_Calculation_Functions::ASCIICODE (   $characters)
static

ASCIICODE.

Parameters
string$characterValue
Returns
int

Definition at line 4795 of file Functions.php.

References flattenSingleValue().

{
$characters = self::flattenSingleValue($characters);
if (is_bool($characters)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$characters = (int) $characters;
} else {
if ($characters) {
$characters = 'True';
} else {
$characters = 'False';
}
}
}
if ((function_exists('mb_strlen')) && (function_exists('mb_substr'))) {
if (mb_strlen($characters, 'UTF-8') > 0) {
$character = mb_substr($characters, 0, 1, 'UTF-8');
$byteLength = strlen($character);
$xValue = 0;
for ($i = 0; $i < $byteLength; ++$i) {
$xValue = ($xValue * 256) + ord($character{$i});
}
return $xValue;
}
} else {
if (strlen($characters) > 0) {
return ord(substr($characters, 0, 1));
}
}
return self::$_errorCodes['value'];
} // function ASCIICODE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::AVEDEV ( )
static

Definition at line 1453 of file Functions.php.

References AVERAGE(), and flattenArray().

{
$aArgs = self::flattenArray(func_get_args());
// Return value
$returnValue = null;
$aMean = self::AVERAGE($aArgs);
if ($aMean != self::$_errorCodes['divisionbyzero']) {
$aCount = 0;
foreach ($aArgs as $arg) {
if ((is_bool($arg)) && (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
$arg = (integer) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = abs($arg - $aMean);
} else {
$returnValue += abs($arg - $aMean);
}
++$aCount;
}
}
// Return
return $returnValue / $aCount ;
}
return self::$_errorCodes['num'];
} // function AVEDEV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::AVERAGE ( )
static

Definition at line 1200 of file Functions.php.

References flattenArray().

Referenced by AVEDEV(), DEVSQ(), KURT(), SKEW(), STDEV(), STDEVP(), SUBTOTAL(), and TRIMMEAN().

{
// Return value
$returnValue = 0;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
if ((is_bool($arg)) && (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
$arg = (integer) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = $arg;
} else {
$returnValue += $arg;
}
++$aCount;
}
}
// Return
if ($aCount > 0) {
return $returnValue / $aCount;
} else {
return self::$_errorCodes['divisionbyzero'];
}
} // function AVERAGE()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::AVERAGEA ( )
static

Definition at line 1244 of file Functions.php.

References elseif(), and flattenArray().

Referenced by STDEVA(), and STDEVPA().

{
// Return value
$returnValue = null;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if (is_null($returnValue)) {
$returnValue = $arg;
} else {
$returnValue += $arg;
}
++$aCount;
}
}
// Return
if ($aCount > 0) {
return $returnValue / $aCount;
} else {
return self::$_errorCodes['divisionbyzero'];
}
} // function AVERAGEA()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::BESSELI (   $x,
  $n 
)
static

BESSELI.

Returns the modified Bessel function, which is equivalent to the Bessel function evaluated for purely imaginary arguments

Parameters
float$x
float$n
Returns
int

Definition at line 8095 of file Functions.php.

References $n, $x, FACT(), and flattenSingleValue().

Referenced by _Besselk0(), and _Besselk1().

{
$n = floor(self::flattenSingleValue($n));
if ((is_numeric($x)) && (is_numeric($n))) {
if ($n < 0) {
return self::$_errorCodes['num'];
}
$f_2_PI = 2 * pi();
if (abs($x) <= 30) {
$fTerm = pow($x / 2, $n) / self::FACT($n);
$nK = 1;
$fResult = $fTerm;
$fSqrX = pow($x,2) / 4;
do {
$fTerm *= $fSqrX;
$fTerm /= ($nK * ($nK + $n));
$fResult += $fTerm;
} while ((abs($fTerm) > 1e-10) && (++$nK < 100));
} else {
$fXAbs = abs($x);
$fResult = exp($fXAbs) / sqrt($f_2_PI * $fXAbs);
if (($n && 1) && ($x < 0)) {
$fResult = -$fResult;
}
}
return $fResult;
}
return self::$_errorCodes['value'];
} // function BESSELI()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::BESSELJ (   $x,
  $n 
)
static

BESSELJ.

Returns the Bessel function

Parameters
float$x
float$n
Returns
int

Definition at line 8137 of file Functions.php.

References $n, $x, FACT(), and flattenSingleValue().

Referenced by _Bessely0(), and _Bessely1().

{
$n = floor(self::flattenSingleValue($n));
if ((is_numeric($x)) && (is_numeric($n))) {
if ($n < 0) {
return self::$_errorCodes['num'];
}
$f_2_DIV_PI = 2 / pi();
$f_PI_DIV_2 = pi() / 2;
$f_PI_DIV_4 = pi() / 4;
$fResult = 0;
if (abs($x) <= 30) {
$fTerm = pow($x / 2, $n) / self::FACT($n);
$nK = 1;
$fResult = $fTerm;
$fSqrX = pow($x,2) / -4;
do {
$fTerm *= $fSqrX;
$fTerm /= ($nK * ($nK + $n));
$fResult += $fTerm;
} while ((abs($fTerm) > 1e-10) && (++$nK < 100));
} else {
$fXAbs = abs($x);
$fResult = sqrt($f_2_DIV_PI / $fXAbs) * cos($fXAbs - $n * $f_PI_DIV_2 - $f_PI_DIV_4);
if (($n && 1) && ($x < 0)) {
$fResult = -$fResult;
}
}
return $fResult;
}
return self::$_errorCodes['value'];
} // function BESSELJ()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::BESSELK (   $x,
  $ord 
)
static

BESSELK.

Returns the modified Bessel function, which is equivalent to the Bessel functions evaluated for purely imaginary arguments.

Parameters
float$x
float$ord
Returns
float

Definition at line 8216 of file Functions.php.

References $n, $x, _Besselk0(), _Besselk1(), and flattenSingleValue().

{
$ord = floor(self::flattenSingleValue($ord));
if ((is_numeric($x)) && (is_numeric($ord))) {
if ($ord < 0) {
return self::$_errorCodes['num'];
}
switch($ord) {
case 0 : return self::_Besselk0($x);
break;
case 1 : return self::_Besselk1($x);
break;
default : $fTox = 2 / $x;
$fBkm = self::_Besselk0($x);
for ($n = 1; $n < $ord; ++$n) {
$fBkp = $fBkm + $n * $fTox * $fBk;
$fBkm = $fBk;
$fBk = $fBkp;
}
}
return $fBk;
}
return self::$_errorCodes['value'];
} // function BESSELK()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::BESSELY (   $x,
  $ord 
)
static

BESSELY.

Returns the Bessel function, which is also called the Weber function or the Neumann function.

Parameters
float$x
float$n
Returns
int

Definition at line 8294 of file Functions.php.

References $n, $x, _Bessely0(), _Bessely1(), and flattenSingleValue().

{
$ord = floor(self::flattenSingleValue($ord));
if ((is_numeric($x)) && (is_numeric($ord))) {
if ($ord < 0) {
return self::$_errorCodes['num'];
}
switch($ord) {
case 0 : return self::_Bessely0($x);
break;
case 1 : return self::_Bessely1($x);
break;
default: $fTox = 2 / $x;
$fBym = self::_Bessely0($x);
for ($n = 1; $n < $ord; ++$n) {
$fByp = $n * $fTox * $fBy - $fBym;
$fBym = $fBy;
$fBy = $fByp;
}
}
return $fBy;
}
return self::$_errorCodes['value'];
} // function BESSELY()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::BETADIST (   $value,
  $alpha,
  $beta,
  $rMin = 0,
  $rMax = 1 
)
static

BETADIST.

Returns the beta distribution.

Parameters
float$valueValue at which you want to evaluate the distribution
float$alphaParameter to the distribution
float$betaParameter to the distribution
boolean$cumulative
Returns
float

Definition at line 3808 of file Functions.php.

References _incompleteBeta(), and flattenSingleValue().

Referenced by BETAINV().

{
$value = self::flattenSingleValue($value);
$alpha = self::flattenSingleValue($alpha);
$beta = self::flattenSingleValue($beta);
$rMin = self::flattenSingleValue($rMin);
$rMax = self::flattenSingleValue($rMax);
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
if (($value < $rMin) || ($value > $rMax) || ($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax)) {
return self::$_errorCodes['num'];
}
if ($rMin > $rMax) {
$tmp = $rMin;
$rMin = $rMax;
$rMax = $tmp;
}
$value -= $rMin;
$value /= ($rMax - $rMin);
return self::_incompleteBeta($value,$alpha,$beta);
}
return self::$_errorCodes['value'];
} // function BETADIST()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::BETAINV (   $probability,
  $alpha,
  $beta,
  $rMin = 0,
  $rMax = 1 
)
static

BETAINV.

Returns the inverse of the beta distribution.

Parameters
float$probabilityProbability at which you want to evaluate the distribution
float$alphaParameter to the distribution
float$betaParameter to the distribution
boolean$cumulative
Returns
float

Definition at line 3844 of file Functions.php.

References $result, BETADIST(), elseif(), flattenSingleValue(), MAX_ITERATIONS, and PRECISION.

{
$probability = self::flattenSingleValue($probability);
$alpha = self::flattenSingleValue($alpha);
$beta = self::flattenSingleValue($beta);
$rMin = self::flattenSingleValue($rMin);
$rMax = self::flattenSingleValue($rMax);
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta)) && (is_numeric($rMin)) && (is_numeric($rMax))) {
if (($alpha <= 0) || ($beta <= 0) || ($rMin == $rMax) || ($probability <= 0) || ($probability > 1)) {
return self::$_errorCodes['num'];
}
if ($rMin > $rMax) {
$tmp = $rMin;
$rMin = $rMax;
$rMax = $tmp;
}
$a = 0;
$b = 2;
$maxIteration = 100;
$i = 0;
while ((($b - $a) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
$guess = ($a + $b) / 2;
$result = self::BETADIST($guess, $alpha, $beta);
if (($result == $probability) || ($result == 0)) {
$b = $a;
} elseif ($result > $probability) {
$b = $guess;
} else {
$a = $guess;
}
}
if ($i == MAX_ITERATIONS) {
return self::$_errorCodes['na'];
}
return round($rMin + $guess * ($rMax - $rMin),12);
}
return self::$_errorCodes['value'];
} // function BETAINV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::BINOMDIST (   $value,
  $trials,
  $probability,
  $cumulative 
)
static

BINOMDIST.

Returns the individual term binomial distribution probability. Use BINOMDIST in problems with a fixed number of tests or trials, when the outcomes of any trial are only success or failure, when trials are independent, and when the probability of success is constant throughout the experiment. For example, BINOMDIST can calculate the probability that two of the next three babies born are male.

Parameters
float$valueNumber of successes in trials
float$trialsNumber of trials
float$probabilityProbability of success on each trial
boolean$cumulative
Returns
float
Todo:
Cumulative distribution function

Definition at line 3128 of file Functions.php.

References COMBIN(), and flattenSingleValue().

{
$value = floor(self::flattenSingleValue($value));
$trials = floor(self::flattenSingleValue($trials));
$probability = self::flattenSingleValue($probability);
if ((is_numeric($value)) && (is_numeric($trials)) && (is_numeric($probability))) {
if (($value < 0) || ($value > $trials)) {
return self::$_errorCodes['num'];
}
if (($probability < 0) || ($probability > 1)) {
return self::$_errorCodes['num'];
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
$summer = 0;
for ($i = 0; $i <= $value; ++$i) {
$summer += self::COMBIN($trials,$i) * pow($probability,$i) * pow(1 - $probability,$trials - $i);
}
return $summer;
} else {
return self::COMBIN($trials,$value) * pow($probability,$value) * pow(1 - $probability,$trials - $value) ;
}
}
}
return self::$_errorCodes['value'];
} // function BINOMDIST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::BINTODEC (   $x)
static

BINTODEC.

Return a binary value as Decimal.

Parameters
string$x
Returns
string

Definition at line 6368 of file Functions.php.

References $out, $x, elseif(), and flattenSingleValue().

{
if (is_bool($x)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return self::$_errorCodes['value'];
}
}
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
$x = floor($x);
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return self::$_errorCodes['num'];
}
if (strlen($x) > 10) {
return self::$_errorCodes['num'];
} elseif (strlen($x) == 10) {
// Two's Complement
$x = substr($x,-9);
return '-'.(512-bindec($x));
}
return bindec($x);
} // function BINTODEC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::BINTOHEX (   $x,
  $places = null 
)
static

BINTOHEX.

Return a binary value as Hex.

Parameters
string$x
Returns
string

Definition at line 6404 of file Functions.php.

References $out, $x, _nbrConversionFormat(), elseif(), and flattenSingleValue().

{
$x = floor(self::flattenSingleValue($x));
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return self::$_errorCodes['value'];
}
}
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
$x = floor($x);
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return self::$_errorCodes['num'];
}
if (strlen($x) > 10) {
return self::$_errorCodes['num'];
} elseif (strlen($x) == 10) {
// Two's Complement
return str_repeat('F',8).substr(strtoupper(dechex(bindec(substr($x,-9)))),-2);
}
$hexVal = (string) strtoupper(dechex(bindec($x)));
return self::_nbrConversionFormat($hexVal,$places);
} // function BINTOHEX()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::BINTOOCT (   $x,
  $places = null 
)
static

BINTOOCT.

Return a binary value as Octal.

Parameters
string$x
Returns
string

Definition at line 6442 of file Functions.php.

References $out, $x, _nbrConversionFormat(), elseif(), and flattenSingleValue().

{
$x = floor(self::flattenSingleValue($x));
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return self::$_errorCodes['value'];
}
}
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
$x = floor($x);
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[01]/',$x,$out)) {
return self::$_errorCodes['num'];
}
if (strlen($x) > 10) {
return self::$_errorCodes['num'];
} elseif (strlen($x) == 10) {
// Two's Complement
return str_repeat('7',7).substr(strtoupper(decoct(bindec(substr($x,-9)))),-3);
}
$octVal = (string) decoct(bindec($x));
return self::_nbrConversionFormat($octVal,$places);
} // function BINTOOCT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CEILING (   $number,
  $significance = null 
)
static

CEILING.

Returns number rounded up, away from zero, to the nearest multiple of significance.

Parameters
float$numberNumber to round
float$significanceSignificance
Returns
float Rounded Number

Definition at line 2645 of file Functions.php.

References flattenSingleValue().

Referenced by EVEN(), and ODD().

{
$number = self::flattenSingleValue($number);
$significance = self::flattenSingleValue($significance);
if ((is_null($significance)) && (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC)) {
$significance = $number/abs($number);
}
if ((is_numeric($number)) && (is_numeric($significance))) {
if (self::SIGN($number) == self::SIGN($significance)) {
if ($significance == 0.0) {
return 0;
}
return ceil($number / $significance) * $significance;
} else {
return self::$_errorCodes['num'];
}
}
return self::$_errorCodes['value'];
} // function CEILING()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::CELL_ADDRESS (   $row,
  $column,
  $relativity = 1,
  $referenceStyle = True,
  $sheetText = '' 
)
static

CELL_ADDRESS.

Returns the straight-line depreciation of an asset for one period

Parameters
rowRow number to use in the cell reference
columnColumn number to use in the cell reference
relativityFlag indicating the type of reference to return
sheetTextName of worksheet to use
Returns
string

Definition at line 9711 of file Functions.php.

References $row, flattenSingleValue(), and PHPExcel_Cell\stringFromColumnIndex().

{
$column = self::flattenSingleValue($column);
$relativity = self::flattenSingleValue($relativity);
$sheetText = self::flattenSingleValue($sheetText);
if ($sheetText > '') {
if (strpos($sheetText,' ') !== False) { $sheetText = "'".$sheetText."'"; }
$sheetText .='!';
}
if ((!is_bool($referenceStyle)) || $referenceStyle) {
$rowRelative = $columnRelative = '$';
if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; }
if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; }
return $sheetText.$columnRelative.$column.$rowRelative.$row;
} else {
if (($relativity == 2) || ($relativity == 4)) { $column = '['.$column.']'; }
if (($relativity == 3) || ($relativity == 4)) { $row = '['.$row.']'; }
return $sheetText.'R'.$row.'C'.$column;
}
} // function CELL_ADDRESS()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CHARACTER (   $character)
static

CHARACTER.

Parameters
string$characterValue
Returns
int

Definition at line 4779 of file Functions.php.

References flattenSingleValue().

{
$character = self::flattenSingleValue($character);
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding('&#'.intval($character).';', 'UTF-8', 'HTML-ENTITIES');
} else {
return chr(intval($character));
}
}

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CHIDIST (   $value,
  $degrees 
)
static

CHIDIST.

Returns the one-tailed probability of the chi-squared distribution.

Parameters
float$valueValue for the function
float$degreesdegrees of freedom
Returns
float

Definition at line 3313 of file Functions.php.

References _gamma(), _incompleteGamma(), and flattenSingleValue().

Referenced by CHIINV().

{
$value = self::flattenSingleValue($value);
$degrees = floor(self::flattenSingleValue($degrees));
if ((is_numeric($value)) && (is_numeric($degrees))) {
if ($degrees < 1) {
return self::$_errorCodes['num'];
}
if ($value < 0) {
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
return 1;
}
return self::$_errorCodes['num'];
}
return 1 - (self::_incompleteGamma($degrees/2,$value/2) / self::_gamma($degrees/2));
}
return self::$_errorCodes['value'];
} // function CHIDIST()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::CHIINV (   $probability,
  $degrees 
)
static

CHIINV.

Returns the one-tailed probability of the chi-squared distribution.

Parameters
float$probabilityProbability for the function
float$degreesdegrees of freedom
Returns
float

Definition at line 3342 of file Functions.php.

References $error, $result, $x, CHIDIST(), elseif(), flattenSingleValue(), MAX_ITERATIONS, and PRECISION.

{
$probability = self::flattenSingleValue($probability);
$degrees = floor(self::flattenSingleValue($degrees));
if ((is_numeric($probability)) && (is_numeric($degrees))) {
$xLo = 100;
$xHi = 0;
$maxIteration = 100;
$x = $xNew = 1;
$dx = 1;
$i = 0;
while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
// Apply Newton-Raphson step
$result = self::CHIDIST($x, $degrees);
$error = $result - $probability;
if ($error == 0.0) {
$dx = 0;
} elseif ($error < 0.0) {
$xLo = $x;
} else {
$xHi = $x;
}
// Avoid division by zero
if ($result != 0.0) {
$dx = $error / $result;
$xNew = $x - $dx;
}
// If the NR fails to converge (which for example may be the
// case if the initial guess is too rough) we apply a bisection
// step to determine a more narrow interval around the root.
if (($xNew < $xLo) || ($xNew > $xHi) || ($result == 0.0)) {
$xNew = ($xLo + $xHi) / 2;
$dx = $xNew - $x;
}
$x = $xNew;
}
if ($i == MAX_ITERATIONS) {
return self::$_errorCodes['na'];
}
return round($x,12);
}
return self::$_errorCodes['value'];
} // function CHIINV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CHOOSE ( )
static

Definition at line 9809 of file Functions.php.

References flattenArray(), and flattenSingleValue().

{
$chooseArgs = func_get_args();
$chosenEntry = self::flattenSingleValue(array_shift($chooseArgs));
$entryCount = count($chooseArgs) - 1;
if ((is_numeric($chosenEntry)) && (!is_bool($chosenEntry))) {
--$chosenEntry;
} else {
return self::$_errorCodes['value'];
}
$chosenEntry = floor($chosenEntry);
if (($chosenEntry <= 0) || ($chosenEntry > $entryCount)) {
return self::$_errorCodes['value'];
}
if (is_array($chooseArgs[$chosenEntry])) {
return self::flattenArray($chooseArgs[$chosenEntry]);
} else {
return $chooseArgs[$chosenEntry];
}
} // function CHOOSE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::COLUMN (   $cellAddress = Null)
static

Definition at line 9735 of file Functions.php.

References PHPExcel_Cell\columnIndexFromString().

{
if (is_null($cellAddress) || $cellAddress === '') {
return 0;
}
foreach($cellAddress as $columnKey => $value) {
}
} // function COLUMN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::COMBIN (   $numObjs,
  $numInSet 
)
static

COMBIN.

Returns the number of combinations for a given number of items. Use COMBIN to determine the total possible number of groups for a given number of items.

Parameters
int$numObjsNumber of different objects
int$numInSetNumber of objects in each combination
Returns
int Number of combinations

Definition at line 2897 of file Functions.php.

References elseif(), FACT(), and flattenSingleValue().

Referenced by BINOMDIST(), and HYPGEOMDIST().

{
$numObjs = self::flattenSingleValue($numObjs);
$numInSet = self::flattenSingleValue($numInSet);
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
if ($numObjs < $numInSet) {
return self::$_errorCodes['num'];
} elseif ($numInSet < 0) {
return self::$_errorCodes['num'];
}
return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet);
}
return self::$_errorCodes['value'];
} // function COMBIN()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::COMPLEX (   $realNumber = 0.0,
  $imaginary = 0.0,
  $suffix = 'i' 
)
static

COMPLEX.

returns a complex number of the form x + yi or x + yj.

Parameters
float$realNumber
float$imaginary
string$suffix
Returns
string

Definition at line 6788 of file Functions.php.

References elseif(), and flattenSingleValue().

Referenced by IMEXP(), IMLN(), IMPOWER(), IMPRODUCT(), IMSIN(), IMSQRT(), IMSUB(), and IMSUM().

{
$realNumber = self::flattenSingleValue($realNumber);
$imaginary = self::flattenSingleValue($imaginary);
$suffix = self::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))) {
if ($realNumber == 0.0) {
if ($imaginary == 0.0) {
return (string) '0';
} elseif ($imaginary == 1.0) {
return (string) $suffix;
} elseif ($imaginary == -1.0) {
return (string) '-'.$suffix;
}
return (string) $imaginary.$suffix;
} elseif ($imaginary == 0.0) {
return (string) $realNumber;
} elseif ($imaginary == 1.0) {
return (string) $realNumber.'+'.$suffix;
} elseif ($imaginary == -1.0) {
return (string) $realNumber.'-'.$suffix;
}
if ($imaginary > 0) { $imaginary = (string) '+'.$imaginary; }
return (string) $realNumber.$imaginary.$suffix;
}
return self::$_errorCodes['value'];
} // function COMPLEX()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::CONCATENATE ( )
static

CONCATENATE.

Returns
string

Definition at line 4833 of file Functions.php.

References flattenArray().

{
// Return value
$returnValue = '';
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
if (is_bool($arg)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$arg = (int) $arg;
} else {
if ($arg) {
$arg = 'TRUE';
} else {
$arg = 'FALSE';
}
}
}
$returnValue .= $arg;
}
// Return
return $returnValue;
} // function CONCATENATE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CONFIDENCE (   $alpha,
  $stdDev,
  $size 
)
static

CONFIDENCE.

Returns the confidence interval for a population mean

Parameters
float$alpha
float$stdDevStandard Deviation
float$size
Returns
float

Definition at line 4580 of file Functions.php.

References $size, flattenSingleValue(), and NORMSINV().

{
$alpha = self::flattenSingleValue($alpha);
$stdDev = self::flattenSingleValue($stdDev);
$size = floor(self::flattenSingleValue($size));
if ((is_numeric($alpha)) && (is_numeric($stdDev)) && (is_numeric($size))) {
if (($alpha <= 0) || ($alpha >= 1)) {
return self::$_errorCodes['num'];
}
if (($stdDev <= 0) || ($size < 1)) {
return self::$_errorCodes['num'];
}
return self::NORMSINV(1 - $alpha / 2) * $stdDev / sqrt($size);
}
return self::$_errorCodes['value'];
} // function CONFIDENCE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CONVERTUOM (   $value,
  $fromUOM,
  $toUOM 
)
static

CONVERTUOM.

Parameters
float$value
string$fromUOM
string$toUOM
Returns
float

Definition at line 8003 of file Functions.php.

References elseif(), and flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$fromUOM = self::flattenSingleValue($fromUOM);
$toUOM = self::flattenSingleValue($toUOM);
if (!is_numeric($value)) {
return self::$_errorCodes['value'];
}
$fromMultiplier = 1;
if (isset(self::$_conversionUnits[$fromUOM])) {
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
} else {
$fromMultiplier = substr($fromUOM,0,1);
$fromUOM = substr($fromUOM,1);
if (isset(self::$_conversionMultipliers[$fromMultiplier])) {
$fromMultiplier = self::$_conversionMultipliers[$fromMultiplier]['multiplier'];
} else {
return self::$_errorCodes['na'];
}
if ((isset(self::$_conversionUnits[$fromUOM])) && (self::$_conversionUnits[$fromUOM]['AllowPrefix'])) {
$unitGroup1 = self::$_conversionUnits[$fromUOM]['Group'];
} else {
return self::$_errorCodes['na'];
}
}
$value *= $fromMultiplier;
$toMultiplier = 1;
if (isset(self::$_conversionUnits[$toUOM])) {
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
} else {
$toMultiplier = substr($toUOM,0,1);
$toUOM = substr($toUOM,1);
if (isset(self::$_conversionMultipliers[$toMultiplier])) {
$toMultiplier = self::$_conversionMultipliers[$toMultiplier]['multiplier'];
} else {
return self::$_errorCodes['na'];
}
if ((isset(self::$_conversionUnits[$toUOM])) && (self::$_conversionUnits[$toUOM]['AllowPrefix'])) {
$unitGroup2 = self::$_conversionUnits[$toUOM]['Group'];
} else {
return self::$_errorCodes['na'];
}
}
if ($unitGroup1 != $unitGroup2) {
return self::$_errorCodes['na'];
}
if ($fromUOM == $toUOM) {
return 1.0;
} elseif ($unitGroup1 == 'Temperature') {
if (($fromUOM == 'F') || ($fromUOM == 'fah')) {
if (($toUOM == 'F') || ($toUOM == 'fah')) {
return 1.0;
} else {
$value = (($value - 32) / 1.8);
if (($toUOM == 'K') || ($toUOM == 'kel')) {
$value += 273.15;
}
return $value;
}
} elseif ((($fromUOM == 'K') || ($fromUOM == 'kel')) &&
(($toUOM == 'K') || ($toUOM == 'kel'))) {
return 1.0;
} elseif ((($fromUOM == 'C') || ($fromUOM == 'cel')) &&
(($toUOM == 'C') || ($toUOM == 'cel'))) {
return 1.0;
}
if (($toUOM == 'F') || ($toUOM == 'fah')) {
if (($fromUOM == 'K') || ($fromUOM == 'kel')) {
$value -= 273.15;
}
return ($value * 1.8) + 32;
}
if (($toUOM == 'C') || ($toUOM == 'cel')) {
return $value - 273.15;
}
return $value + 273.15;
}
return ($value * self::$_unitConversions[$unitGroup1][$fromUOM][$toUOM]) / $toMultiplier;
} // function CONVERTUOM()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CORREL (   $yValues,
  $xValues 
)
static

CORREL.

Returns covariance, the average of the products of deviations for each data point pair.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
Returns
float

Definition at line 2213 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getCorrelation();
} // function CORREL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::COUNT ( )
static

Definition at line 1024 of file Functions.php.

References flattenArray().

Referenced by GEOMEAN(), LARGE(), PERCENTILE(), SMALL(), and SUBTOTAL().

{
// Return value
$returnValue = 0;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
if ((is_bool($arg)) && (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
$arg = (int) $arg;
}
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::COUNTA ( )
static

Definition at line 1089 of file Functions.php.

References flattenArray().

Referenced by SUBTOTAL().

{
// Return value
$returnValue = 0;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric, boolean or string value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNTA()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::COUNTBLANK ( )
static

Definition at line 1058 of file Functions.php.

References flattenArray().

{
// Return value
$returnValue = 0;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a blank cell?
if ((is_null($arg)) || ((is_string($arg)) && ($arg == ''))) {
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNTBLANK()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::COUNTIF (   $aArgs,
  $condition 
)
static

Definition at line 1121 of file Functions.php.

References PHPExcel_Calculation\_wrapResult(), flattenArray(), and PHPExcel_Calculation\getInstance().

{
// Return value
$returnValue = 0;
$aArgs = self::flattenArray($aArgs);
if (!in_array($condition{0},array('>', '<', '='))) {
if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
$condition = '='.$condition;
}
// Loop through arguments
foreach ($aArgs as $arg) {
if (!is_numeric($arg)) { $arg = PHPExcel_Calculation::_wrapResult(strtoupper($arg)); }
$testCondition = '='.$arg.$condition;
if (PHPExcel_Calculation::getInstance()->_calculateFormulaValue($testCondition)) {
// Is it a value within our criteria
++$returnValue;
}
}
// Return
return $returnValue;
} // function COUNTIF()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::COVAR (   $yValues,
  $xValues 
)
static

COVAR.

Returns covariance, the average of the products of deviations for each data point pair.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
Returns
float

Definition at line 2184 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getCovariance();
} // function COVAR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CRITBINOM (   $trials,
  $probability,
  $alpha 
)
static

CRITBINOM.

Returns the smallest value for which the cumulative binomial distribution is greater than or equal to a criterion value

See http://support.microsoft.com/kb/828117/ for details of the algorithm used

Parameters
float$trialsnumber of Bernoulli trials
float$probabilityprobability of a success on each trial
float$alphacriterion value
Returns
int
 \xrefitem todo 58.

Definition at line 3213 of file Functions.php.

References $t, elseif(), and flattenSingleValue().

{
$trials = floor(self::flattenSingleValue($trials));
$probability = self::flattenSingleValue($probability);
$alpha = self::flattenSingleValue($alpha);
if ((is_numeric($trials)) && (is_numeric($probability)) && (is_numeric($alpha))) {
if ($trials < 0) {
return self::$_errorCodes['num'];
}
if (($probability < 0) || ($probability > 1)) {
return self::$_errorCodes['num'];
}
if (($alpha < 0) || ($alpha > 1)) {
return self::$_errorCodes['num'];
}
if ($alpha <= 0.5) {
$t = sqrt(log(1 / pow($alpha,2)));
$trialsApprox = 0 - ($t + (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t));
} else {
$t = sqrt(log(1 / pow(1 - $alpha,2)));
$trialsApprox = $t - (2.515517 + 0.802853 * $t + 0.010328 * $t * $t) / (1 + 1.432788 * $t + 0.189269 * $t * $t + 0.001308 * $t * $t * $t);
}
$Guess = floor($trials * $probability + $trialsApprox * sqrt($trials * $probability * (1 - $probability)));
if ($Guess < 0) {
$Guess = 0;
} elseif ($Guess > $trials) {
$Guess = $trials;
}
$TotalUnscaledProbability = $UnscaledPGuess = $UnscaledCumPGuess = 0.0;
$EssentiallyZero = 10e-12;
$m = floor($trials * $probability);
++$TotalUnscaledProbability;
if ($m == $Guess) { ++$UnscaledPGuess; }
if ($m <= $Guess) { ++$UnscaledCumPGuess; }
$PreviousValue = 1;
$Done = False;
$k = $m + 1;
while ((!$Done) && ($k <= $trials)) {
$CurrentValue = $PreviousValue * ($trials - $k + 1) * $probability / ($k * (1 - $probability));
$TotalUnscaledProbability += $CurrentValue;
if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; }
if ($k <= $Guess) { $UnscaledCumPGuess += $CurrentValue; }
if ($CurrentValue <= $EssentiallyZero) { $Done = True; }
$PreviousValue = $CurrentValue;
++$k;
}
$PreviousValue = 1;
$Done = False;
$k = $m - 1;
while ((!$Done) && ($k >= 0)) {
$CurrentValue = $PreviousValue * $k + 1 * (1 - $probability) / (($trials - $k) * $probability);
$TotalUnscaledProbability += $CurrentValue;
if ($k == $Guess) { $UnscaledPGuess += $CurrentValue; }
if ($k <= $Guess) { $UnscaledCumPGuess += $CurrentValue; }
if ($CurrentValue <= $EssentiallyZero) { $Done = True; }
$PreviousValue = $CurrentValue;
--$k;
}
$PGuess = $UnscaledPGuess / $TotalUnscaledProbability;
$CumPGuess = $UnscaledCumPGuess / $TotalUnscaledProbability;
// $CumPGuessMinus1 = $CumPGuess - $PGuess;
$CumPGuessMinus1 = $CumPGuess - 1;
while (True) {
if (($CumPGuessMinus1 < $alpha) && ($CumPGuess >= $alpha)) {
return $Guess;
} elseif (($CumPGuessMinus1 < $alpha) && ($CumPGuess < $alpha)) {
$PGuessPlus1 = $PGuess * ($trials - $Guess) * $probability / $Guess / (1 - $probability);
$CumPGuessMinus1 = $CumPGuess;
$CumPGuess = $CumPGuess + $PGuessPlus1;
$PGuess = $PGuessPlus1;
++$Guess;
} elseif (($CumPGuessMinus1 >= $alpha) && ($CumPGuess >= $alpha)) {
$PGuessMinus1 = $PGuess * $Guess * (1 - $probability) / ($trials - $Guess + 1) / $probability;
$CumPGuess = $CumPGuessMinus1;
$CumPGuessMinus1 = $CumPGuessMinus1 - $PGuess;
$PGuess = $PGuessMinus1;
--$Guess;
}
}
}
return self::$_errorCodes['value'];
} // function CRITBINOM()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CUMIPMT (   $rate,
  $nper,
  $pv,
  $start,
  $end,
  $type = 0 
)
static

CUMIPMT.

Returns the cumulative interest paid on a loan between start_period and end_period.

Parameters
float$rateInterest rate per period
int$nperNumber of periods
float$pvPresent Value
intstart The first period in the calculation. Payment periods are numbered beginning with 1.
intend The last period in the calculation.
int$typePayment type: 0 = at the end of each period, 1 = at the beginning of each period
Returns
float

Definition at line 8866 of file Functions.php.

References $start, $type, flattenSingleValue(), and IPMT().

{
$rate = self::flattenSingleValue($rate);
$nper = (int) self::flattenSingleValue($nper);
$start = (int) self::flattenSingleValue($start);
$end = (int) self::flattenSingleValue($end);
$type = (int) self::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
if ($start < 1 || $start > $end) {
return self::$_errorCodes['value'];
}
// Calculate
$interest = 0;
for ($per = $start; $per <= $end; ++$per) {
$interest += self::IPMT($rate, $per, $nper, $pv, 0, $type);
}
return $interest;
} // function CUMIPMT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::CUMPRINC (   $rate,
  $nper,
  $pv,
  $start,
  $end,
  $type = 0 
)
static

CUMPRINC.

Returns the cumulative principal paid on a loan between start_period and end_period.

Parameters
float$rateInterest rate per period
int$nperNumber of periods
float$pvPresent Value
intstart The first period in the calculation. Payment periods are numbered beginning with 1.
intend The last period in the calculation.
int$typePayment type: 0 = at the end of each period, 1 = at the beginning of each period
Returns
float

Definition at line 8941 of file Functions.php.

References $start, $type, flattenSingleValue(), and PPMT().

{
$rate = self::flattenSingleValue($rate);
$nper = (int) self::flattenSingleValue($nper);
$start = (int) self::flattenSingleValue($start);
$end = (int) self::flattenSingleValue($end);
$type = (int) self::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
if ($start < 1 || $start > $end) {
return self::$_errorCodes['value'];
}
// Calculate
$principal = 0;
for ($per = $start; $per <= $end; ++$per) {
$principal += self::PPMT($rate, $per, $nper, $pv, 0, $type);
}
return $principal;
} // function CUMPRINC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DATE (   $year = 0,
  $month = 1,
  $day = 1 
)
static

DATE.

Parameters
long$year
long$month
long$day
Returns
mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, depending on the value of the ReturnDateType flag

Definition at line 5278 of file Functions.php.

References elseif(), PHPExcel_Shared_Date\ExcelToPHP(), PHPExcel_Shared_Date\ExcelToPHPObject(), PHPExcel_Shared_Date\FormattedPHPToExcel(), and PHPExcel_Shared_Date\getExcelCalendar().

{
$year = (integer) self::flattenSingleValue($year);
$month = (integer) self::flattenSingleValue($month);
$day = (integer) self::flattenSingleValue($day);
// Validate parameters
if ($year < ($baseYear-1900)) {
return self::$_errorCodes['num'];
}
if ((($baseYear-1900) != 0) && ($year < $baseYear) && ($year >= 1900)) {
return self::$_errorCodes['num'];
}
if (($year < $baseYear) && ($year >= ($baseYear-1900))) {
$year += 1900;
}
if ($month < 1) {
// Handle year/month adjustment if month < 1
--$month;
$year += ceil($month / 12) - 1;
$month = 13 - abs($month % 12);
} elseif ($month > 12) {
// Handle year/month adjustment if month > 12
$year += floor($month / 12);
$month = ($month % 12);
}
// Re-validate the year parameter after adjustments
if (($year < $baseYear) || ($year >= 10000)) {
return self::$_errorCodes['num'];
}
// Execute function
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day);
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : return (float) $excelDateValue;
break;
case self::RETURNDATE_PHP_NUMERIC : return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);
break;
case self::RETURNDATE_PHP_OBJECT : return PHPExcel_Shared_Date::ExcelToPHPObject($excelDateValue);
break;
}
} // function DATE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DATEDIF (   $startDate = 0,
  $endDate = 0,
  $unit = 'D' 
)
static

DATEDIF.

Parameters
long$startDateExcel date serial value or a standard date string
long$endDateExcel date serial value or a standard date string
string$unit
Returns
long Interval between the dates

Definition at line 5662 of file Functions.php.

References elseif(), PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenSingleValue().

Referenced by YEARFRAC().

{
$startDate = self::flattenSingleValue($startDate);
$endDate = self::flattenSingleValue($endDate);
$unit = strtoupper(self::flattenSingleValue($unit));
if (is_string($startDate = self::_getDateValue($startDate))) {
return self::$_errorCodes['value'];
}
if (is_string($endDate = self::_getDateValue($endDate))) {
return self::$_errorCodes['value'];
}
// Validate parameters
if ($startDate >= $endDate) {
return self::$_errorCodes['num'];
}
// Execute function
$difference = $endDate - $startDate;
$PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate);
$startDays = $PHPStartDateObject->format('j');
$startMonths = $PHPStartDateObject->format('n');
$startYears = $PHPStartDateObject->format('Y');
$PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
$endDays = $PHPEndDateObject->format('j');
$endMonths = $PHPEndDateObject->format('n');
$endYears = $PHPEndDateObject->format('Y');
$retVal = self::$_errorCodes['num'];
switch ($unit) {
case 'D':
$retVal = intval($difference);
break;
case 'M':
$retVal = intval($endMonths - $startMonths) + (intval($endYears - $startYears) * 12);
// We're only interested in full months
if ($endDays < $startDays) {
--$retVal;
}
break;
case 'Y':
$retVal = intval($endYears - $startYears);
// We're only interested in full months
if ($endMonths < $startMonths) {
--$retVal;
} elseif (($endMonths == $startMonths) && ($endDays < $startDays)) {
--$retVal;
}
break;
case 'MD':
if ($endDays < $startDays) {
$retVal = $endDays;
$PHPEndDateObject->modify('-'.$endDays.' days');
$adjustDays = $PHPEndDateObject->format('j');
if ($adjustDays > $startDays) {
$retVal += ($adjustDays - $startDays);
}
} else {
$retVal = $endDays - $startDays;
}
break;
case 'YM':
$retVal = abs(intval($endMonths - $startMonths));
// We're only interested in full months
if ($endDays < $startDays) {
--$retVal;
}
break;
case 'YD':
$retVal = intval($difference);
if ($endYears > $startYears) {
while ($endYears > $startYears) {
$PHPEndDateObject->modify('-1 year');
$endYears = $PHPEndDateObject->format('Y');
}
$retVal = abs($PHPEndDateObject->format('z') - $PHPStartDateObject->format('z'));
}
break;
}
return $retVal;
} // function DATEDIF()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::DATENOW ( )
static

DATENOW.

Returns
mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, depending on the value of the ReturnDateType flag

Definition at line 5572 of file Functions.php.

References PHPExcel_Shared_Date\ExcelToPHP(), PHPExcel_Shared_Date\ExcelToPHPObject(), and PHPExcel_Shared_Date\PHPToExcel().

{
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = False;
$excelDateTime = floor(PHPExcel_Shared_Date::PHPToExcel(time()));
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : $retValue = (float) $excelDateTime;
break;
case self::RETURNDATE_PHP_NUMERIC : $retValue = (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateTime) - 3600;
break;
case self::RETURNDATE_PHP_OBJECT : $retValue = PHPExcel_Shared_Date::ExcelToPHPObject($excelDateTime);
break;
}
date_default_timezone_set($saveTimeZone);
return $retValue;
} // function DATENOW()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DATETIMENOW ( )
static

DATETIMENOW.

Returns
mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, depending on the value of the ReturnDateType flag

Definition at line 5548 of file Functions.php.

References PHPExcel_Shared_Date\PHPToExcel().

{
$saveTimeZone = date_default_timezone_get();
date_default_timezone_set('UTC');
$retValue = False;
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : $retValue = (float) PHPExcel_Shared_Date::PHPToExcel(time());
break;
case self::RETURNDATE_PHP_NUMERIC : $retValue = (integer) time();
break;
case self::RETURNDATE_PHP_OBJECT : $retValue = new DateTime();
break;
}
date_default_timezone_set($saveTimeZone);
return $retValue;
} // function DATETIMENOW()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DATEVALUE (   $dateValue = 1)
static

DATEVALUE.

Parameters
string$dateValue
Returns
mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, depending on the value of the ReturnDateType flag

Definition at line 5410 of file Functions.php.

References $t, PHPExcel_Shared_Date\ExcelToPHP(), and PHPExcel_Shared_Date\FormattedPHPToExcel().

Referenced by _getDateValue().

{
$dateValue = str_replace(array('/','.',' '),array('-','-','-'),self::flattenSingleValue(trim($dateValue,'"')));
$yearFound = false;
$t1 = explode('-',$dateValue);
foreach($t1 as &$t) {
if ((is_numeric($t)) && (($t > 31) && ($t < 100))) {
if ($yearFound) {
return self::$_errorCodes['value'];
} else {
$t += 1900;
$yearFound = true;
}
}
}
unset($t);
$dateValue = implode('-',$t1);
$PHPDateArray = date_parse($dateValue);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
$testVal1 = strtok($dateValue,'- ');
if ($testVal1 !== False) {
$testVal2 = strtok('- ');
if ($testVal2 !== False) {
$testVal3 = strtok('- ');
if ($testVal3 === False) {
$testVal3 = strftime('%Y');
}
} else {
return self::$_errorCodes['value'];
}
} else {
return self::$_errorCodes['value'];
}
$PHPDateArray = date_parse($testVal1.'-'.$testVal2.'-'.$testVal3);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
$PHPDateArray = date_parse($testVal2.'-'.$testVal1.'-'.$testVal3);
if (($PHPDateArray === False) || ($PHPDateArray['error_count'] > 0)) {
return self::$_errorCodes['value'];
}
}
}
if (($PHPDateArray !== False) && ($PHPDateArray['error_count'] == 0)) {
// Execute function
if ($PHPDateArray['year'] == '') { $PHPDateArray['year'] = strftime('%Y'); }
if ($PHPDateArray['month'] == '') { $PHPDateArray['month'] = strftime('%m'); }
if ($PHPDateArray['day'] == '') { $PHPDateArray['day'] = strftime('%d'); }
$excelDateValue = floor(PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']));
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : return (float) $excelDateValue;
break;
case self::RETURNDATE_PHP_NUMERIC : return (integer) PHPExcel_Shared_Date::ExcelToPHP($excelDateValue);
break;
case self::RETURNDATE_PHP_OBJECT : return new DateTime($PHPDateArray['year'].'-'.$PHPDateArray['month'].'-'.$PHPDateArray['day'].' 00:00:00');
break;
}
}
return self::$_errorCodes['value'];
} // function DATEVALUE()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::DAYOFMONTH (   $dateValue = 1)
static

DAYOFMONTH.

Parameters
long$dateValueExcel date serial value or a standard date string
Returns
int Day

Definition at line 5957 of file Functions.php.

References PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenSingleValue().

{
$dateValue = self::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPDateObject = &PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('j');
} // function DAYOFMONTH()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DAYOFWEEK (   $dateValue = 1,
  $style = 1 
)
static

DAYOFWEEK.

Parameters
long$dateValueExcel date serial value or a standard date string
Returns
int Day

Definition at line 5977 of file Functions.php.

References PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenSingleValue().

Referenced by NETWORKDAYS(), and WORKDAY().

{
$dateValue = self::flattenSingleValue($dateValue);
$style = floor(self::flattenSingleValue($style));
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
$DoW = $PHPDateObject->format('w');
$firstDay = 1;
switch ($style) {
case 1: ++$DoW;
break;
case 2: if ($DoW == 0) { $DoW = 7; }
break;
case 3: if ($DoW == 0) { $DoW = 7; }
$firstDay = 0;
--$DoW;
break;
default:
}
if (self::$compatibilityMode == self::COMPATIBILITY_EXCEL) {
// Test for Excel's 1900 leap year, and introduce the error as required
if (($PHPDateObject->format('Y') == 1900) && ($PHPDateObject->format('n') <= 2)) {
--$DoW;
if ($DoW < $firstDay) {
$DoW += 7;
}
}
}
return (int) $DoW;
} // function DAYOFWEEK()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::DAYS360 (   $startDate = 0,
  $endDate = 0,
  $method = false 
)
static

DAYS360.

Parameters
long$startDateExcel date serial value or a standard date string
long$endDateExcel date serial value or a standard date string
boolean$methodUS or European Method
Returns
long PHP date/time serial

Definition at line 5628 of file Functions.php.

References $method, _dateDiff360(), PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenSingleValue().

Referenced by YEARFRAC().

{
$startDate = self::flattenSingleValue($startDate);
$endDate = self::flattenSingleValue($endDate);
if (is_string($startDate = self::_getDateValue($startDate))) {
return self::$_errorCodes['value'];
}
if (is_string($endDate = self::_getDateValue($endDate))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPStartDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($startDate);
$startDay = $PHPStartDateObject->format('j');
$startMonth = $PHPStartDateObject->format('n');
$startYear = $PHPStartDateObject->format('Y');
$PHPEndDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
$endDay = $PHPEndDateObject->format('j');
$endMonth = $PHPEndDateObject->format('n');
$endYear = $PHPEndDateObject->format('Y');
return self::_dateDiff360($startDay, $startMonth, $startYear, $endDay, $endMonth, $endYear, !$method);
} // function DAYS360()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::DB (   $cost,
  $salvage,
  $life,
  $period,
  $month = 12 
)
static

DB.

Returns the depreciation of an asset for a specified period using the fixed-declining balance method. This form of depreciation is used if you want to get a higher depreciation value at the beginning of the depreciation (as opposed to linear depreciation). The depreciation value is reduced with every depreciation period by the depreciation already deducted from the initial cost.

Parameters
floatcost Initial cost of the asset.
floatsalvage Value at the end of the depreciation. (Sometimes called the salvage value of the asset)
intlife Number of periods over which the asset is depreciated. (Sometimes called the useful life of the asset)
intperiod The period for which you want to calculate the depreciation. Period must use the same units as life.
floatmonth Number of months in the first year. If month is omitted, it defaults to 12.
Returns
float

Definition at line 9012 of file Functions.php.

References elseif().

{
$cost = (float) self::flattenSingleValue($cost);
$salvage = (float) self::flattenSingleValue($salvage);
$life = (int) self::flattenSingleValue($life);
$period = (int) self::flattenSingleValue($period);
$month = (int) self::flattenSingleValue($month);
// Validate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($month))) {
if ($cost == 0) {
return 0.0;
} elseif (($cost < 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($month < 1)) {
return self::$_errorCodes['num'];
}
// Set Fixed Depreciation Rate
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
$fixedDepreciationRate = round($fixedDepreciationRate, 3);
// Loop through each period calculating the depreciation
$previousDepreciation = 0;
for ($per = 1; $per <= $period; ++$per) {
if ($per == 1) {
$depreciation = $cost * $fixedDepreciationRate * $month / 12;
} elseif ($per == ($life + 1)) {
$depreciation = ($cost - $previousDepreciation) * $fixedDepreciationRate * (12 - $month) / 12;
} else {
$depreciation = ($cost - $previousDepreciation) * $fixedDepreciationRate;
}
$previousDepreciation += $depreciation;
}
return $depreciation;
}
return self::$_errorCodes['value'];
} // function DB()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DDB (   $cost,
  $salvage,
  $life,
  $period,
  $factor = 2.0 
)
static

DDB.

Returns the depreciation of an asset for a specified period using the double-declining balance method or some other method you specify.

Parameters
floatcost Initial cost of the asset.
floatsalvage Value at the end of the depreciation. (Sometimes called the salvage value of the asset)
intlife Number of periods over which the asset is depreciated. (Sometimes called the useful life of the asset)
intperiod The period for which you want to calculate the depreciation. Period must use the same units as life.
floatfactor The rate at which the balance declines. If factor is omitted, it is assumed to be 2 (the double-declining balance method).
Returns
float

Definition at line 9061 of file Functions.php.

{
$cost = (float) self::flattenSingleValue($cost);
$salvage = (float) self::flattenSingleValue($salvage);
$life = (int) self::flattenSingleValue($life);
$period = (int) self::flattenSingleValue($period);
$factor = (float) self::flattenSingleValue($factor);
// Validate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period)) && (is_numeric($factor))) {
if (($cost <= 0) || (($salvage / $cost) < 0) || ($life <= 0) || ($period < 1) || ($factor <= 0.0) || ($period > $life)) {
return self::$_errorCodes['num'];
}
// Set Fixed Depreciation Rate
$fixedDepreciationRate = 1 - pow(($salvage / $cost), (1 / $life));
$fixedDepreciationRate = round($fixedDepreciationRate, 3);
// Loop through each period calculating the depreciation
$previousDepreciation = 0;
for ($per = 1; $per <= $period; ++$per) {
$depreciation = min( ($cost - $previousDepreciation) * ($factor / $life), ($cost - $salvage - $previousDepreciation) );
$previousDepreciation += $depreciation;
}
return $depreciation;
}
return self::$_errorCodes['value'];
} // function DDB()
static PHPExcel_Calculation_Functions::DECTOBIN (   $x,
  $places = null 
)
static

DECTOBIN.

Return an octal value as binary.

Parameters
string$x
Returns
string

Definition at line 6480 of file Functions.php.

References $out, $x, _nbrConversionFormat(), elseif(), and flattenSingleValue().

{
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return self::$_errorCodes['value'];
}
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return self::$_errorCodes['value'];
}
$x = (string) floor($x);
$r = decbin($x);
if (strlen($r) == 32) {
// Two's Complement
$r = substr($r,-10);
} elseif (strlen($r) > 11) {
return self::$_errorCodes['num'];
}
return self::_nbrConversionFormat($r,$places);
} // function DECTOBIN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DECTOHEX (   $x,
  $places = null 
)
static

DECTOHEX.

Return an octal value as binary.

Parameters
string$x
Returns
string

Definition at line 6550 of file Functions.php.

References $out, $x, _nbrConversionFormat(), and flattenSingleValue().

{
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return self::$_errorCodes['value'];
}
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return self::$_errorCodes['value'];
}
$x = (string) floor($x);
$r = strtoupper(dechex($x));
if (strlen($r) == 8) {
// Two's Complement
$r = 'FF'.$r;
}
return self::_nbrConversionFormat($r,$places);
} // function DECTOHEX()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DECTOOCT (   $x,
  $places = null 
)
static

DECTOOCT.

Return an octal value as binary.

Parameters
string$x
Returns
string

Definition at line 6516 of file Functions.php.

References $out, $x, _nbrConversionFormat(), and flattenSingleValue().

{
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$x = (int) $x;
} else {
return self::$_errorCodes['value'];
}
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[-0123456789.]/',$x,$out)) {
return self::$_errorCodes['value'];
}
$x = (string) floor($x);
$r = decoct($x);
if (strlen($r) == 11) {
// Two's Complement
$r = substr($r,-10);
}
return self::_nbrConversionFormat($r,$places);
} // function DECTOOCT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DELTA (   $a,
  $b = 0 
)
static

DELTA.

Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise.

Parameters
float$a
float$b
Returns
int

Definition at line 8332 of file Functions.php.

References flattenSingleValue().

{
return (int) ($a == $b);
} // function DELTA()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DEVSQ ( )
static

Definition at line 1404 of file Functions.php.

References AVERAGE(), flattenArray(), and NA().

{
// Return value
$returnValue = null;
$aMean = self::AVERAGE(func_get_args());
if (!is_null($aMean)) {
$aArgs = self::flattenArray(func_get_args());
$aCount = -1;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_bool($arg)) && (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
$arg = (int) $arg;
}
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (is_null($returnValue)) {
return self::$_errorCodes['num'];
} else {
return $returnValue;
}
}
return self::NA();
} // function DEVSQ()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DISC (   $settlement,
  $maturity,
  $price,
  $redemption,
  $basis = 0 
)
static

DISC.

Returns the discount rate for a security.

Parameters
mixedsettlement The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.
mixedmaturity The security's maturity date. The maturity date is the date when the security expires.
intprice The security's price per $100 face value.
intredemption the security's redemption value per $100 face value.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9233 of file Functions.php.

References flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$price = (float) self::flattenSingleValue($price);
$redemption = (float) self::flattenSingleValue($redemption);
$basis = (int) self::flattenSingleValue($basis);
// Validate
if ((is_numeric($price)) && (is_numeric($redemption)) && (is_numeric($basis))) {
if (($price <= 0) || ($redemption <= 0)) {
return self::$_errorCodes['num'];
}
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
return ((1 - $price / $redemption) / $daysBetweenSettlementAndMaturity);
}
return self::$_errorCodes['value'];
} // function DISC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DOLLAR (   $value = 0,
  $decimals = 2 
)
static

DOLLAR.

This function converts a number to text using currency format, with the decimals rounded to the specified place. The format used is $#,##0.00_);($#,##0.00)..

Parameters
float$valueThe value to format
int$decimalsThe number of digits to display to the right of the decimal point. If decimals is negative, number is rounded to the left of the decimal point. If you omit decimals, it is assumed to be 2
Returns
string

Definition at line 8539 of file Functions.php.

References flattenSingleValue(), and MROUND().

{
$value = self::flattenSingleValue($value);
$decimals = self::flattenSingleValue($decimals);
// Validate parameters
if (!is_numeric($value) || !is_numeric($decimals)) {
return self::$_errorCodes['num'];
}
$decimals = floor($decimals);
if ($decimals > 0) {
return money_format('%.'.$decimals.'n',$value);
} else {
$round = pow(10,abs($decimals));
if ($value < 0) { $round = 0-$round; }
$value = self::MROUND($value,$round);
// The implementation of money_format used if the standard PHP function is not available can't handle decimal places of 0,
// so we display to 1 dp and chop off that character and the decimal separator using substr
return substr(money_format('%.1n',$value),0,-2);
}
} // function DOLLAR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DOLLARDE (   $fractional_dollar = Null,
  $fraction = 0 
)
static

DOLLARDE.

Converts a dollar price expressed as an integer part and a fraction part into a dollar price expressed as a decimal number. Fractional dollar numbers are sometimes used for security prices.

Parameters
float$fractional_dollarFractional Dollar
int$fractionFraction
Returns
float

Definition at line 8572 of file Functions.php.

References flattenSingleValue().

{
$fractional_dollar = self::flattenSingleValue($fractional_dollar);
$fraction = (int)self::flattenSingleValue($fraction);
// Validate parameters
if (is_null($fractional_dollar) || $fraction < 0) {
return self::$_errorCodes['num'];
}
if ($fraction == 0) {
return self::$_errorCodes['divisionbyzero'];
}
$dollars = floor($fractional_dollar);
$cents = fmod($fractional_dollar,1);
$cents /= $fraction;
$cents *= pow(10,ceil(log10($fraction)));
return $dollars + $cents;
} // function DOLLARDE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DOLLARFR (   $decimal_dollar = Null,
  $fraction = 0 
)
static

DOLLARFR.

Converts a dollar price expressed as a decimal number into a dollar price expressed as a fraction. Fractional dollar numbers are sometimes used for security prices.

Parameters
float$decimal_dollarDecimal Dollar
int$fractionFraction
Returns
float

Definition at line 8602 of file Functions.php.

References flattenSingleValue().

{
$decimal_dollar = self::flattenSingleValue($decimal_dollar);
$fraction = (int)self::flattenSingleValue($fraction);
// Validate parameters
if (is_null($decimal_dollar) || $fraction < 0) {
return self::$_errorCodes['num'];
}
if ($fraction == 0) {
return self::$_errorCodes['divisionbyzero'];
}
$dollars = floor($decimal_dollar);
$cents = fmod($decimal_dollar,1);
$cents *= $fraction;
$cents *= pow(10,-ceil(log10($fraction)));
return $dollars + $cents;
} // function DOLLARFR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::DUMMY ( )
static

Definition at line 221 of file Functions.php.

{
return '#Not Yet Implemented';
} // function DUMMY()
static PHPExcel_Calculation_Functions::EDATE (   $dateValue = 1,
  $adjustmentMonths = 0 
)
static

EDATE.

Returns the serial number that represents the date that is the indicated number of months before or after a specified date (the start_date). Use EDATE to calculate maturity dates or due dates that fall on the same day of the month as the date of issue.

Parameters
long$dateValueExcel date serial value or a standard date string
int$adjustmentMonthsNumber of months to adjust by
Returns
long Excel date serial value

Definition at line 6228 of file Functions.php.

References _adjustDateByMonths(), PHPExcel_Shared_Date\ExcelToPHP(), flattenSingleValue(), and PHPExcel_Shared_Date\PHPToExcel().

{
$dateValue = self::flattenSingleValue($dateValue);
$adjustmentMonths = floor(self::flattenSingleValue($adjustmentMonths));
if (!is_numeric($adjustmentMonths)) {
return self::$_errorCodes['value'];
}
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths);
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
break;
case self::RETURNDATE_PHP_NUMERIC : return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
break;
case self::RETURNDATE_PHP_OBJECT : return $PHPDateObject;
break;
}
} // function EDATE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::EFFECT (   $nominal_rate = 0,
  $npery = 0 
)
static

EFFECT.

Returns the effective interest rate given the nominal rate and the number of compounding payments per year.

Parameters
float$nominal_rateNominal interest rate
int$nperyNumber of compounding payments per year
Returns
float

Definition at line 8631 of file Functions.php.

References flattenSingleValue().

{
$nominal_rate = self::flattenSingleValue($nominal_rate);
$npery = (int)self::flattenSingleValue($npery);
// Validate parameters
if ($nominal_rate <= 0 || $npery < 1) {
return self::$_errorCodes['num'];
}
return pow((1 + $nominal_rate / $npery), $npery) - 1;
} // function EFFECT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::EOMONTH (   $dateValue = 1,
  $adjustmentMonths = 0 
)
static

EOMONTH.

Returns the serial number for the last day of the month that is the indicated number of months before or after start_date. Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month.

Parameters
long$dateValueExcel date serial value or a standard date string
int$adjustmentMonthsNumber of months to adjust by
Returns
long Excel date serial value

Definition at line 6264 of file Functions.php.

References _adjustDateByMonths(), PHPExcel_Shared_Date\ExcelToPHP(), flattenSingleValue(), and PHPExcel_Shared_Date\PHPToExcel().

{
$dateValue = self::flattenSingleValue($dateValue);
$adjustmentMonths = floor(self::flattenSingleValue($adjustmentMonths));
if (!is_numeric($adjustmentMonths)) {
return self::$_errorCodes['value'];
}
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPDateObject = self::_adjustDateByMonths($dateValue,$adjustmentMonths+1);
$adjustDays = (int) $PHPDateObject->format('d');
$adjustDaysString = '-'.$adjustDays.' days';
$PHPDateObject->modify($adjustDaysString);
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : return (float) PHPExcel_Shared_Date::PHPToExcel($PHPDateObject);
break;
case self::RETURNDATE_PHP_NUMERIC : return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::PHPToExcel($PHPDateObject));
break;
case self::RETURNDATE_PHP_OBJECT : return $PHPDateObject;
break;
}
} // function EOMONTH()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ERF (   $lower,
  $upper = null 
)
static

ERF.

Returns the error function integrated between lower_limit and upper_limit

Parameters
float$lowerlower bound for integrating ERF
float$upperupper bound for integrating ERF. If omitted, ERF integrates between zero and lower_limit
Returns
int

Definition at line 8395 of file Functions.php.

References _erfVal(), and flattenSingleValue().

{
$lower = self::flattenSingleValue($lower);
$upper = self::flattenSingleValue($upper);
if (is_numeric($lower)) {
if ($lower < 0) {
return self::$_errorCodes['num'];
}
if (is_null($upper)) {
return self::_erfVal($lower);
}
if (is_numeric($upper)) {
if ($upper < 0) {
return self::$_errorCodes['num'];
}
return self::_erfVal($upper) - self::_erfVal($lower);
}
}
return self::$_errorCodes['value'];
} // function ERF()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ERFC (   $x)
static

ERFC.

Returns the complementary ERF function integrated between x and infinity

Parameters
float$xThe lower bound for integrating ERF
Returns
int

Definition at line 8457 of file Functions.php.

References $x, _erfcVal(), and flattenSingleValue().

{
if (is_numeric($x)) {
if ($x < 0) {
return self::$_errorCodes['num'];
}
return self::_erfcVal($x);
}
return self::$_errorCodes['value'];
} // function ERFC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ERROR_TYPE (   $value = '')
static

ERROR_TYPE.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5106 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$i = 1;
foreach(self::$_errorCodes as $errorCode) {
if ($value == $errorCode) {
return $i;
}
++$i;
}
return self::$_errorCodes['na'];
} // function ERROR_TYPE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::EVEN (   $number)
static

EVEN.

Returns number rounded up to the nearest even integer.

Parameters
float$numberNumber to round
Returns
int Rounded Number

Definition at line 2675 of file Functions.php.

References CEILING(), flattenSingleValue(), and SIGN().

{
$number = self::flattenSingleValue($number);
if (is_numeric($number)) {
$significance = 2 * self::SIGN($number);
return self::CEILING($number,$significance);
}
return self::$_errorCodes['value'];
} // function EVEN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::EXPONDIST (   $value,
  $lambda,
  $cumulative 
)
static

EXPONDIST.

Returns the exponential distribution. Use EXPONDIST to model the time between events, such as how long an automated bank teller takes to deliver cash. For example, you can use EXPONDIST to determine the probability that the process takes at most 1 minute.

Parameters
float$valueValue of the function
float$lambdaThe parameter value
boolean$cumulative
Returns
float

Definition at line 3401 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$lambda = self::flattenSingleValue($lambda);
$cumulative = self::flattenSingleValue($cumulative);
if ((is_numeric($value)) && (is_numeric($lambda))) {
if (($value < 0) || ($lambda < 0)) {
return self::$_errorCodes['num'];
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return 1 - exp(0-$value*$lambda);
} else {
return $lambda * exp(0-$value*$lambda);
}
}
}
return self::$_errorCodes['value'];
} // function EXPONDIST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::FACT (   $factVal)
static

FACT.

Returns the factorial of a number.

Parameters
float$factValFactorial Value
Returns
int Factorial

Definition at line 2552 of file Functions.php.

References flattenSingleValue().

Referenced by BESSELI(), BESSELJ(), COMBIN(), MULTINOMIAL(), and POISSON().

{
$factVal = self::flattenSingleValue($factVal);
if (is_numeric($factVal)) {
if ($factVal < 0) {
return self::$_errorCodes['num'];
}
$factLoop = floor($factVal);
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
if ($factVal > $factLoop) {
return self::$_errorCodes['num'];
}
}
$factorial = 1;
while ($factLoop > 1) {
$factorial *= $factLoop--;
}
return $factorial ;
}
return self::$_errorCodes['value'];
} // function FACT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::FACTDOUBLE (   $factVal)
static

FACTDOUBLE.

Returns the double factorial of a number.

Parameters
float$factValFactorial Value
Returns
int Double Factorial

Definition at line 2583 of file Functions.php.

{
$factLoop = floor(self::flattenSingleValue($factVal));
if (is_numeric($factLoop)) {
if ($factVal < 0) {
return self::$_errorCodes['num'];
}
$factorial = 1;
while ($factLoop > 1) {
$factorial *= $factLoop--;
--$factLoop;
}
return $factorial ;
}
return self::$_errorCodes['value'];
} // function FACTDOUBLE()
static PHPExcel_Calculation_Functions::FISHER (   $value)
static

FISHER.

Returns the Fisher transformation at x. This transformation produces a function that is normally distributed rather than skewed. Use this function to perform hypothesis testing on the correlation coefficient.

Parameters
float$value
Returns
float

Definition at line 3432 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
if (is_numeric($value)) {
if (($value <= -1) || ($value >= 1)) {
return self::$_errorCodes['num'];
}
return 0.5 * log((1+$value)/(1-$value));
}
return self::$_errorCodes['value'];
} // function FISHER()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::FISHERINV (   $value)
static

FISHERINV.

Returns the inverse of the Fisher transformation. Use this transformation when analyzing correlations between ranges or arrays of data. If y = FISHER(x), then FISHERINV(y) = x.

Parameters
float$value
Returns
float

Definition at line 3455 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
if (is_numeric($value)) {
return (exp(2 * $value) - 1) / (exp(2 * $value) + 1);
}
return self::$_errorCodes['value'];
} // function FISHERINV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::FIXEDFORMAT (   $value,
  $decimals = 2,
  $no_commas = false 
)
static

FIXEDFORMAT.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5033 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$decimals = self::flattenSingleValue($decimals);
$no_commas = self::flattenSingleValue($no_commas);
$valueResult = round($value,$decimals);
if ($decimals < 0) { $decimals = 0; }
if (!$no_commas) {
$valueResult = number_format($valueResult,$decimals);
}
return (string) $valueResult;
} // function FIXEDFORMAT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::flattenArray (   $array)
static

Flatten multidemensional array.

Parameters
array$arrayArray to be flattened
Returns
array Flattened array

Definition at line 10359 of file Functions.php.

References elseif(), and flattenSingleValue().

Referenced by PHPExcel_Calculation\_calculateFormulaValue(), AVEDEV(), AVERAGE(), AVERAGEA(), CHOOSE(), CONCATENATE(), CORREL(), COUNT(), COUNTA(), COUNTBLANK(), COUNTIF(), COVAR(), DEVSQ(), FORECAST(), GCD(), GEOMEAN(), GROWTH(), HARMEAN(), IMPRODUCT(), IMSUM(), INTERCEPT(), KURT(), LARGE(), LCM(), LINEST(), LOGEST(), LOGICAL_AND(), LOGICAL_OR(), MATCH(), MAX(), MAXA(), MEDIAN(), MIN(), MINA(), MODE(), MULTINOMIAL(), NETWORKDAYS(), NPV(), PERCENTILE(), PERCENTRANK(), PRODUCT(), QUARTILE(), QUOTIENT(), RANK(), RSQ(), SERIESSUM(), SKEW(), SLOPE(), SMALL(), STDEV(), STDEVA(), STDEVP(), STDEVPA(), STEYX(), SUBTOTAL(), SUM(), SUMIF(), SUMSQ(), SUMX2MY2(), SUMX2PY2(), SUMXMY2(), TREND(), TRIMMEAN(), VARA(), VARFunc(), VARP(), VARPA(), and WORKDAY().

{
if(!is_array ( $array ) ){
$array = array ( $array );
}
$arrayValues = array();
foreach ($array as $value) {
if (is_scalar($value)) {
$arrayValues[] = self::flattenSingleValue($value);
} elseif (is_array($value)) {
$arrayValues = array_merge($arrayValues, self::flattenArray($value));
} else {
$arrayValues[] = $value;
}
}
return $arrayValues;
} // function flattenArray()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::flattenSingleValue (   $value = '')
static

Convert an array with one element to a flat value.

Parameters
mixed$valueArray or flat value
Returns
mixed

Definition at line 10386 of file Functions.php.

Referenced by ACCRINT(), ACCRINTM(), ASCIICODE(), BESSELI(), BESSELJ(), BESSELK(), BESSELY(), BETADIST(), BETAINV(), BINOMDIST(), BINTODEC(), BINTOHEX(), BINTOOCT(), CEILING(), CELL_ADDRESS(), CHARACTER(), CHIDIST(), CHIINV(), CHOOSE(), COMBIN(), COMPLEX(), CONFIDENCE(), CONVERTUOM(), CRITBINOM(), CUMIPMT(), CUMPRINC(), DATEDIF(), DAYOFMONTH(), DAYOFWEEK(), DAYS360(), DECTOBIN(), DECTOHEX(), DECTOOCT(), DELTA(), DISC(), DOLLAR(), DOLLARDE(), DOLLARFR(), EDATE(), EFFECT(), EOMONTH(), ERF(), ERFC(), ERROR_TYPE(), EVEN(), EXPONDIST(), FACT(), FISHER(), FISHERINV(), FIXEDFORMAT(), flattenArray(), FLOOR(), FORECAST(), FV(), GAMMADIST(), GAMMAINV(), GAMMALN(), GESTEP(), HEXTOBIN(), HEXTODEC(), HEXTOOCT(), HOUROFDAY(), IMABS(), IMAGINARY(), IMARGUMENT(), IMCONJUGATE(), IMCOS(), IMDIV(), IMEXP(), IMLN(), IMLOG10(), IMLOG2(), IMPOWER(), IMREAL(), IMSIN(), IMSQRT(), IMSUB(), INTRATE(), INTVALUE(), IPMT(), IS_BLANK(), IS_ERR(), IS_ERROR(), IS_EVEN(), IS_LOGICAL(), IS_NA(), IS_NUMBER(), IS_ODD(), IS_TEXT(), LEFT(), LOG_BASE(), LOGINV(), LOGNORMDIST(), LOWERCASE(), MATCH(), MID(), MINUTEOFHOUR(), MOD(), MONTHOFYEAR(), MROUND(), NEGBINOMDIST(), NOMINAL(), NORMDIST(), NORMINV(), NORMSDIST(), NPER(), OCTTOBIN(), OCTTODEC(), OCTTOHEX(), ODD(), PERCENTRANK(), PERMUT(), PMT(), POISSON(), POWER(), PPMT(), PRICEDISC(), PRICEMAT(), PROPERCASE(), PV(), RAND(), RANK(), RECEIVED(), REPLACE(), RETURNSTRING(), RIGHT(), ROUNDDOWN(), ROUNDUP(), SEARCHINSENSITIVE(), SEARCHSENSITIVE(), SECONDOFMINUTE(), SIGN(), SLN(), SQRTPI(), STANDARDIZE(), STATEMENT_IF(), STRINGLENGTH(), SYD(), TBILLEQ(), TBILLPRICE(), TBILLYIELD(), TDIST(), TEXTFORMAT(), TIME(), TIMEVALUE(), TINV(), TRIMNONPRINTABLE(), TRIMSPACES(), TRUNC(), UPPERCASE(), WEEKOFYEAR(), WEIBULL(), YEAR(), YEARFRAC(), YIELDDISC(), and YIELDMAT().

{
if (is_array($value)) {
$value = self::flattenSingleValue(array_pop($value));
}
return $value;
} // function flattenSingleValue()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::FLOOR (   $number,
  $significance = null 
)
static

FLOOR.

Rounds number down, toward zero, to the nearest multiple of significance.

Parameters
float$numberNumber to round
float$significanceSignificance
Returns
float Rounded Number

Definition at line 2838 of file Functions.php.

References flattenSingleValue().

{
$number = self::flattenSingleValue($number);
$significance = self::flattenSingleValue($significance);
if ((is_null($significance)) && (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC)) {
$significance = $number/abs($number);
}
if ((is_numeric($number)) && (is_numeric($significance))) {
if ((float) $significance == 0.0) {
return self::$_errorCodes['divisionbyzero'];
}
if (self::SIGN($number) == self::SIGN($significance)) {
return floor($number / $significance) * $significance;
} else {
return self::$_errorCodes['num'];
}
}
return self::$_errorCodes['value'];
} // function FLOOR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::FORECAST (   $xValue,
  $yValues,
  $xValues 
)
static

FORECAST.

Calculates, or predicts, a future value by using existing values. The predicted value is a y-value for a given x-value.

Parameters
floatValue of X for which we want to find Y
arrayof mixed Data Series Y
arrayof mixed Data Series X
Returns
float

Definition at line 2347 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), flattenSingleValue(), and trendClass\TREND_LINEAR.

{
$xValue = self::flattenSingleValue($xValue);
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
if (!is_numeric($xValue)) {
return self::$_errorCodes['value'];
}
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getValueOfYForX($xValue);
} // function FORECAST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::FV (   $rate = 0,
  $nper = 0,
  $pmt = 0,
  $pv = 0,
  $type = 0 
)
static

FV.

Returns the Future Value of a cash flow with constant payments and interest rate (annuities).

Parameters
float$rateInterest rate per period
int$nperNumber of periods
float$pmtPeriodic payment (annuity)
float$pvPresent Value
int$typePayment type: 0 = at the end of each period, 1 = at the beginning of each period
Returns
float

Definition at line 8712 of file Functions.php.

References $type, and flattenSingleValue().

{
$rate = self::flattenSingleValue($rate);
$nper = self::flattenSingleValue($nper);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
// Calculate
if (!is_null($rate) && $rate != 0) {
return -$pv * pow(1 + $rate, $nper) - $pmt * (1 + $rate * $type) * (pow(1 + $rate, $nper) - 1) / $rate;
} else {
return -$pv - $pmt * $nper;
}
} // function FV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::GAMMADIST (   $value,
  $a,
  $b,
  $cumulative 
)
static

GAMMADIST.

Returns the gamma distribution.

Parameters
float$valueValue at which you want to evaluate the distribution
float$aParameter to the distribution
float$bParameter to the distribution
boolean$cumulative
Returns
float

Definition at line 3941 of file Functions.php.

References _gamma(), _incompleteGamma(), and flattenSingleValue().

Referenced by GAMMAINV().

{
$value = self::flattenSingleValue($value);
if ((is_numeric($value)) && (is_numeric($a)) && (is_numeric($b))) {
if (($value < 0) || ($a <= 0) || ($b <= 0)) {
return self::$_errorCodes['num'];
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return self::_incompleteGamma($a,$value / $b) / self::_gamma($a);
} else {
return (1 / (pow($b,$a) * self::_gamma($a))) * pow($value,$a-1) * exp(0-($value / $b));
}
}
}
return self::$_errorCodes['value'];
} // function GAMMADIST()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::GAMMAINV (   $probability,
  $alpha,
  $beta 
)
static

GAMMAINV.

Returns the inverse of the beta distribution.

Parameters
float$probabilityProbability at which you want to evaluate the distribution
float$alphaParameter to the distribution
float$betaParameter to the distribution
boolean$cumulative
Returns
float

Definition at line 3974 of file Functions.php.

References $error, $result, $x, elseif(), flattenSingleValue(), GAMMADIST(), MAX_ITERATIONS, and PRECISION.

{
$probability = self::flattenSingleValue($probability);
$alpha = self::flattenSingleValue($alpha);
$beta = self::flattenSingleValue($beta);
// $rMin = self::flattenSingleValue($rMin);
// $rMax = self::flattenSingleValue($rMax);
if ((is_numeric($probability)) && (is_numeric($alpha)) && (is_numeric($beta))) {
if (($alpha <= 0) || ($beta <= 0) || ($probability <= 0) || ($probability > 1)) {
return self::$_errorCodes['num'];
}
$xLo = 0;
$xHi = 100;
$maxIteration = 100;
$x = $xNew = 1;
$dx = 1;
$i = 0;
while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
// Apply Newton-Raphson step
$result = self::GAMMADIST($x, $alpha, $beta, True);
$error = $result - $probability;
if ($error == 0.0) {
$dx = 0;
} elseif ($error < 0.0) {
$xLo = $x;
} else {
$xHi = $x;
}
// Avoid division by zero
if ($result != 0.0) {
$dx = $error / $result;
$xNew = $x - $dx;
}
// If the NR fails to converge (which for example may be the
// case if the initial guess is too rough) we apply a bisection
// step to determine a more narrow interval around the root.
if (($xNew < $xLo) || ($xNew > $xHi) || ($result == 0.0)) {
$xNew = ($xLo + $xHi) / 2;
$dx = $xNew - $x;
}
$x = $xNew;
}
if ($i == MAX_ITERATIONS) {
return self::$_errorCodes['na'];
}
return round($x,12);
}
return self::$_errorCodes['value'];
} // function GAMMAINV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::GAMMALN (   $value)
static

GAMMALN.

Returns the natural logarithm of the gamma function.

Parameters
float$value
Returns
float

Definition at line 4035 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
if (is_numeric($value)) {
if ($value <= 0) {
return self::$_errorCodes['num'];
}
return log(self::_gamma($value));
}
return self::$_errorCodes['value'];
} // function GAMMALN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::GCD ( )
static

GCD.

Returns the greatest common divisor of a series of numbers

Parameters
$arrayValues to calculate the Greatest Common Divisor
Returns
int Greatest Common Divisor

Definition at line 3056 of file Functions.php.

References $key, _factors(), elseif(), and flattenArray().

Referenced by PHPExcel_Style_NumberFormat\toFormattedString().

{
$aArgs = self::flattenArray(func_get_args());
$returnValue = 1;
$allPoweredFactors = array();
foreach($aArgs as $value) {
if ($value == 0) {
break;
}
$myFactors = self::_factors($value);
$myCountedFactors = array_count_values($myFactors);
$allValuesFactors[] = $myCountedFactors;
}
$allValuesCount = count($allValuesFactors);
$mergedArray = $allValuesFactors[0];
for ($i=1;$i < $allValuesCount; ++$i) {
$mergedArray = array_intersect_key($mergedArray,$allValuesFactors[$i]);
}
$mergedArrayValues = count($mergedArray);
if ($mergedArrayValues == 0) {
return $returnValue;
} elseif ($mergedArrayValues > 1) {
foreach($mergedArray as $mergedKey => $mergedValue) {
foreach($allValuesFactors as $highestPowerTest) {
foreach($highestPowerTest as $testKey => $testValue) {
if (($testKey == $mergedKey) && ($testValue < $mergedValue)) {
$mergedArray[$mergedKey] = $testValue;
$mergedValue = $testValue;
}
}
}
}
$returnValue = 1;
foreach($mergedArray as $key => $value) {
$returnValue *= pow($key,$value);
}
return $returnValue;
} else {
$keys = array_keys($mergedArray);
$key = $keys[0];
$value = $mergedArray[$key];
foreach($allValuesFactors as $testValue) {
foreach($testValue as $mergedKey => $mergedValue) {
if (($mergedKey == $key) && ($mergedValue < $value)) {
$value = $mergedValue;
}
}
}
return pow($key,$value);
}
} // function GCD()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::GEOMEAN ( )
static

Definition at line 1499 of file Functions.php.

References COUNT(), flattenArray(), and PRODUCT().

{
$aMean = self::PRODUCT(func_get_args());
if (is_numeric($aMean) && ($aMean > 0)) {
$aArgs = self::flattenArray(func_get_args());
$aCount = self::COUNT($aArgs) ;
if (self::MIN($aArgs) > 0) {
return pow($aMean, (1 / $aCount));
}
}
return self::$_errorCodes['num'];
} // GEOMEAN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::GESTEP (   $number,
  $step = 0 
)
static

GESTEP.

Returns 1 if number = step; returns 0 (zero) otherwise

Parameters
float$number
float$step
Returns
int

Definition at line 8349 of file Functions.php.

References flattenSingleValue().

{
$number = self::flattenSingleValue($number);
$step = self::flattenSingleValue($step);
return (int) ($number >= $step);
} // function GESTEP()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::getCompatibilityMode ( )
static

Definition at line 170 of file Functions.php.

References $compatibilityMode.

{
} // function getCompatibilityMode()
static PHPExcel_Calculation_Functions::getConversionGroups ( )
static

getConversionGroups

Returns
array

Definition at line 7942 of file Functions.php.

{
$conversionGroups = array();
foreach(self::$_conversionUnits as $conversionUnit) {
$conversionGroups[] = $conversionUnit['Group'];
}
return array_merge(array_unique($conversionGroups));
} // function getConversionGroups()
static PHPExcel_Calculation_Functions::getConversionGroupUnitDetails (   $group = NULL)
static

getConversionGroupUnitDetails

Returns
array

Definition at line 7972 of file Functions.php.

{
$conversionGroups = array();
foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = array( 'unit' => $conversionUnit,
'description' => $conversionGroup['Unit Name']
);
}
}
return $conversionGroups;
} // function getConversionGroupUnitDetails()
static PHPExcel_Calculation_Functions::getConversionGroupUnits (   $group = NULL)
static

getConversionGroupUnits

Returns
array

Definition at line 7956 of file Functions.php.

{
$conversionGroups = array();
foreach(self::$_conversionUnits as $conversionUnit => $conversionGroup) {
if ((is_null($group)) || ($conversionGroup['Group'] == $group)) {
$conversionGroups[$conversionGroup['Group']][] = $conversionUnit;
}
}
return $conversionGroups;
} // function getConversionGroupUnits()
static PHPExcel_Calculation_Functions::getConversionMultipliers ( )
static

getConversionGroups

Returns
array

Definition at line 7990 of file Functions.php.

References $_conversionMultipliers.

{
} // function getConversionGroups()
static PHPExcel_Calculation_Functions::getReturnDateType ( )
static

Definition at line 209 of file Functions.php.

References $ReturnDateType.

Referenced by _getDateValue(), _getTimeValue(), PHPExcel_Writer_Excel5\save(), and PHPExcel_Writer_Excel2007\save().

{
} // function getReturnDateType()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::GROWTH (   $yValues,
  $xValues = array(),
  $newValues = array(),
  $const = True 
)
static

GROWTH.

Returns values along a predicted emponential trend

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
arrayof mixed Values of X for which we want to find Y
booleanA logical value specifying whether to force the intersect to equal 0.
Returns
array of float

Definition at line 2414 of file Functions.php.

References trendClass\calculate(), flattenArray(), and trendClass\TREND_EXPONENTIAL.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$newValues = self::flattenArray($newValues);
$const = (boolean) self::flattenSingleValue($const);
$bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const);
if (count($newValues) == 0) {
$newValues = $bestFitExponential->getXValues();
}
$returnArray = array();
foreach($newValues as $xValue) {
$returnArray[0][] = $bestFitExponential->getValueOfYForX($xValue);
}
return $returnArray;
} // function GROWTH()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::HARMEAN ( )
static

Definition at line 1526 of file Functions.php.

References flattenArray(), and NA().

{
// Return value
$returnValue = self::NA();
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
if (self::MIN($aArgs) < 0) {
return self::$_errorCodes['num'];
}
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if ($arg <= 0) {
return self::$_errorCodes['num'];
}
if (is_null($returnValue)) {
$returnValue = (1 / $arg);
} else {
$returnValue += (1 / $arg);
}
++$aCount;
}
}
// Return
if ($aCount > 0) {
return 1 / ($returnValue / $aCount);
} else {
return $returnValue;
}
} // function HARMEAN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::HEXTOBIN (   $x,
  $places = null 
)
static

HEXTOBIN.

Return a hex value as binary.

Parameters
string$x
Returns
string

Definition at line 6584 of file Functions.php.

References $out, $x, and flattenSingleValue().

{
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
return self::$_errorCodes['value'];
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return self::$_errorCodes['num'];
}
$binVal = decbin(hexdec($x));
return substr(self::_nbrConversionFormat($binVal,$places),-10);
} // function HEXTOBIN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::HEXTODEC (   $x)
static

HEXTODEC.

Return a hex value as octal.

Parameters
string$x
Returns
string

Definition at line 6634 of file Functions.php.

References $out, $x, and flattenSingleValue().

{
if (is_bool($x)) {
return self::$_errorCodes['value'];
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return self::$_errorCodes['num'];
}
return hexdec($x);
} // function HEXTODEC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::HEXTOOCT (   $x,
  $places = null 
)
static

HEXTOOCT.

Return a hex value as octal.

Parameters
string$x
Returns
string

Definition at line 6609 of file Functions.php.

References $out, $x, _nbrConversionFormat(), and flattenSingleValue().

{
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
return self::$_errorCodes['value'];
}
$x = (string) $x;
if (strlen($x) > preg_match_all('/[0123456789ABCDEF]/',strtoupper($x),$out)) {
return self::$_errorCodes['num'];
}
$octVal = decoct(hexdec($x));
return self::_nbrConversionFormat($octVal,$places);
} // function HEXTOOCT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::HOUROFDAY (   $timeValue = 0)
static

HOUROFDAY.

Parameters
mixed$timeValueExcel time serial value or a standard time string
Returns
int Hour

Definition at line 6096 of file Functions.php.

References _getTimeValue(), elseif(), PHPExcel_Shared_Date\ExcelToPHP(), and flattenSingleValue().

{
$timeValue = self::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) {
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) {
return self::$_errorCodes['value'];
}
}
$timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) {
return self::$_errorCodes['value'];
}
}
// Execute function
if (is_real($timeValue)) {
if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) {
return self::$_errorCodes['num'];
}
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
}
return (int) date('G',$timeValue);
} // function HOUROFDAY()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::HYPGEOMDIST (   $sampleSuccesses,
  $sampleNumber,
  $populationSuccesses,
  $populationNumber 
)
static

HYPGEOMDIST.

Returns the hypergeometric distribution. HYPGEOMDIST returns the probability of a given number of sample successes, given the sample size, population successes, and population size.

Parameters
float$sampleSuccessesNumber of successes in the sample
float$sampleNumberSize of the sample
float$populationSuccessesNumber of successes in the population
float$populationNumberPopulation size
Returns
float

Definition at line 4426 of file Functions.php.

References COMBIN().

{
$sampleSuccesses = floor(self::flattenSingleValue($sampleSuccesses));
$sampleNumber = floor(self::flattenSingleValue($sampleNumber));
$populationSuccesses = floor(self::flattenSingleValue($populationSuccesses));
$populationNumber = floor(self::flattenSingleValue($populationNumber));
if ((is_numeric($sampleSuccesses)) && (is_numeric($sampleNumber)) && (is_numeric($populationSuccesses)) && (is_numeric($populationNumber))) {
if (($sampleSuccesses < 0) || ($sampleSuccesses > $sampleNumber) || ($sampleSuccesses > $populationSuccesses)) {
return self::$_errorCodes['num'];
}
if (($sampleNumber <= 0) || ($sampleNumber > $populationNumber)) {
return self::$_errorCodes['num'];
}
if (($populationSuccesses <= 0) || ($populationSuccesses > $populationNumber)) {
return self::$_errorCodes['num'];
}
return self::COMBIN($populationSuccesses,$sampleSuccesses) *
self::COMBIN($populationNumber - $populationSuccesses,$sampleNumber - $sampleSuccesses) /
self::COMBIN($populationNumber,$sampleNumber);
}
return self::$_errorCodes['value'];
} // function HYPGEOMDIST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMABS (   $complexNumber)
static

IMABS.

Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
real

Definition at line 6864 of file Functions.php.

References _parseComplex(), and flattenSingleValue().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
return sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
} // function IMABS()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMAGINARY (   $complexNumber)
static

IMAGINARY.

Returns the imaginary coefficient of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
real

Definition at line 6826 of file Functions.php.

References _parseComplex(), and flattenSingleValue().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
return $parsedComplex['imaginary'];
} // function IMAGINARY()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMARGUMENT (   $complexNumber)
static

IMARGUMENT.

Returns the argument theta of a complex number, i.e. the angle in radians from the real axis to the representation of the number in polar coordinates.

Parameters
string$complexNumber
Returns
string

Definition at line 6883 of file Functions.php.

References _parseComplex(), elseif(), and flattenSingleValue().

Referenced by IMLN(), IMPOWER(), and IMSQRT().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['real'] == 0.0) {
if ($parsedComplex['imaginary'] == 0.0) {
return 0.0;
} elseif($parsedComplex['imaginary'] < 0.0) {
return pi() / -2;
} else {
return pi() / 2;
}
} elseif ($parsedComplex['real'] > 0.0) {
return atan($parsedComplex['imaginary'] / $parsedComplex['real']);
} elseif ($parsedComplex['imaginary'] < 0.0) {
return 0 - (pi() - atan(abs($parsedComplex['imaginary']) / abs($parsedComplex['real'])));
} else {
return pi() - atan($parsedComplex['imaginary'] / abs($parsedComplex['real']));
}
} // function IMARGUMENT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::IMCONJUGATE (   $complexNumber)
static

IMCONJUGATE.

Returns the complex conjugate of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 6917 of file Functions.php.

References _cleanComplex(), _parseComplex(), and flattenSingleValue().

Referenced by IMCOS().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['imaginary'] == 0.0) {
return $parsedComplex['real'];
} else {
return self::_cleanComplex(self::COMPLEX($parsedComplex['real'], 0 - $parsedComplex['imaginary'], $parsedComplex['suffix']));
}
} // function IMCONJUGATE()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::IMCOS (   $complexNumber)
static

IMCOS.

Returns the cosine of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 6942 of file Functions.php.

References _parseComplex(), flattenSingleValue(), and IMCONJUGATE().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['imaginary'] == 0.0) {
return cos($parsedComplex['real']);
} else {
return self::IMCONJUGATE(self::COMPLEX(cos($parsedComplex['real']) * cosh($parsedComplex['imaginary']),sin($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']));
}
} // function IMCOS()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMDIV (   $complexDividend,
  $complexDivisor 
)
static

IMDIV.

Returns the quotient of two complex numbers in x + yi or x + yj text format.

Parameters
string$complexDividend
string$complexDivisor
Returns
real

Definition at line 7169 of file Functions.php.

References _cleanComplex(), _parseComplex(), elseif(), and flattenSingleValue().

{
$complexDividend = self::flattenSingleValue($complexDividend);
$complexDivisor = self::flattenSingleValue($complexDivisor);
$parsedComplexDividend = self::_parseComplex($complexDividend);
if (!is_array($parsedComplexDividend)) {
return $parsedComplexDividend;
}
$parsedComplexDivisor = self::_parseComplex($complexDivisor);
if (!is_array($parsedComplexDivisor)) {
return $parsedComplexDividend;
}
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] != '') &&
($parsedComplexDividend['suffix'] != $parsedComplexDivisor['suffix'])) {
return self::$_errorCodes['num'];
}
if (($parsedComplexDividend['suffix'] != '') && ($parsedComplexDivisor['suffix'] == '')) {
$parsedComplexDivisor['suffix'] = $parsedComplexDividend['suffix'];
}
$d1 = ($parsedComplexDividend['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['imaginary']);
$d2 = ($parsedComplexDividend['imaginary'] * $parsedComplexDivisor['real']) - ($parsedComplexDividend['real'] * $parsedComplexDivisor['imaginary']);
$d3 = ($parsedComplexDivisor['real'] * $parsedComplexDivisor['real']) + ($parsedComplexDivisor['imaginary'] * $parsedComplexDivisor['imaginary']);
$r = $d1/$d3;
$i = $d2/$d3;
if ($i > 0.0) {
return self::_cleanComplex($r.'+'.$i.$parsedComplexDivisor['suffix']);
} elseif ($i < 0.0) {
return self::_cleanComplex($r.$i.$parsedComplexDivisor['suffix']);
} else {
return $r;
}
} // function IMDIV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMEXP (   $complexNumber)
static

IMEXP.

Returns the exponential of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 7102 of file Functions.php.

References _parseComplex(), COMPLEX(), and flattenSingleValue().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return '1';
}
$e = exp($parsedComplex['real']);
$eX = $e * cos($parsedComplex['imaginary']);
$eY = $e * sin($parsedComplex['imaginary']);
if ($parsedComplex['suffix'] == '') {
return self::COMPLEX($eX,$eY);
} else {
return self::COMPLEX($eX,$eY,$parsedComplex['suffix']);
}
} // function IMEXP()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMLN (   $complexNumber)
static

IMLN.

Returns the natural logarithm of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 7019 of file Functions.php.

References $t, _parseComplex(), COMPLEX(), flattenSingleValue(), and IMARGUMENT().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return self::$_errorCodes['num'];
}
$logR = log(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
$t = self::IMARGUMENT($complexNumber);
if ($parsedComplex['suffix'] == '') {
return self::COMPLEX($logR,$t);
} else {
return self::COMPLEX($logR,$t,$parsedComplex['suffix']);
}
} // function IMLN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMLOG10 (   $complexNumber)
static

IMLOG10.

Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 7050 of file Functions.php.

References _parseComplex(), elseif(), EULER, flattenSingleValue(), and IMPRODUCT().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return self::$_errorCodes['num'];
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return log10($parsedComplex['real']);
}
return self::IMPRODUCT(log10(EULER),self::IMLN($complexNumber));
} // function IMLOG10()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMLOG2 (   $complexNumber)
static

IMLOG2.

Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 7076 of file Functions.php.

References _parseComplex(), elseif(), EULER, flattenSingleValue(), and IMPRODUCT().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if (($parsedComplex['real'] == 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return self::$_errorCodes['num'];
} elseif (($parsedComplex['real'] > 0.0) && ($parsedComplex['imaginary'] == 0.0)) {
return log($parsedComplex['real'],2);
}
return self::IMPRODUCT(log(EULER,2),self::IMLN($complexNumber));
} // function IMLOG2()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMPOWER (   $complexNumber,
  $realNumber 
)
static

IMPOWER.

Returns a complex number in x + yi or x + yj text format raised to a power.

Parameters
string$complexNumber
Returns
string

Definition at line 7134 of file Functions.php.

References _parseComplex(), COMPLEX(), elseif(), flattenSingleValue(), and IMARGUMENT().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$realNumber = self::flattenSingleValue($realNumber);
if (!is_numeric($realNumber)) {
return self::$_errorCodes['value'];
}
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
$r = sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary']));
$rPower = pow($r,$realNumber);
$theta = self::IMARGUMENT($complexNumber) * $realNumber;
if ($theta == 0) {
return 1;
} elseif ($parsedComplex['imaginary'] == 0.0) {
return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']);
} else {
return self::COMPLEX($rPower * cos($theta),$rPower * sin($theta),$parsedComplex['suffix']);
}
} // function IMPOWER()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMPRODUCT ( )
static

IMPRODUCT.

Returns the product of two or more complex numbers in x + yi or x + yj text format.

Parameters
arrayof mixed Data Series
Returns
real

Definition at line 7289 of file Functions.php.

References _parseComplex(), COMPLEX(), elseif(), and flattenArray().

Referenced by IMLOG10(), and IMLOG2().

{
// Return value
$returnValue = self::_parseComplex('1');
$activeSuffix = '';
// Loop through the arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
$workValue = $returnValue;
if (($parsedComplex['suffix'] != '') && ($activeSuffix == '')) {
$activeSuffix = $parsedComplex['suffix'];
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
return self::$_errorCodes['num'];
}
$returnValue['real'] = ($workValue['real'] * $parsedComplex['real']) - ($workValue['imaginary'] * $parsedComplex['imaginary']);
$returnValue['imaginary'] = ($workValue['real'] * $parsedComplex['imaginary']) + ($workValue['imaginary'] * $parsedComplex['real']);
}
if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
} // function IMPRODUCT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::IMREAL (   $complexNumber)
static

IMREAL.

Returns the real coefficient of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
real

Definition at line 6845 of file Functions.php.

References _parseComplex(), and flattenSingleValue().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
return $parsedComplex['real'];
} // function IMREAL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMSIN (   $complexNumber)
static

IMSIN.

Returns the sine of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 6966 of file Functions.php.

References _parseComplex(), COMPLEX(), and flattenSingleValue().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($parsedComplex['imaginary'] == 0.0) {
return sin($parsedComplex['real']);
} else {
return self::COMPLEX(sin($parsedComplex['real']) * cosh($parsedComplex['imaginary']),cos($parsedComplex['real']) * sinh($parsedComplex['imaginary']),$parsedComplex['suffix']);
}
} // function IMSIN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMSQRT (   $complexNumber)
static

IMSQRT.

Returns the square root of a complex number in x + yi or x + yj text format.

Parameters
string$complexNumber
Returns
string

Definition at line 6990 of file Functions.php.

References _parseComplex(), COMPLEX(), flattenSingleValue(), and IMARGUMENT().

{
$complexNumber = self::flattenSingleValue($complexNumber);
$parsedComplex = self::_parseComplex($complexNumber);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
$theta = self::IMARGUMENT($complexNumber);
$d1 = cos($theta / 2);
$d2 = sin($theta / 2);
$r = sqrt(sqrt(($parsedComplex['real'] * $parsedComplex['real']) + ($parsedComplex['imaginary'] * $parsedComplex['imaginary'])));
if ($parsedComplex['suffix'] == '') {
return self::COMPLEX($d1 * $r,$d2 * $r);
} else {
return self::COMPLEX($d1 * $r,$d2 * $r,$parsedComplex['suffix']);
}
} // function IMSQRT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMSUB (   $complexNumber1,
  $complexNumber2 
)
static

IMSUB.

Returns the difference of two complex numbers in x + yi or x + yj text format.

Parameters
string$complexNumber1
string$complexNumber2
Returns
real

Definition at line 7217 of file Functions.php.

References _parseComplex(), COMPLEX(), elseif(), and flattenSingleValue().

{
$complexNumber1 = self::flattenSingleValue($complexNumber1);
$complexNumber2 = self::flattenSingleValue($complexNumber2);
$parsedComplex1 = self::_parseComplex($complexNumber1);
if (!is_array($parsedComplex1)) {
return $parsedComplex1;
}
$parsedComplex2 = self::_parseComplex($complexNumber2);
if (!is_array($parsedComplex2)) {
return $parsedComplex2;
}
if ((($parsedComplex1['suffix'] != '') && ($parsedComplex2['suffix'] != '')) &&
($parsedComplex1['suffix'] != $parsedComplex2['suffix'])) {
return self::$_errorCodes['num'];
} elseif (($parsedComplex1['suffix'] == '') && ($parsedComplex2['suffix'] != '')) {
$parsedComplex1['suffix'] = $parsedComplex2['suffix'];
}
$d1 = $parsedComplex1['real'] - $parsedComplex2['real'];
$d2 = $parsedComplex1['imaginary'] - $parsedComplex2['imaginary'];
return self::COMPLEX($d1,$d2,$parsedComplex1['suffix']);
} // function IMSUB()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IMSUM ( )
static

IMSUM.

Returns the sum of two or more complex numbers in x + yi or x + yj text format.

Parameters
arrayof mixed Data Series
Returns
real

Definition at line 7253 of file Functions.php.

References _parseComplex(), COMPLEX(), elseif(), and flattenArray().

{
// Return value
$returnValue = self::_parseComplex('0');
$activeSuffix = '';
// Loop through the arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
$parsedComplex = self::_parseComplex($arg);
if (!is_array($parsedComplex)) {
return $parsedComplex;
}
if ($activeSuffix == '') {
$activeSuffix = $parsedComplex['suffix'];
} elseif (($parsedComplex['suffix'] != '') && ($activeSuffix != $parsedComplex['suffix'])) {
return self::$_errorCodes['value'];
}
$returnValue['real'] += $parsedComplex['real'];
$returnValue['imaginary'] += $parsedComplex['imaginary'];
}
if ($returnValue['imaginary'] == 0.0) { $activeSuffix = ''; }
return self::COMPLEX($returnValue['real'],$returnValue['imaginary'],$activeSuffix);
} // function IMSUM()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::INDEX (   $arrayValues,
  $rowNum = 0,
  $columnNum = 0 
)
static

Uses an index to choose a value from a reference or array implemented: Return the value of a specified cell or array of cells Array form not implemented: Return a reference to specified cells Reference form.

Parameters
range_arraya range of cells or an array constant
row_numselects the row in array from which to return a value. If row_num is omitted, column_num is required.
column_numselects the column in array from which to return a value. If column_num is omitted, row_num is required.

Definition at line 9960 of file Functions.php.

References elseif().

{
if (($rowNum < 0) || ($columnNum < 0)) {
return self::$_errorCodes['value'];
}
$rowKeys = array_keys($arrayValues);
$columnKeys = array_keys($arrayValues[$rowKeys[0]]);
if ($columnNum > count($columnKeys)) {
return self::$_errorCodes['value'];
} elseif ($columnNum == 0) {
if ($rowNum == 0) {
return $arrayValues;
}
$rowNum = $rowKeys[--$rowNum];
$returnArray = array();
foreach($arrayValues as $arrayColumn) {
$returnArray[] = $arrayColumn[$rowNum];
}
return $returnArray;
}
$columnNum = $columnKeys[--$columnNum];
if ($rowNum > count($rowKeys)) {
return self::$_errorCodes['value'];
} elseif ($rowNum == 0) {
return $arrayValues[$columnNum];
}
$rowNum = $rowKeys[--$rowNum];
return $arrayValues[$rowNum][$columnNum];
} // function INDEX()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::INTERCEPT (   $yValues,
  $xValues 
)
static

INTERCEPT.

Calculates the point at which a line will intersect the y-axis by using existing x-values and y-values.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
Returns
float

Definition at line 2068 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getIntersect();
} // function INTERCEPT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::INTRATE (   $settlement,
  $maturity,
  $investment,
  $redemption,
  $basis = 0 
)
static

INTRATE.

Returns the interest rate for a fully invested security.

Parameters
mixedsettlement The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.
mixedmaturity The security's maturity date. The maturity date is the date when the security expires.
intinvestment The amount invested in the security.
intredemption The amount to be received at maturity.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9420 of file Functions.php.

References flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$investment = (float) self::flattenSingleValue($investment);
$redemption = (float) self::flattenSingleValue($redemption);
$basis = (int) self::flattenSingleValue($basis);
// Validate
if ((is_numeric($investment)) && (is_numeric($redemption)) && (is_numeric($basis))) {
if (($investment <= 0) || ($redemption <= 0)) {
return self::$_errorCodes['num'];
}
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
return (($redemption / $investment) - 1) / ($daysBetweenSettlementAndMaturity);
}
return self::$_errorCodes['value'];
} // function INTRATE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::INTVALUE (   $number)
static

INTVALUE.

Casts a floating point value to an integer

Parameters
float$numberNumber to cast to an integer
Returns
integer Integer value

Definition at line 2720 of file Functions.php.

References flattenSingleValue().

{
$number = self::flattenSingleValue($number);
if (is_numeric($number)) {
return (int) floor($number);
}
return self::$_errorCodes['value'];
} // function INTVALUE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IPMT (   $rate,
  $per,
  $nper,
  $pv,
  $fv = 0,
  $type = 0 
)
static

IPMT.

Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.

Parameters
float$rateInterest rate per period
int$perPeriod for which we want to find the interest
int$nperNumber of periods
float$pvPresent Value
float$fvFuture Value
int$typePayment type: 0 = at the end of each period, 1 = at the beginning of each period
Returns
float

Definition at line 8830 of file Functions.php.

References $type, _interestAndPrincipal(), and flattenSingleValue().

Referenced by CUMIPMT().

{
$rate = self::flattenSingleValue($rate);
$per = (int) self::flattenSingleValue($per);
$nper = (int) self::flattenSingleValue($nper);
$type = (int) self::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
if ($per <= 0 || $per > $nper) {
return self::$_errorCodes['value'];
}
// Calculate
$interestAndPrincipal = self::_interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
return $interestAndPrincipal[0];
} // function IPMT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::IS_BLANK (   $value = null)
static

IS_BLANK.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5126 of file Functions.php.

References flattenSingleValue().

{
if (!is_null($value)) {
$value = self::flattenSingleValue($value);
}
return is_null($value);
} // function IS_BLANK()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IS_ERR (   $value = '')
static

IS_ERR.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5141 of file Functions.php.

References flattenSingleValue(), IS_ERROR(), and IS_NA().

{
$value = self::flattenSingleValue($value);
return self::IS_ERROR($value) && (!self::IS_NA($value));
} // function IS_ERR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IS_ERROR (   $value = '')
static

IS_ERROR.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5154 of file Functions.php.

References flattenSingleValue().

Referenced by IS_ERR().

{
$value = self::flattenSingleValue($value);
return in_array($value, array_values(self::$_errorCodes));
} // function IS_ERROR()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::IS_EVEN (   $value = 0)
static

IS_EVEN.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5180 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
return self::$_errorCodes['value'];
}
return ($value % 2 == 0);
} // function IS_EVEN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IS_LOGICAL (   $value = true)
static

IS_LOGICAL.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5228 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
return is_bool($value);
} // function IS_LOGICAL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IS_NA (   $value = '')
static

IS_NA.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5167 of file Functions.php.

References flattenSingleValue().

Referenced by IS_ERR().

{
$value = self::flattenSingleValue($value);
return ($value === self::$_errorCodes['na']);
} // function IS_NA()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::IS_NONTEXT (   $value = '')
static

IS_NONTEXT.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5254 of file Functions.php.

References IS_TEXT().

{
return !self::IS_TEXT($value);
} // function IS_NONTEXT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IS_NUMBER (   $value = 0)
static

IS_NUMBER.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5212 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
if (is_string($value)) {
return False;
}
return is_numeric($value);
} // function IS_NUMBER()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IS_ODD (   $value = null)
static

IS_ODD.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5196 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
return self::$_errorCodes['value'];
}
return (abs($value) % 2 == 1);
} // function IS_ODD()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::IS_TEXT (   $value = '')
static

IS_TEXT.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5241 of file Functions.php.

References flattenSingleValue().

Referenced by IS_NONTEXT().

{
$value = self::flattenSingleValue($value);
return is_string($value);
} // function IS_TEXT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::KURT ( )
static

KURT.

Returns the kurtosis of a data set. Kurtosis characterizes the relative peakedness or flatness of a distribution compared with the normal distribution. Positive kurtosis indicates a relatively peaked distribution. Negative kurtosis indicates a relatively flat distribution.

Parameters
arrayData Series
Returns
float

Definition at line 4714 of file Functions.php.

References AVERAGE(), flattenArray(), and STDEV().

{
$aArgs = self::flattenArray(func_get_args());
$mean = self::AVERAGE($aArgs);
$stdDev = self::STDEV($aArgs);
if ($stdDev > 0) {
$count = $summer = 0;
// Loop through arguments
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summer += pow((($arg - $mean) / $stdDev),4) ;
++$count;
}
}
// Return
if ($count > 3) {
return $summer * ($count * ($count+1) / (($count-1) * ($count-2) * ($count-3))) - (3 * pow($count-1,2) / (($count-2) * ($count-3)));
}
}
return self::$_errorCodes['divisionbyzero'];
} // function KURT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LARGE ( )
static

Definition at line 904 of file Functions.php.

References $n, COUNT(), and flattenArray().

{
$aArgs = self::flattenArray(func_get_args());
// Calculate
$n = floor(array_pop($aArgs));
if ((is_numeric($n)) && (!is_string($n))) {
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$count = self::COUNT($mArgs);
$n = floor(--$n);
if (($n < 0) || ($n >= $count) || ($count == 0)) {
return self::$_errorCodes['num'];
}
rsort($mArgs);
return $mArgs[$n];
}
return self::$_errorCodes['value'];
} // function LARGE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LCM ( )
static

LCM.

Returns the lowest common multiplier of a series of numbers

Parameters
$arrayValues to calculate the Lowest Common Multiplier
Returns
int Lowest Common Multiplier

Definition at line 3011 of file Functions.php.

References _factors(), elseif(), and flattenArray().

{
$aArgs = self::flattenArray(func_get_args());
$returnValue = 1;
$allPoweredFactors = array();
foreach($aArgs as $value) {
if (!is_numeric($value)) {
return self::$_errorCodes['value'];
}
if ($value == 0) {
return 0;
} elseif ($value < 0) {
return self::$_errorCodes['num'];
}
$myFactors = self::_factors(floor($value));
$myCountedFactors = array_count_values($myFactors);
$myPoweredFactors = array();
foreach($myCountedFactors as $myCountedFactor => $myCountedPower) {
$myPoweredFactors[$myCountedFactor] = pow($myCountedFactor,$myCountedPower);
}
foreach($myPoweredFactors as $myPoweredValue => $myPoweredFactor) {
if (array_key_exists($myPoweredValue,$allPoweredFactors)) {
if ($allPoweredFactors[$myPoweredValue] < $myPoweredFactor) {
$allPoweredFactors[$myPoweredValue] = $myPoweredFactor;
}
} else {
$allPoweredFactors[$myPoweredValue] = $myPoweredFactor;
}
}
}
foreach($allPoweredFactors as $allPoweredFactor) {
$returnValue *= (integer) $allPoweredFactor;
}
return $returnValue;
} // function LCM()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LEFT (   $value = '',
  $chars = 1 
)
static

LEFT.

Parameters
string$valueValue
int$charsNumber of characters
Returns
string

Definition at line 4938 of file Functions.php.

References flattenSingleValue().

Referenced by REPLACE().

{
$value = self::flattenSingleValue($value);
$chars = self::flattenSingleValue($chars);
if (function_exists('mb_substr')) {
return mb_substr($value, 0, $chars, 'UTF-8');
} else {
return substr($value, 0, $chars);
}
} // function LEFT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::LINEST (   $yValues,
  $xValues,
  $const = True,
  $stats = False 
)
static

LINEST.

Calculates the statistics for a line by using the "least squares" method to calculate a straight line that best fits your data, and then returns an array that describes the line.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
booleanA logical value specifying whether to force the intersect to equal 0.
booleanA logical value specifying whether to return additional regression statistics.
Returns
array

Definition at line 2245 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$const = (boolean) self::flattenSingleValue($const);
$stats = (boolean) self::flattenSingleValue($stats);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const);
if ($stats) {
return array( array( $bestFitLinear->getSlope(),
$bestFitLinear->getSlopeSE(),
$bestFitLinear->getGoodnessOfFit(),
$bestFitLinear->getF(),
$bestFitLinear->getSSRegression(),
),
array( $bestFitLinear->getIntersect(),
$bestFitLinear->getIntersectSE(),
$bestFitLinear->getStdevOfResiduals(),
$bestFitLinear->getDFResiduals(),
$bestFitLinear->getSSResiduals()
)
);
} else {
return array( $bestFitLinear->getSlope(),
$bestFitLinear->getIntersect()
);
}
} // function LINEST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LOG_BASE (   $number,
  $base = 10 
)
static

Definition at line 543 of file Functions.php.

References flattenSingleValue().

{
$number = self::flattenSingleValue($number);
$base = self::flattenSingleValue($base);
return log($number, $base);
} // function LOG_BASE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LOGEST (   $yValues,
  $xValues,
  $const = True,
  $stats = False 
)
static

LOGEST.

Calculates an exponential curve that best fits the X and Y data series, and then returns an array that describes the line.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
booleanA logical value specifying whether to force the intersect to equal 0.
booleanA logical value specifying whether to return additional regression statistics.
Returns
array

Definition at line 2297 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_EXPONENTIAL.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$const = (boolean) self::flattenSingleValue($const);
$stats = (boolean) self::flattenSingleValue($stats);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitExponential = trendClass::calculate(trendClass::TREND_EXPONENTIAL,$yValues,$xValues,$const);
if ($stats) {
return array( array( $bestFitExponential->getSlope(),
$bestFitExponential->getSlopeSE(),
$bestFitExponential->getGoodnessOfFit(),
$bestFitExponential->getF(),
$bestFitExponential->getSSRegression(),
),
array( $bestFitExponential->getIntersect(),
$bestFitExponential->getIntersectSE(),
$bestFitExponential->getStdevOfResiduals(),
$bestFitExponential->getDFResiduals(),
$bestFitExponential->getSSResiduals()
)
);
} else {
return array( $bestFitExponential->getSlope(),
$bestFitExponential->getIntersect()
);
}
} // function LOGEST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LOGICAL_AND ( )
static

Definition at line 295 of file Functions.php.

References elseif(), and flattenArray().

{
// Return value
$returnValue = True;
// Loop through the arguments
$aArgs = self::flattenArray(func_get_args());
$argCount = 0;
foreach ($aArgs as $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue && $arg;
++$argCount;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue && ($arg != 0);
++$argCount;
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if ($arg == 'TRUE') {
$arg = 1;
} elseif ($arg == 'FALSE') {
$arg = 0;
} else {
return self::$_errorCodes['value'];
}
$returnValue = $returnValue && ($arg != 0);
++$argCount;
}
}
// Return
if ($argCount == 0) {
return self::$_errorCodes['value'];
}
return $returnValue;
} // function LOGICAL_AND()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LOGICAL_FALSE ( )
static

Definition at line 402 of file Functions.php.

{
return False;
} // function LOGICAL_FALSE()
static PHPExcel_Calculation_Functions::LOGICAL_NOT (   $logical)
static

Definition at line 437 of file Functions.php.

{
return !$logical;
} // function LOGICAL_NOT()
static PHPExcel_Calculation_Functions::LOGICAL_OR ( )
static

Definition at line 353 of file Functions.php.

References elseif(), and flattenArray().

{
// Return value
$returnValue = False;
// Loop through the arguments
$aArgs = self::flattenArray(func_get_args());
$argCount = 0;
foreach ($aArgs as $arg) {
// Is it a boolean value?
if (is_bool($arg)) {
$returnValue = $returnValue || $arg;
++$argCount;
} elseif ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue = $returnValue || ($arg != 0);
++$argCount;
} elseif (is_string($arg)) {
$arg = strtoupper($arg);
if ($arg == 'TRUE') {
$arg = 1;
} elseif ($arg == 'FALSE') {
$arg = 0;
} else {
return self::$_errorCodes['value'];
}
$returnValue = $returnValue || ($arg != 0);
++$argCount;
}
}
// Return
if ($argCount == 0) {
return self::$_errorCodes['value'];
}
return $returnValue;
} // function LOGICAL_OR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LOGICAL_TRUE ( )
static

Definition at line 419 of file Functions.php.

{
return True;
} // function LOGICAL_TRUE()
static PHPExcel_Calculation_Functions::LOGINV (   $probability,
  $mean,
  $stdDev 
)
static

LOGINV.

Returns the inverse of the normal cumulative distribution

Parameters
float$value
Returns
float
Todo:
Try implementing P J Acklam's refinement algorithm for greater accuracy if I can get my head round the mathematics (as described at) http://home.online.no/~pjacklam/notes/invnorm/

Definition at line 4398 of file Functions.php.

References flattenSingleValue().

{
$probability = self::flattenSingleValue($probability);
$mean = self::flattenSingleValue($mean);
$stdDev = self::flattenSingleValue($stdDev);
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if (($probability < 0) || ($probability > 1) || ($stdDev <= 0)) {
return self::$_errorCodes['num'];
}
return exp($mean + $stdDev * self::NORMSINV($probability));
}
return self::$_errorCodes['value'];
} // function LOGINV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LOGNORMDIST (   $value,
  $mean,
  $stdDev 
)
static

LOGNORMDIST.

Returns the cumulative lognormal distribution of x, where ln(x) is normally distributed with parameters mean and standard_dev.

Parameters
float$value
Returns
float

Definition at line 4109 of file Functions.php.

References flattenSingleValue(), and NORMSDIST().

{
$value = self::flattenSingleValue($value);
$mean = self::flattenSingleValue($mean);
$stdDev = self::flattenSingleValue($stdDev);
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if (($value <= 0) || ($stdDev <= 0)) {
return self::$_errorCodes['num'];
}
return self::NORMSDIST((log($value) - $mean) / $stdDev);
}
return self::$_errorCodes['value'];
} // function LOGNORMDIST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::LOOKUP (   $lookup_value,
  $lookup_vector,
  $result_vector = null 
)
static

LOOKUP The LOOKUP function searches for value either from a one-row or one-column range or from an array.

Parameters
lookup_valueThe value that you want to match in lookup_array
lookup_vectorThe range of cells being searched
result_vectorThe column from which the matching value must be returned
Returns
mixed The value of the found cell

Definition at line 10302 of file Functions.php.

{
// check for LOOKUP Syntax (view Excel documentation)
if( is_null($result_vector) )
{
// TODO: Syntax 2 (array)
} else {
// Syntax 1 (vector)
// get key (column or row) of lookup_vector
$kl = key($lookup_vector);
// check if lookup_value exists in lookup_vector
if( in_array($lookup_value, $lookup_vector[$kl]) )
{
// FOUND IT! Get key of lookup_vector
$k_res = array_search($lookup_value, $lookup_vector[$kl]);
} else {
// value NOT FOUND
// Get the smallest value in lookup_vector
// The LOOKUP spec in Excel states --> IMPORTANT - The values in lookup_vector must be placed in ascending order!
$ksv = key($lookup_vector[$kl]);
$smallest_value = $lookup_vector[$kl][$ksv];
// If lookup_value is smaller than the smallest value in lookup_vector, LOOKUP gives the #N/A error value.
if( $lookup_value < $smallest_value )
{
return self::$_errorCodes['na'];
} else {
// If LOOKUP can't find the lookup_value, it matches the largest value in lookup_vector that is less than or equal to lookup_value.
// IMPORTANT : In Excel Documentation is not clear what happen if lookup_value is text!
foreach( $lookup_vector[$kl] AS $kk => $value )
{
if( $lookup_value >= $value )
{
$k_res = $kk;
}
}
}
}
// Returns a value from the same position in result_vector
// get key (column or row) of result_vector
$kr = key($result_vector);
if( isset($result_vector[$kr][$k_res]) )
{
return $result_vector[$kr][$k_res];
} else {
// TODO: In Excel Documentation is not clear what happen here...
}
}
} // function LOOKUP()
static PHPExcel_Calculation_Functions::LOWERCASE (   $mixedCaseString)
static

LOWERCASE.

Converts a string value to upper case.

Parameters
string$mixedCaseString
Returns
string

Definition at line 8478 of file Functions.php.

References flattenSingleValue().

{
$mixedCaseString = self::flattenSingleValue($mixedCaseString);
if (function_exists('mb_convert_case')) {
return mb_convert_case($mixedCaseString, MB_CASE_LOWER, 'UTF-8');
} else {
return strtoupper($mixedCaseString);
}
} // function LOWERCASE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MATCH (   $lookup_value,
  $lookup_array,
  $match_type = 1 
)
static

MATCH The MATCH function searches for a specified item in a range of cells.

Parameters
lookup_valueThe value that you want to match in lookup_array
lookup_arrayThe range of cells being searched
match_typeThe number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. If match_type is 1 or -1, the list has to be ordered.
Returns
integer the relative position of the found item

Definition at line 9840 of file Functions.php.

References flattenArray(), and flattenSingleValue().

{
// flatten the lookup_array
$lookup_array = self::flattenArray($lookup_array);
// flatten lookup_value since it may be a cell reference to a value or the value itself
$lookup_value = self::flattenSingleValue($lookup_value);
// MATCH is not case sensitive
$lookup_value = strtolower($lookup_value);
/*
echo "--------------------<br>looking for $lookup_value in <br>";
print_r($lookup_array);
echo "<br>";
//return 1;
/**/
// **
// check inputs
// **
// lookup_value type has to be number, text, or logical values
if (!is_numeric($lookup_value) && !is_string($lookup_value) && !is_bool($lookup_value)){
// error: lookup_array should contain only number, text, or logical values
//echo "error: lookup_array should contain only number, text, or logical values<br>";
return self::$_errorCodes['na'];
}
// match_type is 0, 1 or -1
if ($match_type!==0 && $match_type!==-1 && $match_type!==1){
// error: wrong value for match_type
//echo "error: wrong value for match_type<br>";
return self::$_errorCodes['na'];
}
// lookup_array should not be empty
if (sizeof($lookup_array)<=0){
// error: empty range
//echo "error: empty range ".sizeof($lookup_array)."<br>";
return self::$_errorCodes['na'];
}
// lookup_array should contain only number, text, or logical values
for ($i=0;$i<sizeof($lookup_array);++$i){
// check the type of the value
if (!is_numeric($lookup_array[$i]) && !is_string($lookup_array[$i]) && !is_bool($lookup_array[$i])){
// error: lookup_array should contain only number, text, or logical values
//echo "error: lookup_array should contain only number, text, or logical values<br>";
return self::$_errorCodes['na'];
}
// convert tpo lowercase
if (is_string($lookup_array[$i]))
$lookup_array[$i] = strtolower($lookup_array[$i]);
}
// if match_type is 1 or -1, the list has to be ordered
if($match_type==1 || $match_type==-1){
// **
// iniitialization
// store the last value
$iLastValue=$lookup_array[0];
// **
// loop on the cells
for ($i=0;$i<sizeof($lookup_array);++$i){
// check ascending order
if(($match_type==1 && $lookup_array[$i]<$iLastValue)
// OR check descending order
|| ($match_type==-1 && $lookup_array[$i]>$iLastValue)){
// error: list is not ordered correctly
//echo "error: list is not ordered correctly<br>";
return self::$_errorCodes['na'];
}
}
}
// **
// find the match
// **
// loop on the cells
for ($i=0; $i < sizeof($lookup_array); ++$i){
// if match_type is 0 <=> find the first value that is exactly equal to lookup_value
if ($match_type==0 && $lookup_array[$i]==$lookup_value){
// this is the exact match
return $i+1;
}
// if match_type is -1 <=> find the smallest value that is greater than or equal to lookup_value
if ($match_type==-1 && $lookup_array[$i] < $lookup_value){
if ($i<1){
// 1st cell was allready smaller than the lookup_value
break;
}
else
// the previous cell was the match
return $i;
}
// if match_type is 1 <=> find the largest value that is less than or equal to lookup_value
if ($match_type==1 && $lookup_array[$i] > $lookup_value){
if ($i<1){
// 1st cell was allready bigger than the lookup_value
break;
}
else
// the previous cell was the match
return $i;
}
}
// unsuccessful in finding a match, return #N/A error value
//echo "unsuccessful in finding a match<br>";
return self::$_errorCodes['na'];
} // function MATCH()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MAX ( )
static

Definition at line 824 of file Functions.php.

References flattenArray().

Referenced by SUBTOTAL().

{
// Return value
$returnValue = null;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if ((is_null($returnValue)) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MAX()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::MAXA ( )
static

Definition at line 860 of file Functions.php.

References elseif(), and flattenArray().

{
// Return value
$returnValue = null;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if ((is_null($returnValue)) || ($arg > $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MAXA()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MDETERM (   $matrixValues)
static

MDETERM.

Parameters
array$matrixValuesA matrix of values
Returns
float

Definition at line 10137 of file Functions.php.

References $row.

{
$matrixData = array();
if (!is_array($matrixValues)) { $matrixValues = array(array($matrixValues)); }
$row = $maxColumn = 0;
foreach($matrixValues as $matrixRow) {
$column = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
return self::$_errorCodes['value'];
}
$matrixData[$column][$row] = $matrixCell;
++$column;
}
if ($column > $maxColumn) { $maxColumn = $column; }
++$row;
}
if ($row != $maxColumn) { return self::$_errorCodes['value']; }
try {
$matrix = new Matrix($matrixData);
return $matrix->det();
} catch (Exception $ex) {
return self::$_errorCodes['value'];
}
} // function MDETERM()
static PHPExcel_Calculation_Functions::MEDIAN ( )
static

Definition at line 1289 of file Functions.php.

References flattenArray().

{
// Return value
$returnValue = self::$_errorCodes['num'];
$mArgs = array();
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$mValueCount = count($mArgs);
if ($mValueCount > 0) {
sort($mArgs,SORT_NUMERIC);
$mValueCount = $mValueCount / 2;
if ($mValueCount == floor($mValueCount)) {
$returnValue = ($mArgs[$mValueCount--] + $mArgs[$mValueCount]) / 2;
} else {
$mValueCount == floor($mValueCount);
$returnValue = $mArgs[$mValueCount];
}
}
// Return
return $returnValue;
} // function MEDIAN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MID (   $value = '',
  $start = 1,
  $chars = null 
)
static

MID.

Parameters
string$valueValue
int$startStart character
int$charsNumber of characters
Returns
string

Definition at line 4977 of file Functions.php.

References $start, and flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$chars = self::flattenSingleValue($chars);
if (function_exists('mb_substr')) {
return mb_substr($value, --$start, $chars, 'UTF-8');
} else {
return substr($value, --$start, $chars);
}
} // function MID()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MIN ( )
static

Definition at line 705 of file Functions.php.

References flattenArray().

Referenced by SUBTOTAL().

{
// Return value
$returnValue = null;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if ((is_null($returnValue)) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MIN()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::MINA ( )
static

Definition at line 741 of file Functions.php.

References elseif(), and flattenArray().

{
// Return value
$returnValue = null;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if ((is_null($returnValue)) || ($arg < $returnValue)) {
$returnValue = $arg;
}
}
}
// Return
if(is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function MINA()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MINUTEOFHOUR (   $timeValue = 0)
static

MINUTEOFHOUR.

Parameters
long$timeValueExcel time serial value or a standard time string
Returns
int Minute

Definition at line 6130 of file Functions.php.

References _getTimeValue(), elseif(), PHPExcel_Shared_Date\ExcelToPHP(), and flattenSingleValue().

{
$timeValue = $timeTester = self::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) {
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) {
return self::$_errorCodes['value'];
}
}
$timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) {
return self::$_errorCodes['value'];
}
}
// Execute function
if (is_real($timeValue)) {
if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) {
return self::$_errorCodes['num'];
}
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
}
return (int) date('i',$timeValue);
} // function MINUTEOFHOUR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MINVERSE (   $matrixValues)
static

MINVERSE.

Parameters
array$matrixValuesA matrix of values
Returns
array

Definition at line 10103 of file Functions.php.

References $row.

{
$matrixData = array();
if (!is_array($matrixValues)) { $matrixValues = array(array($matrixValues)); }
$row = $maxColumn = 0;
foreach($matrixValues as $matrixRow) {
$column = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
return self::$_errorCodes['value'];
}
$matrixData[$column][$row] = $matrixCell;
++$column;
}
if ($column > $maxColumn) { $maxColumn = $column; }
++$row;
}
if ($row != $maxColumn) { return self::$_errorCodes['value']; }
try {
$matrix = new Matrix($matrixData);
return $matrix->inverse()->getArray();
} catch (Exception $ex) {
return self::$_errorCodes['value'];
}
} // function MINVERSE()
static PHPExcel_Calculation_Functions::MMULT (   $matrixData1,
  $matrixData2 
)
static

MMULT.

Parameters
array$matrixData1A matrix of values
array$matrixData2A matrix of values
Returns
array

Definition at line 10053 of file Functions.php.

{
$matrixAData = $matrixBData = array();
if (!is_array($matrixData1)) { $matrixData1 = array(array($matrixData1)); }
if (!is_array($matrixData2)) { $matrixData2 = array(array($matrixData2)); }
$rowA = 0;
foreach($matrixData1 as $matrixRow) {
$columnA = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
return self::$_errorCodes['value'];
}
$matrixAData[$rowA][$columnA] = $matrixCell;
++$columnA;
}
++$rowA;
}
try {
$matrixA = new Matrix($matrixAData);
$rowB = 0;
foreach($matrixData2 as $matrixRow) {
$columnB = 0;
foreach($matrixRow as $matrixCell) {
if ((is_string($matrixCell)) || ($matrixCell === null)) {
return self::$_errorCodes['value'];
}
$matrixBData[$rowB][$columnB] = $matrixCell;
++$columnB;
}
++$rowB;
}
$matrixB = new Matrix($matrixBData);
if (($rowA != $columnB) || ($rowB != $columnA)) {
return self::$_errorCodes['value'];
}
return $matrixA->times($matrixB)->getArray();
} catch (Exception $ex) {
return self::$_errorCodes['value'];
}
} // function MMULT()
static PHPExcel_Calculation_Functions::MOD (   $a = 1,
  $b = 1 
)
static

MOD.

Parameters
int$aDividend
int$bDivisor
Returns
int Remainder

Definition at line 4765 of file Functions.php.

References flattenSingleValue().

{
return fmod($a,$b);
} // function MOD()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MODE ( )
static

Definition at line 1367 of file Functions.php.

References _modeCalc(), flattenArray(), and NA().

{
// Return value
$returnValue = self::NA();
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
if (count($mArgs) > 0) {
return self::_modeCalc($mArgs);
}
// Return
return $returnValue;
} // function MODE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MONTHOFYEAR (   $dateValue = 1)
static

MONTHOFYEAR.

Parameters
long$dateValueExcel date serial value or a standard date string
Returns
int Month

Definition at line 6056 of file Functions.php.

References PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenSingleValue().

{
$dateValue = self::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('n');
} // function MONTHOFYEAR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::MROUND (   $number,
  $multiple 
)
static

MROUND.

Rounds a number to the nearest multiple of a specified value

Parameters
float$numberNumber to round
int$multipleMultiple to which you want to round $number
Returns
float Rounded Number

Definition at line 2789 of file Functions.php.

References flattenSingleValue().

Referenced by DOLLAR().

{
$number = self::flattenSingleValue($number);
$multiple = self::flattenSingleValue($multiple);
if ((is_numeric($number)) && (is_numeric($multiple))) {
if ($multiple == 0) {
return 0;
}
if ((self::SIGN($number)) == (self::SIGN($multiple))) {
$multiplier = 1 / $multiple;
return round($number * $multiplier) / $multiplier;
}
return self::$_errorCodes['num'];
}
return self::$_errorCodes['value'];
} // function MROUND()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::MULTINOMIAL ( )
static

MULTINOMIAL.

Returns the ratio of the factorial of a sum of values to the product of factorials.

Parameters
arrayof mixed Data Series
Returns
float

Definition at line 2609 of file Functions.php.

References FACT(), and flattenArray().

{
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$summer = 0;
$divisor = 1;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if (is_numeric($arg)) {
if ($arg < 1) {
return self::$_errorCodes['num'];
}
$summer += floor($arg);
$divisor *= self::FACT($arg);
} else {
return self::$_errorCodes['value'];
}
}
// Return
if ($summer > 0) {
$summer = self::FACT($summer);
return $summer / $divisor;
}
return 0;
} // function MULTINOMIAL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::NA ( )
static

Definition at line 233 of file Functions.php.

Referenced by _modeCalc(), DEVSQ(), HARMEAN(), and MODE().

{
return self::$_errorCodes['na'];
} // function NA()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::NAME ( )
static

Definition at line 257 of file Functions.php.

{
return self::$_errorCodes['name'];
} // function NAME()
static PHPExcel_Calculation_Functions::NaN ( )
static

Definition at line 245 of file Functions.php.

Referenced by PHPExcel_Calculation\_unwrapResult(), and PHPExcel_Calculation\_wrapResult().

{
return self::$_errorCodes['num'];
} // function NAN()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::NEGBINOMDIST (   $failures,
  $successes,
  $probability 
)
static

NEGBINOMDIST.

Returns the negative binomial distribution. NEGBINOMDIST returns the probability that there will be number_f failures before the number_s-th success, when the constant probability of a success is probability_s. This function is similar to the binomial distribution, except that the number of successes is fixed, and the number of trials is variable. Like the binomial, trials are assumed to be independent.

Parameters
float$failuresNumber of Failures
float$successesThreshold number of Successes
float$probabilityProbability of success on each trial
Returns
float

Definition at line 3171 of file Functions.php.

References flattenSingleValue().

{
$failures = floor(self::flattenSingleValue($failures));
$successes = floor(self::flattenSingleValue($successes));
$probability = self::flattenSingleValue($probability);
if ((is_numeric($failures)) && (is_numeric($successes)) && (is_numeric($probability))) {
if (($failures < 0) || ($successes < 1)) {
return self::$_errorCodes['num'];
}
if (($probability < 0) || ($probability > 1)) {
return self::$_errorCodes['num'];
}
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
if (($failures + $successes - 1) <= 0) {
return self::$_errorCodes['num'];
}
}
return (self::COMBIN($failures + $successes - 1,$successes - 1)) * (pow($probability,$successes)) * (pow(1 - $probability,$failures)) ;
}
return self::$_errorCodes['value'];
} // function NEGBINOMDIST()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::NETWORKDAYS (   $startDate,
  $endDate 
)
static

NETWORKDAYS.

Parameters
mixedStart date
mixedEnd date
arrayof mixed Optional Date Series
Returns
long Interval between the dates

Definition at line 5813 of file Functions.php.

References DAYOFWEEK(), and flattenArray().

{
// Flush the mandatory start and end date that are referenced in the function definition
$dateArgs = self::flattenArray(func_get_args());
array_shift($dateArgs);
array_shift($dateArgs);
// Validate the start and end dates
if (is_string($startDate = $sDate = self::_getDateValue($startDate))) {
return self::$_errorCodes['value'];
}
if (is_string($endDate = $eDate = self::_getDateValue($endDate))) {
return self::$_errorCodes['value'];
}
if ($sDate > $eDate) {
$startDate = $eDate;
$endDate = $sDate;
}
// Execute function
$startDoW = 6 - self::DAYOFWEEK($startDate,2);
if ($startDoW < 0) { $startDoW = 0; }
$endDoW = self::DAYOFWEEK($endDate,2);
if ($endDoW >= 6) { $endDoW = 0; }
$wholeWeekDays = floor(($endDate - $startDate) / 7) * 5;
$partWeekDays = $endDoW + $startDoW;
if ($partWeekDays > 5) {
$partWeekDays -= 5;
}
// Test any extra holiday parameters
$holidayCountedArray = array();
foreach ($dateArgs as $holidayDate) {
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
return self::$_errorCodes['value'];
}
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {
--$partWeekDays;
$holidayCountedArray[] = $holidayDate;
}
}
}
if ($sDate > $eDate) {
return 0 - ($wholeWeekDays + $partWeekDays);
}
return $wholeWeekDays + $partWeekDays;
} // function NETWORKDAYS()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::NOMINAL (   $effect_rate = 0,
  $npery = 0 
)
static

NOMINAL.

Returns the nominal interest rate given the effective rate and the number of compounding payments per year.

Parameters
float$effect_rateEffective interest rate
int$nperyNumber of compounding payments per year
Returns
float

Definition at line 8653 of file Functions.php.

References flattenSingleValue().

{
$effect_rate = self::flattenSingleValue($effect_rate);
$npery = (int)self::flattenSingleValue($npery);
// Validate parameters
if ($effect_rate <= 0 || $npery < 1) {
return self::$_errorCodes['num'];
}
// Calculate
return $npery * (pow($effect_rate + 1, 1 / $npery) - 1);
} // function NOMINAL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::NORMDIST (   $value,
  $mean,
  $stdDev,
  $cumulative 
)
static

NORMDIST.

Returns the normal distribution for the specified mean and standard deviation. This function has a very wide range of applications in statistics, including hypothesis testing.

Parameters
float$value
float$meanMean Value
float$stdDevStandard Deviation
boolean$cumulative
Returns
float

Definition at line 4062 of file Functions.php.

References _erfVal(), flattenSingleValue(), and SQRT2PI.

Referenced by NORMSDIST().

{
$value = self::flattenSingleValue($value);
$mean = self::flattenSingleValue($mean);
$stdDev = self::flattenSingleValue($stdDev);
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if ($stdDev < 0) {
return self::$_errorCodes['num'];
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return 0.5 * (1 + self::_erfVal(($value - $mean) / ($stdDev * sqrt(2))));
} else {
return (1 / (SQRT2PI * $stdDev)) * exp(0 - (pow($value - $mean,2) / (2 * pow($stdDev,2))));
}
}
}
return self::$_errorCodes['value'];
} // function NORMDIST()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::NORMINV (   $probability,
  $mean,
  $stdDev 
)
static

NORMINV.

Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation.

Parameters
float$value
float$meanMean Value
float$stdDevStandard Deviation
Returns
float

Definition at line 4355 of file Functions.php.

References flattenSingleValue().

Referenced by NORMSINV().

{
$probability = self::flattenSingleValue($probability);
$mean = self::flattenSingleValue($mean);
$stdDev = self::flattenSingleValue($stdDev);
if ((is_numeric($probability)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if (($probability < 0) || ($probability > 1)) {
return self::$_errorCodes['num'];
}
if ($stdDev < 0) {
return self::$_errorCodes['num'];
}
return (self::_inverse_ncdf($probability) * $stdDev) + $mean;
}
return self::$_errorCodes['value'];
} // function NORMINV()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::NORMSDIST (   $value)
static

NORMSDIST.

Returns the standard normal cumulative distribution function. The distribution has a mean of 0 (zero) and a standard deviation of one. Use this function in place of a table of standard normal curve areas.

Parameters
float$value
Returns
float

Definition at line 4093 of file Functions.php.

References flattenSingleValue(), and NORMDIST().

Referenced by LOGNORMDIST().

{
$value = self::flattenSingleValue($value);
return self::NORMDIST($value, 0, 1, True);
} // function NORMSDIST()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::NORMSINV (   $value)
static

NORMSINV.

Returns the inverse of the standard normal cumulative distribution

Parameters
float$value
Returns
float

Definition at line 4381 of file Functions.php.

References NORMINV().

Referenced by CONFIDENCE().

{
return self::NORMINV($value, 0, 1);
} // function NORMSINV()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::NPER (   $rate = 0,
  $pmt = 0,
  $pv = 0,
  $fv = 0,
  $type = 0 
)
static

NPER.

Returns the number of periods for a cash flow with constant periodic payments (annuities), and interest rate.

 @param     float   $rate   Interest rate per period
 @param     int             $pmt    Periodic payment (annuity)
 @param     float   $pv             Present Value
 @param     float   $fv             Future Value
 @param     int             $type   Payment type: 0 = at the end of each period, 1 = at the beginning of each period
 @return    float

Definition at line 8778 of file Functions.php.

References $type, and flattenSingleValue().

{
$rate = self::flattenSingleValue($rate);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
// Calculate
if (!is_null($rate) && $rate != 0) {
if ($pmt == 0 && $pv == 0) {
return self::$_errorCodes['num'];
}
return log(($pmt * (1 + $rate * $type) / $rate - $fv) / ($pv + $pmt * (1 + $rate * $type) / $rate)) / log(1 + $rate);
} else {
if ($pmt == 0) {
return self::$_errorCodes['num'];
}
return (-$pv -$fv) / $pmt;
}
} // function NPER()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::NPV ( )
static

NPV.

Returns the Net Present Value of a cash flow series given a discount rate.

Parameters
floatDiscount interest rate
arrayCash flow series
Returns
float

Definition at line 8976 of file Functions.php.

References flattenArray().

{
// Return value
$returnValue = 0;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
// Calculate
$rate = array_shift($aArgs);
for ($i = 1; $i <= count($aArgs); ++$i) {
// Is it a numeric value?
if (is_numeric($aArgs[$i - 1])) {
$returnValue += $aArgs[$i - 1] / pow(1 + $rate, $i);
}
}
// Return
return $returnValue;
} // function NPV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::OCTTOBIN (   $x,
  $places = null 
)
static

OCTTOBIN.

Return an octal value as binary.

Parameters
string$x
Returns
string

Definition at line 6656 of file Functions.php.

References $out, $x, _nbrConversionFormat(), and flattenSingleValue().

{
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
return self::$_errorCodes['value'];
}
$x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return self::$_errorCodes['num'];
}
$binVal = decbin(octdec($x));
return self::_nbrConversionFormat($binVal,$places);
} // function OCTTOBIN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::OCTTODEC (   $x)
static

OCTTODEC.

Return an octal value as binary.

Parameters
string$x
Returns
string

Definition at line 6681 of file Functions.php.

References $out, $x, and flattenSingleValue().

{
if (is_bool($x)) {
return self::$_errorCodes['value'];
}
$x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return self::$_errorCodes['num'];
}
return octdec($x);
} // function OCTTODEC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::OCTTOHEX (   $x,
  $places = null 
)
static

OCTTOHEX.

Return an octal value as hex.

Parameters
string$x
Returns
string

Definition at line 6703 of file Functions.php.

References $out, $x, _nbrConversionFormat(), and flattenSingleValue().

{
$places = self::flattenSingleValue($places);
if (is_bool($x)) {
return self::$_errorCodes['value'];
}
$x = (string) $x;
if (preg_match_all('/[01234567]/',$x,$out) != strlen($x)) {
return self::$_errorCodes['num'];
}
$hexVal = strtoupper(dechex(octdec($x)));
return self::_nbrConversionFormat($hexVal,$places);
} // function OCTTOHEX()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ODD (   $number)
static

ODD.

Returns number rounded up to the nearest odd integer.

Parameters
float$numberNumber to round
Returns
int Rounded Number

Definition at line 2694 of file Functions.php.

References $result, CEILING(), flattenSingleValue(), and SIGN().

{
$number = self::flattenSingleValue($number);
if (is_numeric($number)) {
$significance = self::SIGN($number);
if ($significance == 0) {
return 1;
}
$result = self::CEILING($number,$significance);
if (self::IS_EVEN($result)) {
$result += $significance;
}
return $result;
}
return self::$_errorCodes['value'];
} // function ODD()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::OFFSET (   $cellAddress = Null,
  $rows = 0,
  $columns = 0,
  $height = null,
  $width = null 
)
static

Definition at line 9759 of file Functions.php.

References $columns, PHPExcel_Cell\columnIndexFromString(), and PHPExcel_Cell\stringFromColumnIndex().

{
if ($cellAddress == Null) {
return 0;
}
foreach($cellAddress as $startColumnKey => $rowValue) {
$startColumnIndex = PHPExcel_Cell::columnIndexFromString($startColumnKey);
foreach($rowValue as $startRowKey => $cellValue) {
break 2;
}
}
foreach($cellAddress as $endColumnKey => $rowValue) {
foreach($rowValue as $endRowKey => $cellValue) {
}
}
$endColumnIndex = PHPExcel_Cell::columnIndexFromString($endColumnKey);
$startColumnIndex += --$columns;
$startRowKey += $rows;
if ($width == null) {
$endColumnIndex += $columns -1;
} else {
$endColumnIndex = $startColumnIndex + $width;
}
if ($height == null) {
$endRowKey += $rows;
} else {
$endRowKey = $startRowKey + $height -1;
}
if (($startColumnIndex < 0) || ($startRowKey <= 0)) {
return self::$_errorCodes['reference'];
}
$startColumnKey = PHPExcel_Cell::stringFromColumnIndex($startColumnIndex);
$endColumnKey = PHPExcel_Cell::stringFromColumnIndex($endColumnIndex);
$startCell = $startColumnKey.$startRowKey;
$endCell = $endColumnKey.$endRowKey;
if ($startCell == $endCell) {
return $startColumnKey.$startRowKey;
} else {
return $startColumnKey.$startRowKey.':'.$endColumnKey.$endRowKey;
}
} // function OFFSET()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::PERCENTILE ( )
static

Definition at line 944 of file Functions.php.

References COUNT(), and flattenArray().

Referenced by QUARTILE().

{
$aArgs = self::flattenArray(func_get_args());
// Calculate
$entry = array_pop($aArgs);
if ((is_numeric($entry)) && (!is_string($entry))) {
if (($entry < 0) || ($entry > 1)) {
return self::$_errorCodes['num'];
}
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$mValueCount = count($mArgs);
if ($mValueCount > 0) {
sort($mArgs);
$count = self::COUNT($mArgs);
$index = $entry * ($count-1);
$iBase = floor($index);
if ($index == $iBase) {
return $mArgs[$index];
} else {
$iNext = $iBase + 1;
$iProportion = $index - $iBase;
return $mArgs[$iBase] + (($mArgs[$iNext] - $mArgs[$iBase]) * $iProportion) ;
}
}
}
return self::$_errorCodes['value'];
} // function PERCENTILE()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::PERCENTRANK (   $valueSet,
  $value,
  $significance = 3 
)
static

PERCENTRANK.

Returns the rank of a value in a data set as a percentage of the data set.

Parameters
arrayof number An array of, or a reference to, a list of numbers.
numberThe number whose rank you want to find.
numberThe number of significant digits for the returned percentage value.
Returns
float

Definition at line 2007 of file Functions.php.

References $key, flattenArray(), and flattenSingleValue().

{
$valueSet = self::flattenArray($valueSet);
$value = self::flattenSingleValue($value);
$significance = self::flattenSingleValue($significance);
foreach($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) {
unset($valueSet[$key]);
}
}
sort($valueSet,SORT_NUMERIC);
$valueCount = count($valueSet);
if ($valueCount == 0) {
return self::$_errorCodes['num'];
}
$valueAdjustor = $valueCount - 1;
if (($value < $valueSet[0]) || ($value > $valueSet[$valueAdjustor])) {
return self::$_errorCodes['na'];
}
$pos = array_search($value,$valueSet);
if ($pos === False) {
$pos = 0;
$testValue = $valueSet[0];
while ($testValue < $value) {
$testValue = $valueSet[++$pos];
}
--$pos;
$pos += (($value - $valueSet[$pos]) / ($testValue - $valueSet[$pos]));
}
return round($pos / $valueAdjustor,$significance);
} // function PERCENTRANK()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::PERMUT (   $numObjs,
  $numInSet 
)
static

PERMUT.

Returns the number of permutations for a given number of objects that can be selected from number objects. A permutation is any set or subset of objects or events where internal order is significant. Permutations are different from combinations, for which the internal order is not significant. Use this function for lottery-style probability calculations.

Parameters
int$numObjsNumber of different objects
int$numInSetNumber of objects in each permutation
Returns
int Number of permutations

Definition at line 2873 of file Functions.php.

References flattenSingleValue().

{
$numObjs = self::flattenSingleValue($numObjs);
$numInSet = self::flattenSingleValue($numInSet);
if ((is_numeric($numObjs)) && (is_numeric($numInSet))) {
if ($numObjs < $numInSet) {
return self::$_errorCodes['num'];
}
return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet));
}
return self::$_errorCodes['value'];
} // function PERMUT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::PMT (   $rate = 0,
  $nper = 0,
  $pv = 0,
  $fv = 0,
  $type = 0 
)
static

PMT.

Returns the constant payment (annuity) for a cash flow with a constant interest rate.

Parameters
float$rateInterest rate per period
int$nperNumber of periods
float$pvPresent Value
float$fvFuture Value
int$typePayment type: 0 = at the end of each period, 1 = at the beginning of each period
Returns
float

Definition at line 8745 of file Functions.php.

References $type, and flattenSingleValue().

Referenced by _interestAndPrincipal().

{
$rate = self::flattenSingleValue($rate);
$nper = self::flattenSingleValue($nper);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
// Calculate
if (!is_null($rate) && $rate != 0) {
return (-$fv - $pv * pow(1 + $rate, $nper)) / (1 + $rate * $type) / ((pow(1 + $rate, $nper) - 1) / $rate);
} else {
return (-$pv - $fv) / $nper;
}
} // function PMT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::POISSON (   $value,
  $mean,
  $cumulative 
)
static

POISSON.

Returns the Poisson distribution. A common application of the Poisson distribution is predicting the number of events over a specific time, such as the number of cars arriving at a toll plaza in 1 minute.

Parameters
float$value
float$meanMean Value
boolean$cumulative
Returns
float

Definition at line 4611 of file Functions.php.

References FACT(), and flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$mean = self::flattenSingleValue($mean);
if ((is_numeric($value)) && (is_numeric($mean))) {
if (($value <= 0) || ($mean <= 0)) {
return self::$_errorCodes['num'];
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
$summer = 0;
for ($i = 0; $i <= floor($value); ++$i) {
$summer += pow($mean,$i) / self::FACT($i);
}
return exp(0-$mean) * $summer;
} else {
return (exp(0-$mean) * pow($mean,$value)) / self::FACT($value);
}
}
}
return self::$_errorCodes['value'];
} // function POISSON()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::POWER (   $x = 0,
  $y = 2 
)
static

POWER.

Computes x raised to the power y.

Parameters
float$x
float$y
Returns
float

Definition at line 6333 of file Functions.php.

References $x, $y, and flattenSingleValue().

{
// Validate parameters
if ($x == 0 && $y <= 0) {
return self::$_errorCodes['divisionbyzero'];
}
// Return
return pow($x, $y);
} // function POWER()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::PPMT (   $rate,
  $per,
  $nper,
  $pv,
  $fv = 0,
  $type = 0 
)
static

PPMT.

Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate.

Parameters
float$rateInterest rate per period
int$perPeriod for which we want to find the interest
int$nperNumber of periods
float$pvPresent Value
float$fvFuture Value
int$typePayment type: 0 = at the end of each period, 1 = at the beginning of each period
Returns
float

Definition at line 8905 of file Functions.php.

References $type, _interestAndPrincipal(), and flattenSingleValue().

Referenced by CUMPRINC().

{
$rate = self::flattenSingleValue($rate);
$per = (int) self::flattenSingleValue($per);
$nper = (int) self::flattenSingleValue($nper);
$type = (int) self::flattenSingleValue($type);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
if ($per <= 0 || $per > $nper) {
return self::$_errorCodes['value'];
}
// Calculate
$interestAndPrincipal = self::_interestAndPrincipal($rate, $per, $nper, $pv, $fv, $type);
return $interestAndPrincipal[1];
} // function PPMT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::PRICEDISC (   $settlement,
  $maturity,
  $discount,
  $redemption,
  $basis = 0 
)
static

PRICEDISC.

Returns the price per $100 face value of a discounted security.

Parameters
mixedsettlement The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.
mixedmaturity The security's maturity date. The maturity date is the date when the security expires.
intdiscount The security's discount rate.
intredemption The security's redemption value per $100 face value.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9275 of file Functions.php.

References flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$discount = (float) self::flattenSingleValue($discount);
$redemption = (float) self::flattenSingleValue($redemption);
$basis = (int) self::flattenSingleValue($basis);
// Validate
if ((is_numeric($discount)) && (is_numeric($redemption)) && (is_numeric($basis))) {
if (($discount <= 0) || ($redemption <= 0)) {
return self::$_errorCodes['num'];
}
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
return $redemption * (1 - $discount * $daysBetweenSettlementAndMaturity);
}
return self::$_errorCodes['value'];
} // function PRICEDISC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::PRICEMAT (   $settlement,
  $maturity,
  $issue,
  $rate,
  $yield,
  $basis = 0 
)
static

PRICEMAT.

Returns the price per $100 face value of a security that pays interest at maturity.

Parameters
mixedsettlement The security's settlement date. The security's settlement date is the date after the issue date when the security is traded to the buyer.
mixedmaturity The security's maturity date. The maturity date is the date when the security expires.
mixedissue The security's issue date.
intrate The security's interest rate at date of issue.
intyield The security's annual yield.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9318 of file Functions.php.

References _daysPerYear(), flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$issue = self::flattenSingleValue($issue);
$rate = self::flattenSingleValue($rate);
$yield = self::flattenSingleValue($yield);
$basis = (int) self::flattenSingleValue($basis);
// Validate
if (is_numeric($rate) && is_numeric($yield)) {
if (($rate <= 0) || ($yield <= 0)) {
return self::$_errorCodes['num'];
}
$daysPerYear = self::_daysPerYear(self::YEAR($settlement),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement = self::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
return $daysBetweenIssueAndSettlement;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = self::YEARFRAC($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) {
return $daysBetweenIssueAndMaturity;
}
$daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= $daysPerYear;
return ((100 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate * 100)) /
(1 + (($daysBetweenSettlementAndMaturity / $daysPerYear) * $yield)) -
(($daysBetweenIssueAndSettlement / $daysPerYear) * $rate * 100));
}
return self::$_errorCodes['value'];
} // function PRICEMAT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::PRODUCT ( )
static

Definition at line 626 of file Functions.php.

References flattenArray().

Referenced by GEOMEAN(), and SUBTOTAL().

{
// Return value
$returnValue = null;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = $arg;
} else {
$returnValue *= $arg;
}
}
}
// Return
if (is_null($returnValue)) {
return 0;
}
return $returnValue;
} // function PRODUCT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::PROPERCASE (   $mixedCaseString)
static

PROPERCASE.

Converts a string value to upper case.

Parameters
string$mixedCaseString
Returns
string

Definition at line 8516 of file Functions.php.

References flattenSingleValue().

{
$mixedCaseString = self::flattenSingleValue($mixedCaseString);
if (function_exists('mb_convert_case')) {
return mb_convert_case($mixedCaseString, MB_CASE_TITLE, 'UTF-8');
} else {
return ucwords($mixedCaseString);
}
} // function PROPERCASE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::PV (   $rate = 0,
  $nper = 0,
  $pmt = 0,
  $fv = 0,
  $type = 0 
)
static

PV.

Returns the Present Value of a cash flow with constant payments and interest rate (annuities).

Parameters
float$rateInterest rate per period
int$nperNumber of periods
float$pmtPeriodic payment (annuity)
float$fvFuture Value
int$typePayment type: 0 = at the end of each period, 1 = at the beginning of each period
Returns
float

Definition at line 8679 of file Functions.php.

References $type, and flattenSingleValue().

{
$rate = self::flattenSingleValue($rate);
$nper = self::flattenSingleValue($nper);
// Validate parameters
if ($type != 0 && $type != 1) {
return self::$_errorCodes['num'];
}
// Calculate
if (!is_null($rate) && $rate != 0) {
return (-$pmt * (1 + $rate * $type) * ((pow(1 + $rate, $nper) - 1) / $rate) - $fv) / pow(1 + $rate, $nper);
} else {
return -$fv - $pmt * $nper;
}
} // function PV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::QUARTILE ( )
static

Definition at line 994 of file Functions.php.

References flattenArray(), and PERCENTILE().

{
$aArgs = self::flattenArray(func_get_args());
// Calculate
$entry = floor(array_pop($aArgs));
if ((is_numeric($entry)) && (!is_string($entry))) {
$entry /= 4;
if (($entry < 0) || ($entry > 1)) {
return self::$_errorCodes['num'];
}
return self::PERCENTILE($aArgs,$entry);
}
return self::$_errorCodes['value'];
} // function QUARTILE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::QUOTIENT ( )
static

Definition at line 665 of file Functions.php.

References flattenArray().

{
// Return value
$returnValue = null;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = ($arg == 0) ? 0 : $arg;
} else {
if (($returnValue == 0) || ($arg == 0)) {
$returnValue = 0;
} else {
$returnValue /= $arg;
}
}
}
}
// Return
return intval($returnValue);
} // function QUOTIENT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::RAND (   $min = 0,
  $max = 0 
)
static

RAND.

Parameters
int$minMinimal value
int$maxMaximal value
Returns
int Random number

Definition at line 4746 of file Functions.php.

References flattenSingleValue().

{
if ($min == 0 && $max == 0) {
return (rand(0,10000000)) / 10000000;
} else {
return rand($min, $max);
}
} // function RAND()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::RANK (   $value,
  $valueSet,
  $order = 0 
)
static

RANK.

Returns the rank of a number in a list of numbers.

Parameters
numberThe number whose rank you want to find.
arrayof number An array of, or a reference to, a list of numbers.
mixedOrder to sort the values in the value set
Returns
float

Definition at line 1972 of file Functions.php.

References $key, flattenArray(), and flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$valueSet = self::flattenArray($valueSet);
$order = self::flattenSingleValue($order);
foreach($valueSet as $key => $valueEntry) {
if (!is_numeric($valueEntry)) {
unset($valueSet[$key]);
}
}
if ($order == 0) {
rsort($valueSet,SORT_NUMERIC);
} else {
sort($valueSet,SORT_NUMERIC);
}
$pos = array_search($value,$valueSet);
if ($pos === False) {
return self::$_errorCodes['na'];
}
return ++$pos;
} // function RANK()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::RECEIVED (   $settlement,
  $maturity,
  $investment,
  $discount,
  $basis = 0 
)
static

RECEIVED.

Returns the price per $100 face value of a discounted security.

Parameters
mixedsettlement The security's settlement date. The security settlement date is the date after the issue date when the security is traded to the buyer.
mixedmaturity The security's maturity date. The maturity date is the date when the security expires.
intinvestment The amount invested in the security.
intdiscount The security's discount rate.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9378 of file Functions.php.

References flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$investment = (float) self::flattenSingleValue($investment);
$discount = (float) self::flattenSingleValue($discount);
$basis = (int) self::flattenSingleValue($basis);
// Validate
if ((is_numeric($investment)) && (is_numeric($discount)) && (is_numeric($basis))) {
if (($investment <= 0) || ($discount <= 0)) {
return self::$_errorCodes['num'];
}
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
return $investment / ( 1 - ($discount * $daysBetweenSettlementAndMaturity));
}
return self::$_errorCodes['value'];
} // function RECEIVED()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::REF ( )
static

Definition at line 269 of file Functions.php.

Referenced by PHPExcel_Calculation\_processTokenStack().

{
return self::$_errorCodes['reference'];
} // function REF()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::REPLACE (   $oldText = '',
  $start = 1,
  $chars = null,
  $newText 
)
static

REPLACE.

Parameters
string$valueValue
int$startStart character
int$charsNumber of characters
Returns
string

Definition at line 4998 of file Functions.php.

References $start, flattenSingleValue(), LEFT(), and RIGHT().

{
$oldText = self::flattenSingleValue($oldText);
$chars = self::flattenSingleValue($chars);
$newText = self::flattenSingleValue($newText);
$left = self::LEFT($oldText,$start-1);
$right = self::RIGHT($oldText,self::STRINGLENGTH($oldText)-($start+$chars)+1);
return $left.$newText.$right;
} // function REPLACE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::RETURNSTRING (   $testValue = '')
static

RETURNSTRING.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5017 of file Functions.php.

References flattenSingleValue().

{
$testValue = self::flattenSingleValue($testValue);
if (is_string($testValue)) {
return $testValue;
}
return Null;
} // function RETURNSTRING()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::REVERSE_ATAN2 (   $xCoordinate,
  $yCoordinate 
)
static

Definition at line 517 of file Functions.php.

{
$xCoordinate = (float) self::flattenSingleValue($xCoordinate);
$yCoordinate = (float) self::flattenSingleValue($yCoordinate);
if (($xCoordinate == 0) && ($yCoordinate == 0)) {
return self::$_errorCodes['divisionbyzero'];
}
return atan2($yCoordinate, $xCoordinate);
} // function REVERSE_ATAN2()
static PHPExcel_Calculation_Functions::RIGHT (   $value = '',
  $chars = 1 
)
static

RIGHT.

Parameters
string$valueValue
int$charsNumber of characters
Returns
string

Definition at line 4957 of file Functions.php.

References flattenSingleValue().

Referenced by REPLACE().

{
$value = self::flattenSingleValue($value);
$chars = self::flattenSingleValue($chars);
if ((function_exists('mb_substr')) && (function_exists('mb_strlen'))) {
return mb_substr($value, mb_strlen($value, 'UTF-8') - $chars, $chars, 'UTF-8');
} else {
return substr($value, strlen($value) - $chars);
}
} // function RIGHT()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::ROMAN (   $aValue,
  $style = 0 
)
static

Definition at line 2439 of file Functions.php.

References $t, and _romanCut().

{
$aValue = (integer) self::flattenSingleValue($aValue);
if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
return self::$_errorCodes['value'];
}
if ($aValue == 0) {
return '';
}
$mill = Array('', 'M', 'MM', 'MMM', 'MMMM', 'MMMMM');
$cent = Array('', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM');
$tens = Array('', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC');
$ones = Array('', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX');
$roman = '';
while ($aValue > 5999) {
$roman .= 'M';
$aValue -= 1000;
}
$m = self::_romanCut($aValue, 1000); $aValue %= 1000;
$c = self::_romanCut($aValue, 100); $aValue %= 100;
$t = self::_romanCut($aValue, 10); $aValue %= 10;
return $roman.$mill[$m].$cent[$c].$tens[$t].$ones[$aValue];
} // function ROMAN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ROUNDDOWN (   $number,
  $digits 
)
static

ROUNDDOWN.

Rounds a number down to a specified number of decimal places

Parameters
float$numberNumber to round
int$digitsNumber of digits to which you want to round $number
Returns
float Rounded Number

Definition at line 2764 of file Functions.php.

References flattenSingleValue().

{
$number = self::flattenSingleValue($number);
$digits = self::flattenSingleValue($digits);
if ((is_numeric($number)) && (is_numeric($digits))) {
$significance = pow(10,$digits);
if ($number < 0.0) {
return ceil($number * $significance) / $significance;
} else {
return floor($number * $significance) / $significance;
}
}
return self::$_errorCodes['value'];
} // function ROUNDDOWN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ROUNDUP (   $number,
  $digits 
)
static

ROUNDUP.

Rounds a number up to a specified number of decimal places

Parameters
float$numberNumber to round
int$digitsNumber of digits to which you want to round $number
Returns
float Rounded Number

Definition at line 2739 of file Functions.php.

References flattenSingleValue().

{
$number = self::flattenSingleValue($number);
$digits = self::flattenSingleValue($digits);
if ((is_numeric($number)) && (is_numeric($digits))) {
$significance = pow(10,$digits);
if ($number < 0.0) {
return floor($number * $significance) / $significance;
} else {
return ceil($number * $significance) / $significance;
}
}
return self::$_errorCodes['value'];
} // function ROUNDUP()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::ROW (   $cellAddress = Null)
static

Definition at line 9746 of file Functions.php.

{
if ($cellAddress === Null) {
return 0;
}
foreach($cellAddress as $columnKey => $rowValue) {
foreach($rowValue as $rowKey => $cellValue) {
return $rowKey;
}
}
} // function ROW()
static PHPExcel_Calculation_Functions::RSQ (   $yValues,
  $xValues 
)
static

RSQ.

Returns the square of the Pearson product moment correlation coefficient through data points in known_y's and known_x's.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
Returns
float

Definition at line 2097 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getGoodnessOfFit();
} // function RSQ()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SEARCHINSENSITIVE (   $needle,
  $haystack,
  $offset = 1 
)
static

SEARCHINSENSITIVE.

Parameters
string$needleThe string to look for
string$haystackThe string in which to look
int$offsetOffset within $haystack
Returns
string

Definition at line 4912 of file Functions.php.

References flattenSingleValue().

{
$needle = (string) self::flattenSingleValue($needle);
$haystack = (string) self::flattenSingleValue($haystack);
$offset = self::flattenSingleValue($offset);
if (($offset > 0) && (strlen($haystack) > $offset)) {
if (function_exists('mb_stripos')) {
$pos = mb_stripos($haystack, $needle, --$offset,'UTF-8');
} else {
$pos = stripos($haystack, $needle, --$offset);
}
if ($pos !== false) {
return ++$pos;
}
}
return self::$_errorCodes['value'];
} // function SEARCHINSENSITIVE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SEARCHSENSITIVE (   $needle,
  $haystack,
  $offset = 1 
)
static

SEARCHSENSITIVE.

Parameters
string$needleThe string to look for
string$haystackThe string in which to look
int$offsetOffset within $haystack
Returns
string

Definition at line 4885 of file Functions.php.

References flattenSingleValue().

{
$needle = (string) self::flattenSingleValue($needle);
$haystack = (string) self::flattenSingleValue($haystack);
$offset = self::flattenSingleValue($offset);
if (($offset > 0) && (strlen($haystack) > $offset)) {
if (function_exists('mb_strpos')) {
$pos = mb_strpos($haystack, $needle, --$offset,'UTF-8');
} else {
$pos = strpos($haystack, $needle, --$offset);
}
if ($pos !== false) {
return ++$pos;
}
}
return self::$_errorCodes['value'];
} // function SEARCHSENSITIVE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SECONDOFMINUTE (   $timeValue = 0)
static

SECONDOFMINUTE.

Parameters
long$timeValueExcel time serial value or a standard time string
Returns
int Second

Definition at line 6164 of file Functions.php.

References _getTimeValue(), elseif(), PHPExcel_Shared_Date\ExcelToPHP(), and flattenSingleValue().

{
$timeValue = self::flattenSingleValue($timeValue);
if (!is_numeric($timeValue)) {
if (self::$compatibilityMode == self::COMPATIBILITY_GNUMERIC) {
$testVal = strtok($timeValue,'/-: ');
if (strlen($testVal) < strlen($timeValue)) {
return self::$_errorCodes['value'];
}
}
$timeValue = self::_getTimeValue($timeValue);
if (is_string($timeValue)) {
return self::$_errorCodes['value'];
}
}
// Execute function
if (is_real($timeValue)) {
if ($timeValue >= 1) {
$timeValue = fmod($timeValue,1);
} elseif ($timeValue < 0.0) {
return self::$_errorCodes['num'];
}
$timeValue = PHPExcel_Shared_Date::ExcelToPHP($timeValue);
}
return (int) date('s',$timeValue);
} // function SECONDOFMINUTE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SERIESSUM ( )
static

SERIESSUM.

Returns the sum of a power series

Parameters
float$xInput value to the power series
float$nInitial power to which you want to raise $x
float$mStep by which to increase $n for each term in the series
arrayof mixed Data Series
Returns
float

Definition at line 2924 of file Functions.php.

References $n, $x, and flattenArray().

{
// Return value
$returnValue = 0;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
$x = array_shift($aArgs);
$n = array_shift($aArgs);
$m = array_shift($aArgs);
if ((is_numeric($x)) && (is_numeric($n)) && (is_numeric($m))) {
// Calculate
$i = 0;
foreach($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue += $arg * pow($x,$n + ($m * $i++));
} else {
return self::$_errorCodes['value'];
}
}
// Return
return $returnValue;
}
return self::$_errorCodes['value'];
} // function SERIESSUM()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::setCompatibilityMode (   $compatibilityMode)
static

Definition at line 148 of file Functions.php.

References $compatibilityMode.

{
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
self::$compatibilityMode = $compatibilityMode;
return True;
}
return False;
} // function setCompatibilityMode()
static PHPExcel_Calculation_Functions::setReturnDateType (   $returnDateType)
static

Definition at line 187 of file Functions.php.

Referenced by _getDateValue(), _getTimeValue(), PHPExcel_Writer_Excel5\save(), and PHPExcel_Writer_Excel2007\save().

{
if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
($returnDateType == self::RETURNDATE_EXCEL)) {
self::$ReturnDateType = $returnDateType;
return True;
}
return False;
} // function setReturnDateType()

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::SIGN (   $number)
static

SIGN.

Determines the sign of a number. Returns 1 if the number is positive, zero (0) if the number is 0, and -1 if the number is negative.

Parameters
float$numberNumber to round
Returns
int sign value

Definition at line 2816 of file Functions.php.

References flattenSingleValue().

Referenced by EVEN(), and ODD().

{
$number = self::flattenSingleValue($number);
if (is_numeric($number)) {
if ($number == 0.0) {
return 0;
}
return $number / abs($number);
}
return self::$_errorCodes['value'];
} // function SIGN()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::SKEW ( )
static

SKEW.

Returns the skewness of a distribution. Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending toward more positive values. Negative skewness indicates a distribution with an asymmetric tail extending toward more negative values.

Parameters
arrayData Series
Returns
float

Definition at line 4680 of file Functions.php.

References AVERAGE(), flattenArray(), and STDEV().

{
$aArgs = self::flattenArray(func_get_args());
$mean = self::AVERAGE($aArgs);
$stdDev = self::STDEV($aArgs);
$count = $summer = 0;
// Loop through arguments
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summer += pow((($arg - $mean) / $stdDev),3) ;
++$count;
}
}
// Return
if ($count > 2) {
return $summer * ($count / (($count-1) * ($count-2)));
}
return self::$_errorCodes['divisionbyzero'];
} // function SKEW()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SLN (   $cost,
  $salvage,
  $life 
)
static

SLN.

Returns the straight-line depreciation of an asset for one period

Parameters
costInitial cost of the asset
salvageValue at the end of the depreciation
lifeNumber of periods over which the asset is depreciated
Returns
float

Definition at line 9576 of file Functions.php.

References flattenSingleValue().

{
$cost = self::flattenSingleValue($cost);
$salvage = self::flattenSingleValue($salvage);
$life = self::flattenSingleValue($life);
// Calculate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life))) {
if ($life < 0) {
return self::$_errorCodes['num'];
}
return ($cost - $salvage) / $life;
}
return self::$_errorCodes['value'];
} // function SLN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SLOPE (   $yValues,
  $xValues 
)
static

SLOPE.

Returns the slope of the linear regression line through data points in known_y's and known_x's.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
Returns
float

Definition at line 2126 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getSlope();
} // function SLOPE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SMALL ( )
static

Definition at line 784 of file Functions.php.

References $n, COUNT(), and flattenArray().

{
$aArgs = self::flattenArray(func_get_args());
// Calculate
$n = array_pop($aArgs);
if ((is_numeric($n)) && (!is_string($n))) {
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$count = self::COUNT($mArgs);
$n = floor(--$n);
if (($n < 0) || ($n >= $count) || ($count == 0)) {
return self::$_errorCodes['num'];
}
sort($mArgs);
return $mArgs[$n];
}
return self::$_errorCodes['value'];
} // function SMALL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SQRTPI (   $number)
static

SQRTPI.

Returns the square root of (number * pi).

Parameters
float$numberNumber
Returns
float Square Root of Number * Pi

Definition at line 2531 of file Functions.php.

References flattenSingleValue().

{
$number = self::flattenSingleValue($number);
if (is_numeric($number)) {
if ($number < 0) {
return self::$_errorCodes['num'];
}
return sqrt($number * pi()) ;
}
return self::$_errorCodes['value'];
} // function SQRTPI()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::STANDARDIZE (   $value,
  $mean,
  $stdDev 
)
static

STANDARDIZE.

Returns a normalized value from a distribution characterized by mean and standard_dev.

Parameters
float$valueValue to normalize
float$meanMean Value
float$stdDevStandard Deviation
Returns
float Standardized value

Definition at line 2963 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$mean = self::flattenSingleValue($mean);
$stdDev = self::flattenSingleValue($stdDev);
if ((is_numeric($value)) && (is_numeric($mean)) && (is_numeric($stdDev))) {
if ($stdDev <= 0) {
return self::$_errorCodes['num'];
}
return ($value - $mean) / $stdDev ;
}
return self::$_errorCodes['value'];
} // function STANDARDIZE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::STATEMENT_IF (   $condition = true,
  $returnIfTrue = 0,
  $returnIfFalse = False 
)
static

STATEMENT_IF.

Returns one value if a condition you specify evaluates to TRUE and another value if it evaluates to FALSE.

Excel Function: IF(condition[,returnIfTrue[,returnIfFalse]])

Condition is any value or expression that can be evaluated to TRUE or FALSE. For example, A10=100 is a logical expression; if the value in cell A10 is equal to 100, the expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE. This argument can use any comparison calculation operator. ReturnIfTrue is the value that is returned if condition evaluates to TRUE. For example, if this argument is the text string "Within budget" and the condition argument evaluates to TRUE, then the IF function returns the text "Within budget" If condition is TRUE and ReturnIfTrue is blank, this argument returns 0 (zero). To display the word TRUE, use the logical value TRUE for this argument. ReturnIfTrue can be another formula. ReturnIfFalse is the value that is returned if condition evaluates to FALSE. For example, if this argument is the text string "Over budget" and the condition argument evaluates to FALSE, then the IF function returns the text "Over budget". If condition is FALSE and ReturnIfFalse is omitted, then the logical value FALSE is returned. If condition is FALSE and ReturnIfFalse is blank, then the value 0 (zero) is returned. ReturnIfFalse can be another formula.

Parameters
mixed$conditionCondition to evaluate
mixed$returnIfTrueValue to return when condition is true
mixed$returnIfFalseValue to return when condition is false
Returns
mixed The value of returnIfTrue or returnIfFalse determined by condition

Definition at line 472 of file Functions.php.

References flattenSingleValue().

Referenced by STATEMENT_IFERROR().

{
$condition = self::flattenSingleValue($condition);
$returnIfTrue = self::flattenSingleValue($returnIfTrue);
$returnIfFalse = self::flattenSingleValue($returnIfFalse);
if (is_null($returnIfTrue)) { $returnIfTrue = 0; }
if (is_null($returnIfFalse)) { $returnIfFalse = 0; }
return ($condition ? $returnIfTrue : $returnIfFalse);
} // function STATEMENT_IF()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::STATEMENT_IFERROR (   $value = '',
  $errorpart = '' 
)
static

STATEMENT_IFERROR.

Parameters
mixed$valueValue to check , is also value when no error
mixed$errorpartValue when error
Returns
mixed

Definition at line 490 of file Functions.php.

References STATEMENT_IF().

{
return self::STATEMENT_IF(self::IS_ERROR($value), $errorpart, $value);
} // function STATEMENT_IFERROR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::STDEV ( )
static

Definition at line 1619 of file Functions.php.

References AVERAGE(), and flattenArray().

Referenced by KURT(), SKEW(), and SUBTOTAL().

{
// Return value
$returnValue = null;
$aMean = self::AVERAGE(func_get_args());
if (!is_null($aMean)) {
$aArgs = self::flattenArray(func_get_args());
$aCount = -1;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (($aCount > 0) && ($returnValue > 0)) {
return sqrt($returnValue / $aCount);
}
}
return self::$_errorCodes['divisionbyzero'];
} // function STDEV()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::STDEVA ( )
static

Definition at line 1662 of file Functions.php.

References AVERAGEA(), elseif(), and flattenArray().

{
// Return value
$returnValue = null;
$aMean = self::AVERAGEA(func_get_args());
if (!is_null($aMean)) {
$aArgs = self::flattenArray(func_get_args());
$aCount = -1;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (($aCount > 0) && ($returnValue > 0)) {
return sqrt($returnValue / $aCount);
}
}
return self::$_errorCodes['divisionbyzero'];
} // function STDEVA()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::STDEVP ( )
static

Definition at line 1710 of file Functions.php.

References AVERAGE(), and flattenArray().

Referenced by SUBTOTAL().

{
// Return value
$returnValue = null;
$aMean = self::AVERAGE(func_get_args());
if (!is_null($aMean)) {
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (($aCount > 0) && ($returnValue > 0)) {
return sqrt($returnValue / $aCount);
}
}
return self::$_errorCodes['divisionbyzero'];
} // function STDEVP()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::STDEVPA ( )
static

Definition at line 1753 of file Functions.php.

References AVERAGEA(), elseif(), and flattenArray().

{
// Return value
$returnValue = null;
$aMean = self::AVERAGEA(func_get_args());
if (!is_null($aMean)) {
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
if (is_null($returnValue)) {
$returnValue = pow(($arg - $aMean),2);
} else {
$returnValue += pow(($arg - $aMean),2);
}
++$aCount;
}
}
// Return
if (($aCount > 0) && ($returnValue > 0)) {
return sqrt($returnValue / $aCount);
}
}
return self::$_errorCodes['divisionbyzero'];
} // function STDEVPA()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::STEYX (   $yValues,
  $xValues 
)
static

STEYX.

Returns the standard error of the predicted y-value for each x in the regression.

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
Returns
float

Definition at line 2155 of file Functions.php.

References _checkTrendArray(), trendClass\calculate(), elseif(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$yValues = self::_checkTrendArray($yValues);
$yValueCount = count($yValues);
$xValues = self::_checkTrendArray($xValues);
$xValueCount = count($xValues);
if (($yValueCount == 0) || ($yValueCount != $xValueCount)) {
return self::$_errorCodes['na'];
} elseif ($yValueCount == 1) {
return self::$_errorCodes['divisionbyzero'];
}
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues);
return $bestFitLinear->getStdevOfResiduals();
} // function STEYX()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::STRINGLENGTH (   $value = '')
static

STRINGLENGTH.

Parameters
string$valueValue
int$charsNumber of characters
Returns
string

Definition at line 4866 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
if (function_exists('mb_strlen')) {
return mb_strlen($value, 'UTF-8');
} else {
return strlen($value);
}
} // function STRINGLENGTH()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SUBTOTAL ( )
static

SUBTOTAL.

Returns a subtotal in a list or database.

Parameters
intthe number 1 to 11 that specifies which function to use in calculating subtotals within a list.
arrayof mixed Data Series
Returns
float

Definition at line 2476 of file Functions.php.

References AVERAGE(), COUNT(), COUNTA(), flattenArray(), MAX(), MIN(), PRODUCT(), STDEV(), STDEVP(), SUM(), VARFunc(), and VARP().

{
$aArgs = self::flattenArray(func_get_args());
// Calculate
$subtotal = array_shift($aArgs);
if ((is_numeric($subtotal)) && (!is_string($subtotal))) {
switch($subtotal) {
case 1 :
return self::AVERAGE($aArgs);
break;
case 2 :
return self::COUNT($aArgs);
break;
case 3 :
return self::COUNTA($aArgs);
break;
case 4 :
return self::MAX($aArgs);
break;
case 5 :
return self::MIN($aArgs);
break;
case 6 :
return self::PRODUCT($aArgs);
break;
case 7 :
return self::STDEV($aArgs);
break;
case 8 :
return self::STDEVP($aArgs);
break;
case 9 :
return self::SUM($aArgs);
break;
case 10 :
return self::VARFunc($aArgs);
break;
case 11 :
return self::VARP($aArgs);
break;
}
}
return self::$_errorCodes['value'];
} // function SUBTOTAL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SUM ( )
static

Definition at line 564 of file Functions.php.

References flattenArray().

Referenced by SUBTOTAL().

{
// Return value
$returnValue = 0;
// Loop through the arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue += $arg;
}
}
// Return
return $returnValue;
} // function SUM()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::SUMIF (   $aArgs,
  $condition,
  $sumArgs = array() 
)
static

Definition at line 1159 of file Functions.php.

References $key, PHPExcel_Calculation\_wrapResult(), flattenArray(), and PHPExcel_Calculation\getInstance().

{
// Return value
$returnValue = 0;
$aArgs = self::flattenArray($aArgs);
$sumArgs = self::flattenArray($sumArgs);
if (count($sumArgs) == 0) {
$sumArgs = $aArgs;
}
if (!in_array($condition{0},array('>', '<', '='))) {
if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
$condition = '='.$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)) {
// Is it a value within our criteria
$returnValue += $sumArgs[$key];
}
}
// Return
return $returnValue;
} // function SUMIF()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SUMSQ ( )
static

Definition at line 595 of file Functions.php.

References flattenArray().

{
// Return value
$returnValue = 0;
// Loop trough arguments
$aArgs = self::flattenArray(func_get_args());
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$returnValue += pow($arg,2);
}
}
// Return
return $returnValue;
} // function SUMSQ()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SUMX2MY2 (   $matrixData1,
  $matrixData2 
)
static

SUMX2MY2.

Parameters
mixed$valueValue to check
Returns
float

Definition at line 10171 of file Functions.php.

References $result, and flattenArray().

{
$array1 = self::flattenArray($matrixData1);
$array2 = self::flattenArray($matrixData2);
$count1 = count($array1);
$count2 = count($array2);
if ($count1 < $count2) {
$count = $count1;
} else {
$count = $count2;
}
$result = 0;
for ($i = 0; $i < $count; ++$i) {
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
$result += ($array1[$i] * $array1[$i]) - ($array2[$i] * $array2[$i]);
}
}
return $result;
} // function SUMX2MY2()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SUMX2PY2 (   $matrixData1,
  $matrixData2 
)
static

SUMX2PY2.

Parameters
mixed$valueValue to check
Returns
float

Definition at line 10200 of file Functions.php.

References $result, and flattenArray().

{
$array1 = self::flattenArray($matrixData1);
$array2 = self::flattenArray($matrixData2);
$count1 = count($array1);
$count2 = count($array2);
if ($count1 < $count2) {
$count = $count1;
} else {
$count = $count2;
}
$result = 0;
for ($i = 0; $i < $count; ++$i) {
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
$result += ($array1[$i] * $array1[$i]) + ($array2[$i] * $array2[$i]);
}
}
return $result;
} // function SUMX2PY2()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SUMXMY2 (   $matrixData1,
  $matrixData2 
)
static

SUMXMY2.

Parameters
mixed$valueValue to check
Returns
float

Definition at line 10229 of file Functions.php.

References $result, and flattenArray().

{
$array1 = self::flattenArray($matrixData1);
$array2 = self::flattenArray($matrixData2);
$count1 = count($array1);
$count2 = count($array2);
if ($count1 < $count2) {
$count = $count1;
} else {
$count = $count2;
}
$result = 0;
for ($i = 0; $i < $count; ++$i) {
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) {
$result += ($array1[$i] - $array2[$i]) * ($array1[$i] - $array2[$i]);
}
}
return $result;
} // function SUMXMY2()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::SYD (   $cost,
  $salvage,
  $life,
  $period 
)
static

SYD.

Returns the sum-of-years' digits depreciation of an asset for a specified period.

Parameters
costInitial cost of the asset
salvageValue at the end of the depreciation
lifeNumber of periods over which the asset is depreciated
periodPeriod
Returns
float

Definition at line 10004 of file Functions.php.

References flattenSingleValue().

{
$cost = self::flattenSingleValue($cost);
$salvage = self::flattenSingleValue($salvage);
$life = self::flattenSingleValue($life);
$period = self::flattenSingleValue($period);
// Calculate
if ((is_numeric($cost)) && (is_numeric($salvage)) && (is_numeric($life)) && (is_numeric($period))) {
if (($life < 1) || ($salvage < $life) || ($period > $life)) {
return self::$_errorCodes['num'];
}
return (($cost - $salvage) * ($life - $period + 1) * 2) / ($life * ($life + 1));
}
return self::$_errorCodes['value'];
} // function SYD()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TBILLEQ (   $settlement,
  $maturity,
  $discount 
)
static

TBILLEQ.

Returns the bond-equivalent yield for a Treasury bill.

Parameters
mixedsettlement The Treasury bill's settlement date. The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
mixedmaturity The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.
intdiscount The Treasury bill's discount rate.
Returns
float

Definition at line 9455 of file Functions.php.

References flattenSingleValue(), TBILLPRICE(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$discount = self::flattenSingleValue($discount);
// Use TBILLPRICE for validation
$testValue = self::TBILLPRICE($settlement, $maturity, $discount);
if (is_string($testValue)) {
return $testValue;
}
if (is_string($maturity = self::_getDateValue($maturity))) {
return self::$_errorCodes['value'];
}
++$maturity;
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity);
$daysBetweenSettlementAndMaturity *= 360;
return (365 * $discount) / (360 - ($discount * ($daysBetweenSettlementAndMaturity)));
} // function TBILLEQ()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TBILLPRICE (   $settlement,
  $maturity,
  $discount 
)
static

TBILLPRICE.

Returns the yield for a Treasury bill.

Parameters
mixedsettlement The Treasury bill's settlement date. The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
mixedmaturity The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.
intdiscount The Treasury bill's discount rate.
Returns
float

Definition at line 9490 of file Functions.php.

References flattenSingleValue(), and YEARFRAC().

Referenced by TBILLEQ().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$discount = self::flattenSingleValue($discount);
if (is_string($maturity = self::_getDateValue($maturity))) {
return self::$_errorCodes['value'];
}
++$maturity;
// Validate
if (is_numeric($discount)) {
if ($discount <= 0) {
return self::$_errorCodes['num'];
}
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= 360;
if ($daysBetweenSettlementAndMaturity > 360) {
return self::$_errorCodes['num'];
}
$price = 100 * (1 - (($discount * $daysBetweenSettlementAndMaturity) / 360));
if ($price <= 0) {
return self::$_errorCodes['num'];
}
return $price;
}
return self::$_errorCodes['value'];
} // function TBILLPRICE()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::TBILLYIELD (   $settlement,
  $maturity,
  $price 
)
static

TBILLYIELD.

Returns the yield for a Treasury bill.

Parameters
mixedsettlement The Treasury bill's settlement date. The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
mixedmaturity The Treasury bill's maturity date. The maturity date is the date when the Treasury bill expires.
intprice The Treasury bill's price per $100 face value.
Returns
float

Definition at line 9537 of file Functions.php.

References flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$price = self::flattenSingleValue($price);
// Validate
if (is_numeric($price)) {
if ($price <= 0) {
return self::$_errorCodes['num'];
}
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= 360;
// Sometimes we need to add 1, sometimes not. I haven't yet worked out the rule which determines this.
++$daysBetweenSettlementAndMaturity;
if ($daysBetweenSettlementAndMaturity > 360) {
return self::$_errorCodes['num'];
}
return ((100 - $price) / $price) * (360 / $daysBetweenSettlementAndMaturity);
}
return self::$_errorCodes['value'];
} // function TBILLYIELD()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TDIST (   $value,
  $degrees,
  $tails 
)
static

TDIST.

Returns the probability of Student's T distribution.

Parameters
float$valueValue for the function
float$degreesdegrees of freedom
float$tailsnumber of tails (1 or 2)
Returns
float

Definition at line 4460 of file Functions.php.

References flattenSingleValue().

Referenced by TINV().

{
$value = self::flattenSingleValue($value);
$degrees = floor(self::flattenSingleValue($degrees));
$tails = floor(self::flattenSingleValue($tails));
if ((is_numeric($value)) && (is_numeric($degrees)) && (is_numeric($tails))) {
if (($value < 0) || ($degrees < 1) || ($tails < 1) || ($tails > 2)) {
return self::$_errorCodes['num'];
}
// tdist, which finds the probability that corresponds to a given value
// of t with k degrees of freedom. This algorithm is translated from a
// pascal function on p81 of "Statistical Computing in Pascal" by D
// Cooke, A H Craven & G M Clark (1985: Edward Arnold (Pubs.) Ltd:
// London). The above Pascal algorithm is itself a translation of the
// fortran algoritm "AS 3" by B E Cooper of the Atlas Computer
// Laboratory as reported in (among other places) "Applied Statistics
// Algorithms", editied by P Griffiths and I D Hill (1985; Ellis
// Horwood Ltd.; W. Sussex, England).
// $ta = 2 / pi();
$ta = 0.636619772367581;
$tterm = $degrees;
$ttheta = atan2($value,sqrt($tterm));
$tc = cos($ttheta);
$ts = sin($ttheta);
$tsum = 0;
if (($degrees % 2) == 1) {
$ti = 3;
$tterm = $tc;
} else {
$ti = 2;
$tterm = 1;
}
$tsum = $tterm;
while ($ti < $degrees) {
$tterm *= $tc * $tc * ($ti - 1) / $ti;
$tsum += $tterm;
$ti += 2;
}
$tsum *= $ts;
if (($degrees % 2) == 1) { $tsum = $ta * ($tsum + $ttheta); }
$tValue = 0.5 * (1 + $tsum);
if ($tails == 1) {
return 1 - abs($tValue);
} else {
return 1 - abs((1 - $tValue) - $tValue);
}
}
return self::$_errorCodes['value'];
} // function TDIST()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::TEXTFORMAT (   $value,
  $format 
)
static

TEXTFORMAT.

Parameters
mixed$valueValue to check
Returns
boolean

Definition at line 5054 of file Functions.php.

References flattenSingleValue(), and PHPExcel_Style_NumberFormat\toFormattedString().

{
$value = self::flattenSingleValue($value);
$format = self::flattenSingleValue($format);
return (string) PHPExcel_Style_NumberFormat::toFormattedString($value,$format);
} // function TEXTFORMAT()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TIME (   $hour = 0,
  $minute = 0,
  $second = 0 
)
static

TIME.

Parameters
long$hour
long$minute
long$second
Returns
mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, depending on the value of the ReturnDateType flag

Definition at line 5334 of file Functions.php.

References PHPExcel_Shared_Date\CALENDAR_WINDOWS_1900, elseif(), PHPExcel_Shared_Date\ExcelToPHP(), flattenSingleValue(), PHPExcel_Shared_Date\FormattedPHPToExcel(), and PHPExcel_Shared_Date\getExcelCalendar().

{
$hour = self::flattenSingleValue($hour);
$minute = self::flattenSingleValue($minute);
$second = self::flattenSingleValue($second);
if ($hour == '') { $hour = 0; }
if ($minute == '') { $minute = 0; }
if ($second == '') { $second = 0; }
if ((!is_numeric($hour)) || (!is_numeric($minute)) || (!is_numeric($second))) {
return self::$_errorCodes['value'];
}
$hour = (integer) $hour;
$minute = (integer) $minute;
$second = (integer) $second;
if ($second < 0) {
$minute += floor($second / 60);
$second = 60 - abs($second % 60);
if ($second == 60) { $second = 0; }
} elseif ($second >= 60) {
$minute += floor($second / 60);
$second = $second % 60;
}
if ($minute < 0) {
$hour += floor($minute / 60);
$minute = 60 - abs($minute % 60);
if ($minute == 60) { $minute = 0; }
} elseif ($minute >= 60) {
$hour += floor($minute / 60);
$minute = $minute % 60;
}
if ($hour > 23) {
$hour = $hour % 24;
} elseif ($hour < 0) {
return self::$_errorCodes['num'];
}
// Execute function
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : $date = 0;
$date = 1;
}
return (float) PHPExcel_Shared_Date::FormattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
break;
case self::RETURNDATE_PHP_NUMERIC : return (integer) PHPExcel_Shared_Date::ExcelToPHP(PHPExcel_Shared_Date::FormattedPHPToExcel(1970, 1, 1, $hour-1, $minute, $second)); // -2147468400; // -2147472000 + 3600
break;
case self::RETURNDATE_PHP_OBJECT : $dayAdjust = 0;
if ($hour < 0) {
$dayAdjust = floor($hour / 24);
$hour = 24 - abs($hour % 24);
if ($hour == 24) { $hour = 0; }
} elseif ($hour >= 24) {
$dayAdjust = floor($hour / 24);
$hour = $hour % 24;
}
$phpDateObject = new DateTime('1900-01-01 '.$hour.':'.$minute.':'.$second);
if ($dayAdjust != 0) {
$phpDateObject->modify($dayAdjust.' days');
}
return $phpDateObject;
break;
}
} // function TIME()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TIMEVALUE (   $timeValue)
static

TIMEVALUE.

Parameters
string$timeValue
Returns
mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, depending on the value of the ReturnDateType flag

Definition at line 5504 of file Functions.php.

References PHPExcel_Shared_Date\ExcelToPHP(), flattenSingleValue(), and PHPExcel_Shared_Date\FormattedPHPToExcel().

Referenced by _getTimeValue().

{
$timeValue = self::flattenSingleValue($timeValue);
if ((($PHPDateArray = date_parse($timeValue)) !== False) && ($PHPDateArray['error_count'] == 0)) {
if (self::$compatibilityMode == self::COMPATIBILITY_OPENOFFICE) {
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel($PHPDateArray['year'],$PHPDateArray['month'],$PHPDateArray['day'],$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']);
} else {
$excelDateValue = PHPExcel_Shared_Date::FormattedPHPToExcel(1900,1,1,$PHPDateArray['hour'],$PHPDateArray['minute'],$PHPDateArray['second']) - 1;
}
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : return (float) $excelDateValue;
break;
case self::RETURNDATE_PHP_NUMERIC : return (integer) $phpDateValue = PHPExcel_Shared_Date::ExcelToPHP($excelDateValue+25569) - 3600;;
break;
case self::RETURNDATE_PHP_OBJECT : return new DateTime('1900-01-01 '.$PHPDateArray['hour'].':'.$PHPDateArray['minute'].':'.$PHPDateArray['second']);
break;
}
}
return self::$_errorCodes['value'];
} // function TIMEVALUE()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::TINV (   $probability,
  $degrees 
)
static

TINV.

Returns the one-tailed probability of the chi-squared distribution.

Parameters
float$probabilityProbability for the function
float$degreesdegrees of freedom
Returns
float

Definition at line 4522 of file Functions.php.

References $error, $result, $x, elseif(), flattenSingleValue(), MAX_ITERATIONS, PRECISION, and TDIST().

{
$probability = self::flattenSingleValue($probability);
$degrees = floor(self::flattenSingleValue($degrees));
if ((is_numeric($probability)) && (is_numeric($degrees))) {
$xLo = 100;
$xHi = 0;
$maxIteration = 100;
$x = $xNew = 1;
$dx = 1;
$i = 0;
while ((abs($dx) > PRECISION) && ($i++ < MAX_ITERATIONS)) {
// Apply Newton-Raphson step
$result = self::TDIST($x, $degrees, 2);
$error = $result - $probability;
if ($error == 0.0) {
$dx = 0;
} elseif ($error < 0.0) {
$xLo = $x;
} else {
$xHi = $x;
}
// Avoid division by zero
if ($result != 0.0) {
$dx = $error / $result;
$xNew = $x - $dx;
}
// If the NR fails to converge (which for example may be the
// case if the initial guess is too rough) we apply a bisection
// step to determine a more narrow interval around the root.
if (($xNew < $xLo) || ($xNew > $xHi) || ($result == 0.0)) {
$xNew = ($xLo + $xHi) / 2;
$dx = $xNew - $x;
}
$x = $xNew;
}
if ($i == MAX_ITERATIONS) {
return self::$_errorCodes['na'];
}
return round($x,12);
}
return self::$_errorCodes['value'];
} // function TINV()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TRANSPOSE (   $matrixData)
static

TRANSPOSE.

Parameters
array$matrixDataA matrix of values
Returns
array

Unlike the Excel TRANSPOSE function, which will only work on a single row or column, this function will transpose a full matrix.

Definition at line 10029 of file Functions.php.

References $row.

{
$returnMatrix = array();
if (!is_array($matrixData)) { $matrixData = array(array($matrixData)); }
$column = 0;
foreach($matrixData as $matrixRow) {
$row = 0;
foreach($matrixRow as $matrixCell) {
$returnMatrix[$column][$row] = $matrixCell;
++$row;
}
++$column;
}
return $returnMatrix;
} // function TRANSPOSE()
static PHPExcel_Calculation_Functions::TREND (   $yValues,
  $xValues = array(),
  $newValues = array(),
  $const = True 
)
static

TREND.

Returns values along a linear trend

Parameters
arrayof mixed Data Series Y
arrayof mixed Data Series X
arrayof mixed Values of X for which we want to find Y
booleanA logical value specifying whether to force the intersect to equal 0.
Returns
array of float

Definition at line 2383 of file Functions.php.

References trendClass\calculate(), flattenArray(), and trendClass\TREND_LINEAR.

{
$yValues = self::flattenArray($yValues);
$xValues = self::flattenArray($xValues);
$newValues = self::flattenArray($newValues);
$const = (boolean) self::flattenSingleValue($const);
$bestFitLinear = trendClass::calculate(trendClass::TREND_LINEAR,$yValues,$xValues,$const);
if (count($newValues) == 0) {
$newValues = $bestFitLinear->getXValues();
}
$returnArray = array();
foreach($newValues as $xValue) {
$returnArray[0][] = $bestFitLinear->getValueOfYForX($xValue);
}
return $returnArray;
} // function TREND()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TRIMMEAN ( )
static

Definition at line 1576 of file Functions.php.

References AVERAGE(), and flattenArray().

{
$aArgs = self::flattenArray(func_get_args());
// Calculate
$percent = array_pop($aArgs);
if ((is_numeric($percent)) && (!is_string($percent))) {
if (($percent < 0) || ($percent > 1)) {
return self::$_errorCodes['num'];
}
$mArgs = array();
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$mArgs[] = $arg;
}
}
$discard = floor(self::COUNT($mArgs) * $percent / 2);
sort($mArgs);
for ($i=0; $i < $discard; ++$i) {
array_pop($mArgs);
array_shift($mArgs);
}
return self::AVERAGE($mArgs);
}
return self::$_errorCodes['value'];
} // function TRIMMEAN()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TRIMNONPRINTABLE (   $stringValue = '')
static

TRIMNONPRINTABLE.

Parameters
mixed$valueValue to check
Returns
string

Definition at line 5086 of file Functions.php.

References flattenSingleValue().

{
$stringValue = self::flattenSingleValue($stringValue);
if (self::$_invalidChars == Null) {
self::$_invalidChars = range(chr(0),chr(31));
}
if (is_string($stringValue) || is_numeric($stringValue)) {
return str_replace(self::$_invalidChars,'',trim($stringValue,"\x00..\x1F"));
}
return Null;
} // function TRIMNONPRINTABLE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TRIMSPACES (   $stringValue = '')
static

TRIMSPACES.

Parameters
mixed$valueValue to check
Returns
string

Definition at line 5068 of file Functions.php.

References flattenSingleValue().

{
$stringValue = self::flattenSingleValue($stringValue);
if (is_string($stringValue) || is_numeric($stringValue)) {
return trim(preg_replace('/ +/',' ',$stringValue));
}
return Null;
} // function TRIMSPACES()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::TRUNC (   $value = 0,
  $number_digits = 0 
)
static

TRUNC.

Truncates value to the number of fractional digits by number_digits.

Parameters
float$value
int$number_digits
Returns
float Truncated value

Definition at line 6302 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$number_digits = self::flattenSingleValue($number_digits);
// Validate parameters
if ($number_digits < 0) {
return self::$_errorCodes['value'];
}
// Truncate
if ($number_digits > 0) {
$value = $value * pow(10, $number_digits);
}
$value = intval($value);
if ($number_digits > 0) {
$value = $value / pow(10, $number_digits);
}
// Return
return $value;
} // function TRUNC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::UPPERCASE (   $mixedCaseString)
static

UPPERCASE.

Converts a string value to upper case.

Parameters
string$mixedCaseString
Returns
string

Definition at line 8497 of file Functions.php.

References flattenSingleValue().

{
$mixedCaseString = self::flattenSingleValue($mixedCaseString);
if (function_exists('mb_convert_case')) {
return mb_convert_case($mixedCaseString, MB_CASE_UPPER, 'UTF-8');
} else {
return strtoupper($mixedCaseString);
}
} // function UPPERCASE()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::VARA ( )
static

Definition at line 1842 of file Functions.php.

References elseif(), and flattenArray().

{
// Return value
$returnValue = self::$_errorCodes['divisionbyzero'];
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
// Return
if ($aCount > 1) {
$summerA = $summerA * $aCount;
$summerB = ($summerB * $summerB);
$returnValue = ($summerA - $summerB) / ($aCount * ($aCount - 1));
}
return $returnValue;
} // function VARA()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::VARFunc ( )
static

Definition at line 1801 of file Functions.php.

References flattenArray().

Referenced by SUBTOTAL().

{
// Return value
$returnValue = self::$_errorCodes['divisionbyzero'];
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
// Return
if ($aCount > 1) {
$summerA = $summerA * $aCount;
$summerB = ($summerB * $summerB);
$returnValue = ($summerA - $summerB) / ($aCount * ($aCount - 1));
}
return $returnValue;
} // function VARFunc()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::VARP ( )
static

Definition at line 1888 of file Functions.php.

References flattenArray().

Referenced by SUBTOTAL().

{
// Return value
$returnValue = self::$_errorCodes['divisionbyzero'];
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) {
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
// Return
if ($aCount > 0) {
$summerA = $summerA * $aCount;
$summerB = ($summerB * $summerB);
$returnValue = ($summerA - $summerB) / ($aCount * $aCount);
}
return $returnValue;
} // function VARP()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::VARPA ( )
static

Definition at line 1929 of file Functions.php.

References elseif(), and flattenArray().

{
// Return value
$returnValue = self::$_errorCodes['divisionbyzero'];
$summerA = $summerB = 0;
// Loop through arguments
$aArgs = self::flattenArray(func_get_args());
$aCount = 0;
foreach ($aArgs as $arg) {
// Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
if (is_bool($arg)) {
$arg = (integer) $arg;
} elseif (is_string($arg)) {
$arg = 0;
}
$summerA += ($arg * $arg);
$summerB += $arg;
++$aCount;
}
}
// Return
if ($aCount > 0) {
$summerA = $summerA * $aCount;
$summerB = ($summerB * $summerB);
$returnValue = ($summerA - $summerB) / ($aCount * $aCount);
}
return $returnValue;
} // function VARPA()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::VERSION ( )
static

VERSION.

Returns
string Version information

Definition at line 5264 of file Functions.php.

{
return 'PHPExcel 1.7.0, 2009-08-10';
} // function VERSION()
static PHPExcel_Calculation_Functions::VLOOKUP (   $lookup_value,
  $lookup_array,
  $index_number,
  $not_exact_match = true 
)
static

VLOOKUP The VLOOKUP function searches for value in the left-most column of lookup_array and returns the value in the same row based on the index_number.

Parameters
lookup_valueThe value that you want to match in lookup_array
lookup_arrayThe range of cells being searched
index_numberThe column number in table_array from which the matching value must be returned. The first column is 1.
not_exact_matchDetermines if you are looking for an exact match based on lookup_value.
Returns
mixed The value of the found cell

Definition at line 10261 of file Functions.php.

{
// index_number must be greater than or equal to 1
if ($index_number < 1) {
return self::$_errorCodes['value'];
}
// index_number must be less than or equal to the number of columns in lookup_array
if ($index_number > count($lookup_array)) {
return self::$_errorCodes['reference'];
}
// re-index lookup_array with numeric keys starting at 1
array_unshift($lookup_array, array());
$lookup_array = array_slice(array_values($lookup_array), 1, count($lookup_array), true);
// look for an exact match
$row_number = array_search($lookup_value, $lookup_array[1]);
// if an exact match is required, we have what we need to return an appropriate response
if ($not_exact_match == false) {
if ($row_number === false) {
return self::$_errorCodes['na'];
} else {
return $lookup_array[$index_number][$row_number];
}
}
// TODO: The VLOOKUP spec in Excel states that, at this point, we should search for
// the highest value that is less than lookup_value. However, documentation on how string
// values should be treated here is sparse.
return self::$_errorCodes['na'];
} // function VLOOKUP()
static PHPExcel_Calculation_Functions::WEEKOFYEAR (   $dateValue = 1,
  $method = 1 
)
static

WEEKOFYEAR.

Parameters
long$dateValueExcel date serial value or a standard date string
boolean$methodWeek begins on Sunday or Monday
Returns
int Week Number

Definition at line 6022 of file Functions.php.

References $method, elseif(), PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenSingleValue().

{
$dateValue = self::flattenSingleValue($dateValue);
$method = floor(self::flattenSingleValue($method));
if (!is_numeric($method)) {
return self::$_errorCodes['value'];
} elseif (($method < 1) || ($method > 2)) {
return self::$_errorCodes['num'];
}
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
$dayOfYear = $PHPDateObject->format('z');
$dow = $PHPDateObject->format('w');
$PHPDateObject->modify('-'.$dayOfYear.' days');
$dow = $PHPDateObject->format('w');
$daysInFirstWeek = 7 - (($dow + (2 - $method)) % 7);
$dayOfYear -= $daysInFirstWeek;
$weekOfYear = ceil($dayOfYear / 7) + 1;
return (int) $weekOfYear;
} // function WEEKOFYEAR()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::WEIBULL (   $value,
  $alpha,
  $beta,
  $cumulative 
)
static

WEIBULL.

Returns the Weibull distribution. Use this distribution in reliability analysis, such as calculating a device's mean time to failure.

Parameters
float$value
float$alphaAlpha Parameter
float$betaBeta Parameter
boolean$cumulative
Returns
float

Definition at line 4648 of file Functions.php.

References flattenSingleValue().

{
$value = self::flattenSingleValue($value);
$alpha = self::flattenSingleValue($alpha);
$beta = self::flattenSingleValue($beta);
if ((is_numeric($value)) && (is_numeric($alpha)) && (is_numeric($beta))) {
if (($value < 0) || ($alpha <= 0) || ($beta <= 0)) {
return self::$_errorCodes['num'];
}
if ((is_numeric($cumulative)) || (is_bool($cumulative))) {
if ($cumulative) {
return 1 - exp(0 - pow($value / $beta,$alpha));
} else {
return ($alpha / pow($beta,$alpha)) * pow($value,$alpha - 1) * exp(0 - pow($value / $beta,$alpha));
}
}
}
return self::$_errorCodes['value'];
} // function WEIBULL()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::WORKDAY (   $startDate,
  $endDays 
)
static

WORKDAY.

Parameters
mixedStart date
mixednumber of days for adjustment
arrayof mixed Optional Date Series
Returns
long Interval between the dates

Definition at line 5873 of file Functions.php.

References DAYOFWEEK(), PHPExcel_Shared_Date\ExcelToPHP(), PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenArray().

{
$dateArgs = self::flattenArray(func_get_args());
array_shift($dateArgs);
array_shift($dateArgs);
if (is_string($startDate = self::_getDateValue($startDate))) {
return self::$_errorCodes['value'];
}
if (!is_numeric($endDays)) {
return self::$_errorCodes['value'];
}
$endDate = (float) $startDate + (floor($endDays / 5) * 7) + ($endDays % 5);
if ($endDays < 0) {
$endDate += 7;
}
$endDoW = self::DAYOFWEEK($endDate,3);
if ($endDoW >= 5) {
if ($endDays >= 0) {
$endDate += (7 - $endDoW);
} else {
$endDate -= ($endDoW - 5);
}
}
// Test any extra holiday parameters
if (count($dateArgs) > 0) {
$holidayCountedArray = $holidayDates = array();
foreach ($dateArgs as $holidayDate) {
if (is_string($holidayDate = self::_getDateValue($holidayDate))) {
return self::$_errorCodes['value'];
}
$holidayDates[] = $holidayDate;
}
if ($endDays >= 0) {
sort($holidayDates, SORT_NUMERIC);
} else {
rsort($holidayDates, SORT_NUMERIC);
}
foreach ($holidayDates as $holidayDate) {
if ($endDays >= 0) {
if (($holidayDate >= $startDate) && ($holidayDate <= $endDate)) {
if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {
++$endDate;
$holidayCountedArray[] = $holidayDate;
}
}
} else {
if (($holidayDate <= $startDate) && ($holidayDate >= $endDate)) {
if ((self::DAYOFWEEK($holidayDate,2) < 6) && (!in_array($holidayDate,$holidayCountedArray))) {
--$endDate;
$holidayCountedArray[] = $holidayDate;
}
}
}
$endDoW = self::DAYOFWEEK($endDate,3);
if ($endDoW >= 5) {
if ($endDays >= 0) {
$endDate += (7 - $endDoW);
} else {
$endDate -= ($endDoW - 5);
}
}
}
}
switch (self::getReturnDateType()) {
case self::RETURNDATE_EXCEL : return (float) $endDate;
break;
case self::RETURNDATE_PHP_NUMERIC : return (integer) PHPExcel_Shared_Date::ExcelToPHP($endDate);
break;
case self::RETURNDATE_PHP_OBJECT : return PHPExcel_Shared_Date::ExcelToPHPObject($endDate);
break;
}
} // function WORKDAY()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::YEAR (   $dateValue = 1)
static

YEAR.

Parameters
long$dateValueExcel date serial value or a standard date string
Returns
int Year

Definition at line 6076 of file Functions.php.

References PHPExcel_Shared_Date\ExcelToPHPObject(), and flattenSingleValue().

Referenced by YEARFRAC().

{
$dateValue = self::flattenSingleValue($dateValue);
if (is_string($dateValue = self::_getDateValue($dateValue))) {
return self::$_errorCodes['value'];
}
// Execute function
$PHPDateObject = PHPExcel_Shared_Date::ExcelToPHPObject($dateValue);
return (int) $PHPDateObject->format('Y');
} // function YEAR()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::YEARFRAC (   $startDate = 0,
  $endDate = 0,
  $method = 0 
)
static

YEARFRAC.

Calculates the fraction of the year represented by the number of whole days between two dates (the start_date and the end_date). Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or obligations to assign to a specific term.

Parameters
mixed$startDateExcel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string
mixed$endDateExcel date serial value (float), PHP date timestamp (integer) or date object, or a standard date string
integer$methodMethod used for the calculation 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float fraction of the year

Definition at line 5764 of file Functions.php.

References $method, DATEDIF(), DAYS360(), flattenSingleValue(), and YEAR().

Referenced by ACCRINT(), ACCRINTM(), DISC(), INTRATE(), PRICEDISC(), PRICEMAT(), RECEIVED(), TBILLEQ(), TBILLPRICE(), TBILLYIELD(), YIELDDISC(), and YIELDMAT().

{
$startDate = self::flattenSingleValue($startDate);
$endDate = self::flattenSingleValue($endDate);
if (is_string($startDate = self::_getDateValue($startDate))) {
return self::$_errorCodes['value'];
}
if (is_string($endDate = self::_getDateValue($endDate))) {
return self::$_errorCodes['value'];
}
if ((is_numeric($method)) && (!is_string($method))) {
switch($method) {
case 0 :
return self::DAYS360($startDate,$endDate) / 360;
break;
case 1 :
$startYear = self::YEAR($startDate);
$endYear = self::YEAR($endDate);
$leapDay = 0;
if (self::_isLeapYear($startYear) || self::_isLeapYear($endYear)) {
$leapDay = 1;
}
return self::DATEDIF($startDate,$endDate) / (365 + $leapDay);
break;
case 2 :
return self::DATEDIF($startDate,$endDate) / 360;
break;
case 3 :
return self::DATEDIF($startDate,$endDate) / 365;
break;
case 4 :
return self::DAYS360($startDate,$endDate,True) / 360;
break;
}
}
return self::$_errorCodes['value'];
} // function YEARFRAC()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Calculation_Functions::YIELDDISC (   $settlement,
  $maturity,
  $price,
  $redemption,
  $basis = 0 
)
static

YIELDDISC.

Returns the annual yield of a security that pays interest at maturity.

Parameters
mixedsettlement The security's settlement date. The security's settlement date is the date after the issue date when the security is traded to the buyer.
mixedmaturity The security's maturity date. The maturity date is the date when the security expires.
intprice The security's price per $100 face value.
intredemption The security's redemption value per $100 face value.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9672 of file Functions.php.

References _daysPerYear(), flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$price = self::flattenSingleValue($price);
$redemption = self::flattenSingleValue($redemption);
$basis = (int) self::flattenSingleValue($basis);
// Validate
if (is_numeric($price) && is_numeric($redemption)) {
if (($price <= 0) || ($redemption <= 0)) {
return self::$_errorCodes['num'];
}
$daysPerYear = self::_daysPerYear(self::YEAR($settlement),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity,$basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= $daysPerYear;
return (($redemption - $price) / $price) * ($daysPerYear / $daysBetweenSettlementAndMaturity);
}
return self::$_errorCodes['value'];
} // function YIELDDISC()

+ Here is the call graph for this function:

static PHPExcel_Calculation_Functions::YIELDMAT (   $settlement,
  $maturity,
  $issue,
  $rate,
  $price,
  $basis = 0 
)
static

YIELDMAT.

Returns the annual yield of a security that pays interest at maturity.

Parameters
mixedsettlement The security's settlement date. The security's settlement date is the date after the issue date when the security is traded to the buyer.
mixedmaturity The security's maturity date. The maturity date is the date when the security expires.
mixedissue The security's issue date.
intrate The security's interest rate at date of issue.
intprice The security's price per $100 face value.
intbasis The type of day count to use. 0 or omitted US (NASD) 30/360 1 Actual/actual 2 Actual/360 3 Actual/365 4 European 30/360
Returns
float

Definition at line 9612 of file Functions.php.

References _daysPerYear(), flattenSingleValue(), and YEARFRAC().

{
$settlement = self::flattenSingleValue($settlement);
$maturity = self::flattenSingleValue($maturity);
$issue = self::flattenSingleValue($issue);
$rate = self::flattenSingleValue($rate);
$price = self::flattenSingleValue($price);
$basis = (int) self::flattenSingleValue($basis);
// Validate
if (is_numeric($rate) && is_numeric($price)) {
if (($rate <= 0) || ($price <= 0)) {
return self::$_errorCodes['num'];
}
$daysPerYear = self::_daysPerYear(self::YEAR($settlement),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement = self::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
return $daysBetweenIssueAndSettlement;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
$daysBetweenIssueAndMaturity = self::YEARFRAC($issue, $maturity, $basis);
if (!is_numeric($daysBetweenIssueAndMaturity)) {
return $daysBetweenIssueAndMaturity;
}
$daysBetweenIssueAndMaturity *= $daysPerYear;
$daysBetweenSettlementAndMaturity = self::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
return $daysBetweenSettlementAndMaturity;
}
$daysBetweenSettlementAndMaturity *= $daysPerYear;
return ((1 + (($daysBetweenIssueAndMaturity / $daysPerYear) * $rate) - (($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) /
(($price / 100) + (($daysBetweenIssueAndSettlement / $daysPerYear) * $rate))) *
($daysPerYear / $daysBetweenSettlementAndMaturity);
}
return self::$_errorCodes['value'];
} // function YIELDMAT()

+ Here is the call graph for this function:

Field Documentation

PHPExcel_Calculation_Functions::$_conversionMultipliers
staticprivate
Initial value:
array( 'Y' => array( 'multiplier' => 1E24, 'name' => 'yotta' ),
'Z' => array( 'multiplier' => 1E21, 'name' => 'zetta' ),
'E' => array( 'multiplier' => 1E18, 'name' => 'exa' ),
'P' => array( 'multiplier' => 1E15, 'name' => 'peta' ),
'T' => array( 'multiplier' => 1E12, 'name' => 'tera' ),
'G' => array( 'multiplier' => 1E9, 'name' => 'giga' ),
'M' => array( 'multiplier' => 1E6, 'name' => 'mega' ),
'k' => array( 'multiplier' => 1E3, 'name' => 'kilo' ),
'h' => array( 'multiplier' => 1E2, 'name' => 'hecto' ),
'e' => array( 'multiplier' => 1E1, 'name' => 'deka' ),
'd' => array( 'multiplier' => 1E-1, 'name' => 'deci' ),
'c' => array( 'multiplier' => 1E-2, 'name' => 'centi' ),
'm' => array( 'multiplier' => 1E-3, 'name' => 'milli' ),
'u' => array( 'multiplier' => 1E-6, 'name' => 'micro' ),
'n' => array( 'multiplier' => 1E-9, 'name' => 'nano' ),
'p' => array( 'multiplier' => 1E-12, 'name' => 'pico' ),
'f' => array( 'multiplier' => 1E-15, 'name' => 'femto' ),
'a' => array( 'multiplier' => 1E-18, 'name' => 'atto' ),
'z' => array( 'multiplier' => 1E-21, 'name' => 'zepto' ),
'y' => array( 'multiplier' => 1E-24, 'name' => 'yocto' )
)

Definition at line 7381 of file Functions.php.

Referenced by getConversionMultipliers().

PHPExcel_Calculation_Functions::$_conversionUnits
staticprivate

Definition at line 7316 of file Functions.php.

PHPExcel_Calculation_Functions::$_errorCodes
staticprivate
Initial value:
array( 'null' => '#NULL!',
'divisionbyzero' => '#DIV/0!',
'value' => '#VALUE!',
'reference' => '#REF!',
'name' => '#NAME?',
'num' => '#NUM!',
'na' => '#N/A',
'gettingdata' => '#GETTING_DATA'
)

Definition at line 125 of file Functions.php.

PHPExcel_Calculation_Functions::$_invalidChars = Null
staticprivate

Definition at line 5078 of file Functions.php.

PHPExcel_Calculation_Functions::$_logBetaCache_p = 0.0
staticprivate

Definition at line 3466 of file Functions.php.

PHPExcel_Calculation_Functions::$_logBetaCache_q = 0.0
staticprivate

Definition at line 3467 of file Functions.php.

PHPExcel_Calculation_Functions::$_logBetaCache_result = 0.0
staticprivate

Definition at line 3468 of file Functions.php.

Referenced by _logBeta().

PHPExcel_Calculation_Functions::$_logGammaCache_result = 0.0
staticprivate

logGamma function

Version
1.1
Author
Jaco van Kooten

Original author was Jaco van Kooten. Ported to PHP by Paul Meagher.

The natural logarithm of the gamma function.
Based on public domain NETLIB (Fortran) code by W. J. Cody and L. Stoltz
Applied Mathematics Division
Argonne National Laboratory
Argonne, IL 60439

References:

  1. W. J. Cody and K. E. Hillstrom, 'Chebyshev Approximations for the Natural Logarithm of the Gamma Function,' Math. Comp. 21, 1967, pp. 198-203.
  2. K. E. Hillstrom, ANL/AMD Program ANLC366S, DGAMMA/DLGAMA, May, 1969.
  3. Hart, Et. Al., Computer Approximations, Wiley and sons, New York, 1968.

From the original documentation:

This routine calculates the LOG(GAMMA) function for a positive real argument X. Computation is based on an algorithm outlined in references 1 and 2. The program uses rational functions that theoretically approximate LOG(GAMMA) to at least 18 significant decimal digits. The approximation for X > 12 is from reference 3, while approximations for X < 12.0 are similar to those in reference 1, but are unpublished. The accuracy achieved depends on the arithmetic system, the compiler, the intrinsic functions, and proper selection of the machine-dependent constants.

Error returns:
The program returns the value XINF for X .LE. 0.0 or when overflow would occur. The computation is believed to be free of underflow and overflow.

Returns
MAX_VALUE for x < 0.0 or when overflow would occur, i.e. x > 2.55E305

Definition at line 3586 of file Functions.php.

Referenced by _logGamma().

PHPExcel_Calculation_Functions::$_logGammaCache_x = 0.0
staticprivate

Definition at line 3587 of file Functions.php.

PHPExcel_Calculation_Functions::$_one_sqrtpi = 0.564189583547756287
staticprivate

Definition at line 8420 of file Functions.php.

PHPExcel_Calculation_Functions::$_rel_error = 1E-15
staticprivate

Definition at line 8361 of file Functions.php.

Referenced by _erfVal().

PHPExcel_Calculation_Functions::$_two_sqrtpi = 1.128379167095512574
staticprivate

Definition at line 8360 of file Functions.php.

PHPExcel_Calculation_Functions::$_unitConversions
staticprivate

Definition at line 7403 of file Functions.php.

PHPExcel_Calculation_Functions::$compatibilityMode = self::COMPATIBILITY_EXCEL
staticprivate

Definition at line 109 of file Functions.php.

Referenced by getCompatibilityMode(), and setCompatibilityMode().

PHPExcel_Calculation_Functions::$ReturnDateType = self::RETURNDATE_EXCEL
staticprivate

Definition at line 117 of file Functions.php.

Referenced by getReturnDateType().

const PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL = 'Excel'

constants

Definition at line 94 of file Functions.php.

const PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC = 'Gnumeric'

Definition at line 95 of file Functions.php.

const PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc'

Definition at line 96 of file Functions.php.

const PHPExcel_Calculation_Functions::RETURNDATE_EXCEL = 'E'

Definition at line 100 of file Functions.php.

Referenced by PHPExcel_Writer_Excel5\save(), and PHPExcel_Writer_Excel2007\save().

const PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC = 'P'

Definition at line 98 of file Functions.php.

const PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT = 'O'

Definition at line 99 of file Functions.php.


The documentation for this class was generated from the following file: