当前路径:Classes/PHPExcel/Calculation/MathTrig.php <?php /** PHPExcel root directory */ if (!defined('PHPEXCEL_ROOT')) { /** * @ignore */ define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } /** * PHPExcel_Calculation_MathTrig * * Copyright (c) 2006 - 2015 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel * @package PHPExcel_Calculation * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ class PHPExcel_Calculation_MathTrig { // // Private method to return an array of the factors of the input value // private static function factors($value) { $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 (!empty($factorArray)) { rsort($factorArray); return $factorArray; } else { return array((integer) $value); } } private static function romanCut($num, $n) { return ($num - ($num % $n ) ) / $n; } /** * ATAN2 * * This function calculates the arc tangent of the two variables x and y. It is similar to * calculating the arc tangent of y ÷ x, except that the signs of both arguments are used * to determine the quadrant of the result. * The arctangent is the angle from the x-axis to a line containing the origin (0, 0) and a * point with coordinates (xCoordinate, yCoordinate). The angle is given in radians between * -pi and pi, excluding -pi. * * Note that the Excel ATAN2() function accepts its arguments in the reverse order to the standard * PHP atan2() function, so we need to reverse them here before calling the PHP atan() function. * * Excel Function: * ATAN2(xCoordinate,yCoordinate) * * @access public * @category Mathematical and Trigonometric Functions * @param float $xCoordinate The x-coordinate of the point. * @param float $yCoordinate The y-coordinate of the point. * @return float The inverse tangent of the specified x- and y-coordinates. */ public static function ATAN2($xCoordinate = null, $yCoordinate = null) { $xCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($xCoordinate); $yCoordinate = PHPExcel_Calculation_Functions::flattenSingleValue($yCoordinate); $xCoordinate = ($xCoordinate !== null) ? $xCoordinate : 0.0; $yCoordinate = ($yCoordinate !== null) ? $yCoordinate : 0.0; if (((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) && ((is_numeric($yCoordinate))) || (is_bool($yCoordinate))) { $xCoordinate = (float) $xCoordinate; $yCoordinate = (float) $yCoordinate; if (($xCoordinate == 0) && ($yCoordinate == 0)) { return PHPExcel_Calculation_Functions::DIV0(); } return atan2($yCoordinate, $xCoordinate); } return PHPExcel_Calculation_Functions::VALUE(); } /** * CEILING * * Returns number rounded up, away from zero, to the nearest multiple of significance. * For example, if you want to avoid using pennies in your prices and your product is * priced at $4.42, use the formula =CEILING(4.42,0.05) to round prices up to the * nearest nickel. * * Excel Function: * CEILING(number[,significance]) * * @access public * @category Mathematical and Trigonometric Functions * @param float $number The number you want to round. * @param float $significance The multiple to which you want to round. * @return float Rounded Number */ public static function CEILING($number, $significance = null) { $number = PHPExcel_Calculation_Functions::flattenSingleValue($number); $significance = PHPExcel_Calculation_Functions::flattenSingleValue($significance); if ((is_null($significance)) && (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC)) { $significance = $number / abs($number); } if ((is_numeric($number)) && (is_numeric($significance))) { if (($number == 0.0 ) || ($significance == 0.0)) { return 0.0; } elseif (self::SIGN($number) == self::SIGN($significance)) { return ceil($number / $significance) * $significance; } else { return PHPExcel_Calculation_Functions::NaN(); } } return PHPExcel_Calculation_Functions::VALUE(); } /** * 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. * * Excel Function: * COMBIN(numObjs,numInSet) * * @access public * @category Mathematical and Trigonometric Functions * @param int $numObjs Number of different objects * @param int $numInSet Number of objects in each combination * @return int Number of combinations */ public static function COMBIN($numObjs, $numInSet) { $numObjs = PHPExcel_Calculation_Functions::flattenSingleValue($numObjs); $numInSet = PHPExcel_Calculation_Functions::flattenSingleValue($numInSet); if ((is_numeric($numObjs)) && (is_numeric($numInSet))) { if ($numObjs < $numInSet) { return PHPExcel_Calculation_Functions::NaN(); } elseif ($numInSet < 0) { return PHPExcel_Calculation_Functions::NaN(); } return round(self::FACT($numObjs) / self::FACT($numObjs - $numInSet)) / self::FACT($numInSet); } return PHPExcel_Calculation_Functions::VALUE(); } /** * EVEN * * Returns number rounded up to the nearest even integer. * You can use this function for processing items that come in twos. For example, * a packing crate accepts rows of one or two items. The crate is full when * the number of items, rounded up to the nearest two, matches the crate's * capacity. * * Excel Function: * EVEN(number) * * @access public * @category Mathematical and Trigonometric Functions * @param float $number Number to round * @return int Rounded Number */ public static function EVEN($number) { $number = PHPExcel_Calculation_Functions::flattenSingleValue($number); if (is_null($number)) { return 0; } elseif (is_bool($number)) { $number = (int) $number; } if (is_numeric($number)) { $significance = 2 * self::SIGN($number); return (int) self::CEILING($number, $significance); } return PHPExcel_Calculation_Functions::VALUE(); } /** * FACT * * Returns the factorial of a number. * The factorial of a number is equal to 1*2*3*...* number. * * Excel Function: * FACT(factVal) * * @access public * @category Mathematical and Trigonometric Functions * @param float $factVal Factorial Value * @return int Factorial */ public static function FACT($factVal) { $factVal = PHPExcel_Calculation_Functions::flattenSingleValue($factVal); if (is_numeric($factVal)) { if ($factVal < 0) { return PHPExcel_Calculation_Functions::NaN(); } $factLoop = floor($factVal); if (PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC) { if ($factVal > $factLoop) { return PHPExcel_Calculation_Functions::NaN(); } } $factorial = 1; while ($factLoop > 1) { $factorial *= $factLoop--; } return $factorial ; } return PHPExcel_Calculation_Functions::VALUE(); } /** * FACTDOUBLE * * Returns the double factorial of a number. * * Excel Fu...
完整源码文件,请先购买后再查看
相关源码
- 通用后台管理系统2023-09-25
- ASPNET公交查询系统2023-09-21
- ASPNET MVC婚纱宣传官网2023-09-21
- DSKMS在线培训开源视频管理系统 V3.1.22023-09-16
- 基于SPRINGBOOT医院管理系统2023-09-12
- ASP.NET的社区志愿服务平台2023-09-11
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号