mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-29 08:46:03 +03:00
PSR2 Fixes
This commit is contained in:
parent
1bf5ea414b
commit
f827a25af2
File diff suppressed because it is too large
Load Diff
@ -45,7 +45,8 @@ class PHPExcel_Shared_PasswordHasher
|
|||||||
* @param string $pPassword Password to hash
|
* @param string $pPassword Password to hash
|
||||||
* @return string Hashed password
|
* @return string Hashed password
|
||||||
*/
|
*/
|
||||||
public static function hashPassword($pPassword = '') {
|
public static function hashPassword($pPassword = '')
|
||||||
|
{
|
||||||
$password = 0x0000;
|
$password = 0x0000;
|
||||||
$charPos = 1; // char position
|
$charPos = 1; // char position
|
||||||
|
|
||||||
|
@ -93,10 +93,11 @@ class PHPExcel_Shared_String
|
|||||||
/**
|
/**
|
||||||
* Build control characters array
|
* Build control characters array
|
||||||
*/
|
*/
|
||||||
private static function _buildControlCharacters() {
|
private static function _buildControlCharacters()
|
||||||
|
{
|
||||||
for ($i = 0; $i <= 31; ++$i) {
|
for ($i = 0; $i <= 31; ++$i) {
|
||||||
if ($i != 9 && $i != 10 && $i != 13) {
|
if ($i != 9 && $i != 10 && $i != 13) {
|
||||||
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
|
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
|
||||||
$replace = chr($i);
|
$replace = chr($i);
|
||||||
self::$_controlCharacters[$find] = $replace;
|
self::$_controlCharacters[$find] = $replace;
|
||||||
}
|
}
|
||||||
@ -316,10 +317,7 @@ class PHPExcel_Shared_String
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CUSTOM: IBM AIX iconv() does not work
|
// CUSTOM: IBM AIX iconv() does not work
|
||||||
if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX')
|
if (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
|
||||||
&& defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
|
|
||||||
&& defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
|
|
||||||
{
|
|
||||||
self::$_isIconvEnabled = false;
|
self::$_isIconvEnabled = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -329,7 +327,8 @@ class PHPExcel_Shared_String
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function buildCharacterSets() {
|
public static function buildCharacterSets()
|
||||||
|
{
|
||||||
if (empty(self::$_controlCharacters)) {
|
if (empty(self::$_controlCharacters)) {
|
||||||
self::_buildControlCharacters();
|
self::_buildControlCharacters();
|
||||||
}
|
}
|
||||||
@ -352,8 +351,9 @@ class PHPExcel_Shared_String
|
|||||||
* @param string $value Value to unescape
|
* @param string $value Value to unescape
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function ControlCharacterOOXML2PHP($value = '') {
|
public static function ControlCharacterOOXML2PHP($value = '')
|
||||||
return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
|
{
|
||||||
|
return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -370,8 +370,9 @@ class PHPExcel_Shared_String
|
|||||||
* @param string $value Value to escape
|
* @param string $value Value to escape
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function ControlCharacterPHP2OOXML($value = '') {
|
public static function ControlCharacterPHP2OOXML($value = '')
|
||||||
return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
|
{
|
||||||
|
return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -402,7 +403,8 @@ class PHPExcel_Shared_String
|
|||||||
* @param string $value
|
* @param string $value
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function IsUTF8($value = '') {
|
public static function IsUTF8($value = '')
|
||||||
|
{
|
||||||
return $value === '' || preg_match('/^./su', $value) === 1;
|
return $value === '' || preg_match('/^./su', $value) === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +415,8 @@ class PHPExcel_Shared_String
|
|||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function FormatNumber($value) {
|
public static function FormatNumber($value)
|
||||||
|
{
|
||||||
if (is_float($value)) {
|
if (is_float($value)) {
|
||||||
return str_replace(',', '.', $value);
|
return str_replace(',', '.', $value);
|
||||||
}
|
}
|
||||||
@ -524,16 +527,27 @@ class PHPExcel_Shared_String
|
|||||||
* @author vadik56
|
* @author vadik56
|
||||||
*/
|
*/
|
||||||
public static function utf16_decode($str, $bom_be = TRUE) {
|
public static function utf16_decode($str, $bom_be = TRUE) {
|
||||||
if ( strlen($str) < 2 ) return $str;
|
if (strlen($str) < 2) {
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
$c0 = ord($str{0});
|
$c0 = ord($str{0});
|
||||||
$c1 = ord($str{1});
|
$c1 = ord($str{1});
|
||||||
if ( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
|
if ($c0 == 0xfe && $c1 == 0xff) {
|
||||||
elseif ( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
|
$str = substr($str,2);
|
||||||
|
} elseif ($c0 == 0xff && $c1 == 0xfe) {
|
||||||
|
$str = substr($str,2);
|
||||||
|
$bom_be = false;
|
||||||
|
}
|
||||||
$len = strlen($str);
|
$len = strlen($str);
|
||||||
$newstr = '';
|
$newstr = '';
|
||||||
for($i=0;$i<$len;$i+=2) {
|
for($i=0;$i<$len;$i+=2) {
|
||||||
if ( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
|
if ($bom_be) {
|
||||||
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
|
$val = ord($str{$i}) << 4;
|
||||||
|
$val += ord($str{$i+1});
|
||||||
|
} else {
|
||||||
|
$val = ord($str{$i+1}) << 4;
|
||||||
|
$val += ord($str{$i});
|
||||||
|
}
|
||||||
$newstr .= ($val == 0x228) ? "\n" : chr($val);
|
$newstr .= ($val == 0x228) ? "\n" : chr($val);
|
||||||
}
|
}
|
||||||
return $newstr;
|
return $newstr;
|
||||||
@ -634,7 +648,7 @@ class PHPExcel_Shared_String
|
|||||||
{
|
{
|
||||||
# Split at all position not after the start: ^
|
# Split at all position not after the start: ^
|
||||||
# and not before the end: $
|
# and not before the end: $
|
||||||
return preg_split('/(?<!^)(?!$)/u', $string );
|
return preg_split('/(?<!^)(?!$)/u', $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -667,7 +681,8 @@ class PHPExcel_Shared_String
|
|||||||
* @param string &$operand string value to test
|
* @param string &$operand string value to test
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function convertToNumberIfFraction(&$operand) {
|
public static function convertToNumberIfFraction(&$operand)
|
||||||
|
{
|
||||||
if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
|
if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
|
||||||
$sign = ($match[1] == '-') ? '-' : '+';
|
$sign = ($match[1] == '-') ? '-' : '+';
|
||||||
$fractionFormula = '='.$sign.$match[2].$sign.$match[3];
|
$fractionFormula = '='.$sign.$match[2].$sign.$match[3];
|
||||||
@ -802,8 +817,9 @@ class PHPExcel_Shared_String
|
|||||||
*/
|
*/
|
||||||
public static function testStringAsNumeric($value)
|
public static function testStringAsNumeric($value)
|
||||||
{
|
{
|
||||||
if (is_numeric($value))
|
if (is_numeric($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
|
}
|
||||||
$v = floatval($value);
|
$v = floatval($value);
|
||||||
return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
|
return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@ class PHPExcel_Shared_TimeZone
|
|||||||
* @param string $timezone Time zone (e.g. 'Europe/London')
|
* @param string $timezone Time zone (e.g. 'Europe/London')
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function _validateTimeZone($timezone) {
|
public static function _validateTimeZone($timezone)
|
||||||
|
{
|
||||||
if (in_array($timezone, DateTimeZone::listIdentifiers())) {
|
if (in_array($timezone, DateTimeZone::listIdentifiers())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -63,7 +64,8 @@ class PHPExcel_Shared_TimeZone
|
|||||||
* @param string $timezone Time zone (e.g. 'Europe/London')
|
* @param string $timezone Time zone (e.g. 'Europe/London')
|
||||||
* @return boolean Success or failure
|
* @return boolean Success or failure
|
||||||
*/
|
*/
|
||||||
public static function setTimeZone($timezone) {
|
public static function setTimeZone($timezone)
|
||||||
|
{
|
||||||
if (self::_validateTimezone($timezone)) {
|
if (self::_validateTimezone($timezone)) {
|
||||||
self::$_timezone = $timezone;
|
self::$_timezone = $timezone;
|
||||||
return true;
|
return true;
|
||||||
@ -77,7 +79,8 @@ class PHPExcel_Shared_TimeZone
|
|||||||
*
|
*
|
||||||
* @return string Timezone (e.g. 'Europe/London')
|
* @return string Timezone (e.g. 'Europe/London')
|
||||||
*/
|
*/
|
||||||
public static function getTimeZone() {
|
public static function getTimeZone()
|
||||||
|
{
|
||||||
return self::$_timezone;
|
return self::$_timezone;
|
||||||
} // function getTimezone()
|
} // function getTimezone()
|
||||||
|
|
||||||
@ -89,7 +92,8 @@ class PHPExcel_Shared_TimeZone
|
|||||||
* @param integer $timestamp PHP date/time value for finding the current transition
|
* @param integer $timestamp PHP date/time value for finding the current transition
|
||||||
* @return array The current transition details
|
* @return array The current transition details
|
||||||
*/
|
*/
|
||||||
private static function _getTimezoneTransitions($objTimezone, $timestamp) {
|
private static function _getTimezoneTransitions($objTimezone, $timestamp)
|
||||||
|
{
|
||||||
$allTransitions = $objTimezone->getTransitions();
|
$allTransitions = $objTimezone->getTransitions();
|
||||||
$transitions = array();
|
$transitions = array();
|
||||||
foreach ($allTransitions as $key => $transition) {
|
foreach ($allTransitions as $key => $transition) {
|
||||||
@ -114,7 +118,8 @@ class PHPExcel_Shared_TimeZone
|
|||||||
* @return integer Number of seconds for timezone adjustment
|
* @return integer Number of seconds for timezone adjustment
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public static function getTimeZoneAdjustment($timezone, $timestamp) {
|
public static function getTimeZoneAdjustment($timezone, $timestamp)
|
||||||
|
{
|
||||||
if ($timezone !== null) {
|
if ($timezone !== null) {
|
||||||
if (!self::_validateTimezone($timezone)) {
|
if (!self::_validateTimezone($timezone)) {
|
||||||
throw new PHPExcel_Exception("Invalid timezone " . $timezone);
|
throw new PHPExcel_Exception("Invalid timezone " . $timezone);
|
||||||
|
@ -33,7 +33,6 @@ if (!defined('DEBUGMODE_ENABLED')) {
|
|||||||
define('DEBUGMODE_ENABLED', false);
|
define('DEBUGMODE_ENABLED', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Shared_XMLWriter
|
* PHPExcel_Shared_XMLWriter
|
||||||
*
|
*
|
||||||
@ -41,7 +40,8 @@ if (!defined('DEBUGMODE_ENABLED')) {
|
|||||||
* @package PHPExcel_Shared
|
* @package PHPExcel_Shared
|
||||||
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Shared_XMLWriter extends XMLWriter {
|
class PHPExcel_Shared_XMLWriter extends XMLWriter
|
||||||
|
{
|
||||||
/** Temporary storage method */
|
/** Temporary storage method */
|
||||||
const STORAGE_MEMORY = 1;
|
const STORAGE_MEMORY = 1;
|
||||||
const STORAGE_DISK = 2;
|
const STORAGE_DISK = 2;
|
||||||
@ -59,14 +59,15 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
|
|||||||
* @param int $pTemporaryStorage Temporary storage location
|
* @param int $pTemporaryStorage Temporary storage location
|
||||||
* @param string $pTemporaryStorageFolder Temporary storage folder
|
* @param string $pTemporaryStorageFolder Temporary storage folder
|
||||||
*/
|
*/
|
||||||
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = NULL) {
|
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = null) {
|
||||||
// Open temporary storage
|
// Open temporary storage
|
||||||
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
if ($pTemporaryStorage == self::STORAGE_MEMORY) {
|
||||||
$this->openMemory();
|
$this->openMemory();
|
||||||
} else {
|
} else {
|
||||||
// Create temporary filename
|
// Create temporary filename
|
||||||
if ($pTemporaryStorageFolder === NULL)
|
if ($pTemporaryStorageFolder === null) {
|
||||||
$pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
|
$pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
|
||||||
|
}
|
||||||
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
|
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
|
||||||
|
|
||||||
// Open storage
|
// Open storage
|
||||||
@ -85,7 +86,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
|
|||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
public function __destruct() {
|
public function __destruct()
|
||||||
|
{
|
||||||
// Unlink temporary files
|
// Unlink temporary files
|
||||||
if ($this->_tempFileName != '') {
|
if ($this->_tempFileName != '') {
|
||||||
@unlink($this->_tempFileName);
|
@unlink($this->_tempFileName);
|
||||||
@ -97,7 +99,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
|
|||||||
*
|
*
|
||||||
* @return $data
|
* @return $data
|
||||||
*/
|
*/
|
||||||
public function getData() {
|
public function getData()
|
||||||
|
{
|
||||||
if ($this->_tempFileName == '') {
|
if ($this->_tempFileName == '') {
|
||||||
return $this->outputMemory(true);
|
return $this->outputMemory(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,10 +92,7 @@ class PHPExcel_Shared_ZipArchive
|
|||||||
fwrite($handle, $contents);
|
fwrite($handle, $contents);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
|
|
||||||
$res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"],
|
$res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"], PCLZIP_OPT_REMOVE_PATH, $this->_tempDir, PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]);
|
||||||
PCLZIP_OPT_REMOVE_PATH, $this->_tempDir,
|
|
||||||
PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]
|
|
||||||
);
|
|
||||||
if ($res == 0) {
|
if ($res == 0) {
|
||||||
throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true));
|
throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true));
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,12 @@
|
|||||||
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
class PHPExcel_Shared_ZipStreamWrapper {
|
class PHPExcel_Shared_ZipStreamWrapper
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Internal ZipAcrhive
|
* Internal ZipAcrhive
|
||||||
*
|
*
|
||||||
* @var ZipAcrhive
|
* @var ZipArchive
|
||||||
*/
|
*/
|
||||||
private $_archive;
|
private $_archive;
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Best_Fit
|
* PHPExcel_Best_Fit
|
||||||
*
|
*
|
||||||
@ -75,7 +74,7 @@ class PHPExcel_Best_Fit
|
|||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
**/
|
**/
|
||||||
protected $_adjustToZero = False;
|
protected $_adjustToZero = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Y-value series of best-fit values
|
* Y-value series of best-fit values
|
||||||
@ -113,205 +112,207 @@ class PHPExcel_Best_Fit
|
|||||||
protected $_Yoffset = 0;
|
protected $_Yoffset = 0;
|
||||||
|
|
||||||
|
|
||||||
public function getError() {
|
public function getError()
|
||||||
|
{
|
||||||
return $this->_error;
|
return $this->_error;
|
||||||
} // function getBestFitType()
|
} // function getBestFitType()
|
||||||
|
|
||||||
|
|
||||||
public function getBestFitType() {
|
public function getBestFitType()
|
||||||
|
{
|
||||||
return $this->_bestFitType;
|
return $this->_bestFitType;
|
||||||
} // function getBestFitType()
|
} // function getBestFitType()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
*
|
*
|
||||||
* @param float $xValue X-Value
|
* @param float $xValue X-Value
|
||||||
* @return float Y-Value
|
* @return float Y-Value
|
||||||
*/
|
*/
|
||||||
public function getValueOfYForX($xValue) {
|
public function getValueOfYForX($xValue)
|
||||||
return False;
|
{
|
||||||
|
return false;
|
||||||
} // function getValueOfYForX()
|
} // function getValueOfYForX()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
*
|
*
|
||||||
* @param float $yValue Y-Value
|
* @param float $yValue Y-Value
|
||||||
* @return float X-Value
|
* @return float X-Value
|
||||||
*/
|
*/
|
||||||
public function getValueOfXForY($yValue) {
|
public function getValueOfXForY($yValue)
|
||||||
return False;
|
{
|
||||||
|
return false;
|
||||||
} // function getValueOfXForY()
|
} // function getValueOfXForY()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the original set of X-Values
|
* Return the original set of X-Values
|
||||||
*
|
*
|
||||||
* @return float[] X-Values
|
* @return float[] X-Values
|
||||||
*/
|
*/
|
||||||
public function getXValues() {
|
public function getXValues()
|
||||||
|
{
|
||||||
return $this->_xValues;
|
return $this->_xValues;
|
||||||
} // function getValueOfXForY()
|
} // function getValueOfXForY()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Equation of the best-fit line
|
* Return the Equation of the best-fit line
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEquation($dp=0) {
|
public function getEquation($dp = 0)
|
||||||
|
{
|
||||||
return False;
|
return False;
|
||||||
} // function getEquation()
|
} // function getEquation()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Slope of the line
|
* Return the Slope of the line
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSlope($dp=0) {
|
public function getSlope($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_slope, $dp);
|
return round($this->_slope, $dp);
|
||||||
}
|
}
|
||||||
return $this->_slope;
|
return $this->_slope;
|
||||||
} // function getSlope()
|
} // function getSlope()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the standard error of the Slope
|
* Return the standard error of the Slope
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getSlopeSE($dp=0) {
|
public function getSlopeSE($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_slopeSE, $dp);
|
return round($this->_slopeSE, $dp);
|
||||||
}
|
}
|
||||||
return $this->_slopeSE;
|
return $this->_slopeSE;
|
||||||
} // function getSlopeSE()
|
} // function getSlopeSE()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Value of X where it intersects Y = 0
|
* Return the Value of X where it intersects Y = 0
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIntersect($dp=0) {
|
public function getIntersect($dp=0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_intersect, $dp);
|
return round($this->_intersect, $dp);
|
||||||
}
|
}
|
||||||
return $this->_intersect;
|
return $this->_intersect;
|
||||||
} // function getIntersect()
|
} // function getIntersect()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the standard error of the Intersect
|
* Return the standard error of the Intersect
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIntersectSE($dp=0) {
|
public function getIntersectSE($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_intersectSE, $dp);
|
return round($this->_intersectSE, $dp);
|
||||||
}
|
}
|
||||||
return $this->_intersectSE;
|
return $this->_intersectSE;
|
||||||
} // function getIntersectSE()
|
} // function getIntersectSE()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the goodness of fit for this regression
|
* Return the goodness of fit for this regression
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to return
|
* @param int $dp Number of places of decimal precision to return
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getGoodnessOfFit($dp=0) {
|
public function getGoodnessOfFit($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_goodnessOfFit, $dp);
|
return round($this->_goodnessOfFit, $dp);
|
||||||
}
|
}
|
||||||
return $this->_goodnessOfFit;
|
return $this->_goodnessOfFit;
|
||||||
} // function getGoodnessOfFit()
|
} // function getGoodnessOfFit()
|
||||||
|
|
||||||
|
public function getGoodnessOfFitPercent($dp = 0)
|
||||||
public function getGoodnessOfFitPercent($dp=0) {
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_goodnessOfFit * 100, $dp);
|
return round($this->_goodnessOfFit * 100, $dp);
|
||||||
}
|
}
|
||||||
return $this->_goodnessOfFit * 100;
|
return $this->_goodnessOfFit * 100;
|
||||||
} // function getGoodnessOfFitPercent()
|
} // function getGoodnessOfFitPercent()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the standard deviation of the residuals for this regression
|
* Return the standard deviation of the residuals for this regression
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to return
|
* @param int $dp Number of places of decimal precision to return
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getStdevOfResiduals($dp=0) {
|
public function getStdevOfResiduals($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_stdevOfResiduals, $dp);
|
return round($this->_stdevOfResiduals, $dp);
|
||||||
}
|
}
|
||||||
return $this->_stdevOfResiduals;
|
return $this->_stdevOfResiduals;
|
||||||
} // function getStdevOfResiduals()
|
} // function getStdevOfResiduals()
|
||||||
|
|
||||||
|
public function getSSRegression($dp = 0)
|
||||||
public function getSSRegression($dp=0) {
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_SSRegression, $dp);
|
return round($this->_SSRegression, $dp);
|
||||||
}
|
}
|
||||||
return $this->_SSRegression;
|
return $this->_SSRegression;
|
||||||
} // function getSSRegression()
|
} // function getSSRegression()
|
||||||
|
|
||||||
|
public function getSSResiduals($dp = 0)
|
||||||
public function getSSResiduals($dp=0) {
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_SSResiduals, $dp);
|
return round($this->_SSResiduals, $dp);
|
||||||
}
|
}
|
||||||
return $this->_SSResiduals;
|
return $this->_SSResiduals;
|
||||||
} // function getSSResiduals()
|
} // function getSSResiduals()
|
||||||
|
|
||||||
|
public function getDFResiduals($dp = 0)
|
||||||
public function getDFResiduals($dp=0) {
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_DFResiduals, $dp);
|
return round($this->_DFResiduals, $dp);
|
||||||
}
|
}
|
||||||
return $this->_DFResiduals;
|
return $this->_DFResiduals;
|
||||||
} // function getDFResiduals()
|
} // function getDFResiduals()
|
||||||
|
|
||||||
|
public function getF($dp = 0)
|
||||||
public function getF($dp=0) {
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_F, $dp);
|
return round($this->_F, $dp);
|
||||||
}
|
}
|
||||||
return $this->_F;
|
return $this->_F;
|
||||||
} // function getF()
|
} // function getF()
|
||||||
|
|
||||||
|
public function getCovariance($dp = 0)
|
||||||
public function getCovariance($dp=0) {
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_covariance, $dp);
|
return round($this->_covariance, $dp);
|
||||||
}
|
}
|
||||||
return $this->_covariance;
|
return $this->_covariance;
|
||||||
} // function getCovariance()
|
} // function getCovariance()
|
||||||
|
|
||||||
|
public function getCorrelation($dp = 0)
|
||||||
public function getCorrelation($dp=0) {
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round($this->_correlation, $dp);
|
return round($this->_correlation, $dp);
|
||||||
}
|
}
|
||||||
return $this->_correlation;
|
return $this->_correlation;
|
||||||
} // function getCorrelation()
|
} // function getCorrelation()
|
||||||
|
|
||||||
|
public function getYBestFitValues()
|
||||||
public function getYBestFitValues() {
|
{
|
||||||
return $this->_yBestFitValues;
|
return $this->_yBestFitValues;
|
||||||
} // function getYBestFitValues()
|
} // function getYBestFitValues()
|
||||||
|
|
||||||
|
protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
|
||||||
protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const) {
|
{
|
||||||
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
|
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
|
||||||
foreach ($this->_xValues as $xKey => $xValue) {
|
foreach ($this->_xValues as $xKey => $xValue) {
|
||||||
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
|
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
|
||||||
@ -364,8 +365,8 @@ class PHPExcel_Best_Fit
|
|||||||
}
|
}
|
||||||
} // function _calculateGoodnessOfFit()
|
} // function _calculateGoodnessOfFit()
|
||||||
|
|
||||||
|
protected function _leastSquareFit($yValues, $xValues, $const)
|
||||||
protected function _leastSquareFit($yValues, $xValues, $const) {
|
{
|
||||||
// calculate sums
|
// calculate sums
|
||||||
$x_sum = array_sum($xValues);
|
$x_sum = array_sum($xValues);
|
||||||
$y_sum = array_sum($yValues);
|
$y_sum = array_sum($yValues);
|
||||||
@ -401,7 +402,6 @@ class PHPExcel_Best_Fit
|
|||||||
$this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
|
$this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
|
||||||
} // function _leastSquareFit()
|
} // function _leastSquareFit()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression
|
* Define the regression
|
||||||
*
|
*
|
||||||
@ -409,7 +409,8 @@ class PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
function __construct($yValues, $xValues=array(), $const=True) {
|
function __construct($yValues, $xValues = array(), $const = true)
|
||||||
|
{
|
||||||
// Calculate number of points
|
// Calculate number of points
|
||||||
$nY = count($yValues);
|
$nY = count($yValues);
|
||||||
$nX = count($xValues);
|
$nX = count($xValues);
|
||||||
@ -420,13 +421,12 @@ class PHPExcel_Best_Fit
|
|||||||
$nX = $nY;
|
$nX = $nY;
|
||||||
} elseif ($nY != $nX) {
|
} elseif ($nY != $nX) {
|
||||||
// Ensure both arrays of points are the same size
|
// Ensure both arrays of points are the same size
|
||||||
$this->_error = True;
|
$this->_error = true;
|
||||||
return False;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_valueCount = $nY;
|
$this->_valueCount = $nY;
|
||||||
$this->_xValues = $xValues;
|
$this->_xValues = $xValues;
|
||||||
$this->_yValues = $yValues;
|
$this->_yValues = $yValues;
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
}
|
||||||
} // class bestFit
|
|
||||||
|
@ -46,71 +46,70 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'exponential';
|
protected $_bestFitType = 'exponential';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
*
|
*
|
||||||
* @param float $xValue X-Value
|
* @param float $xValue X-Value
|
||||||
* @return float Y-Value
|
* @return float Y-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue) {
|
public function getValueOfYForX($xValue)
|
||||||
|
{
|
||||||
return $this->getIntersect() * pow($this->getSlope(),($xValue - $this->_Xoffset));
|
return $this->getIntersect() * pow($this->getSlope(),($xValue - $this->_Xoffset));
|
||||||
} // function getValueOfYForX()
|
} // function getValueOfYForX()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
*
|
*
|
||||||
* @param float $yValue Y-Value
|
* @param float $yValue Y-Value
|
||||||
* @return float X-Value
|
* @return float X-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfXForY($yValue) {
|
public function getValueOfXForY($yValue)
|
||||||
|
{
|
||||||
return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($this->getSlope());
|
return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($this->getSlope());
|
||||||
} // function getValueOfXForY()
|
} // function getValueOfXForY()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Equation of the best-fit line
|
* Return the Equation of the best-fit line
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getEquation($dp=0) {
|
public function getEquation($dp = 0)
|
||||||
|
{
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
return 'Y = '.$intersect.' * '.$slope.'^X';
|
return 'Y = '.$intersect.' * '.$slope.'^X';
|
||||||
} // function getEquation()
|
} // function getEquation()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Slope of the line
|
* Return the Slope of the line
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getSlope($dp=0) {
|
public function getSlope($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round(exp($this->_slope), $dp);
|
return round(exp($this->_slope), $dp);
|
||||||
}
|
}
|
||||||
return exp($this->_slope);
|
return exp($this->_slope);
|
||||||
} // function getSlope()
|
} // function getSlope()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Value of X where it intersects Y = 0
|
* Return the Value of X where it intersects Y = 0
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getIntersect($dp=0) {
|
public function getIntersect($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round(exp($this->_intersect), $dp);
|
return round(exp($this->_intersect), $dp);
|
||||||
}
|
}
|
||||||
return exp($this->_intersect);
|
return exp($this->_intersect);
|
||||||
} // function getIntersect()
|
} // function getIntersect()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
*
|
*
|
||||||
@ -118,7 +117,8 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _exponential_regression($yValues, $xValues, $const) {
|
private function _exponential_regression($yValues, $xValues, $const)
|
||||||
|
{
|
||||||
foreach ($yValues as &$value) {
|
foreach ($yValues as &$value) {
|
||||||
if ($value < 0.0) {
|
if ($value < 0.0) {
|
||||||
$value = 0 - log(abs($value));
|
$value = 0 - log(abs($value));
|
||||||
@ -131,7 +131,6 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||||
} // function _exponential_regression()
|
} // function _exponential_regression()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
*
|
*
|
||||||
@ -139,10 +138,10 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
function __construct($yValues, $xValues=array(), $const=True) {
|
function __construct($yValues, $xValues = array(), $const = true)
|
||||||
if (parent::__construct($yValues, $xValues) !== False) {
|
{
|
||||||
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_exponential_regression($yValues, $xValues, $const);
|
$this->_exponential_regression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
}
|
||||||
} // class exponentialBestFit
|
|
@ -25,10 +25,8 @@
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Linear_Best_Fit
|
* PHPExcel_Linear_Best_Fit
|
||||||
*
|
*
|
||||||
@ -46,25 +44,25 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'linear';
|
protected $_bestFitType = 'linear';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
*
|
*
|
||||||
* @param float $xValue X-Value
|
* @param float $xValue X-Value
|
||||||
* @return float Y-Value
|
* @return float Y-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue) {
|
public function getValueOfYForX($xValue)
|
||||||
|
{
|
||||||
return $this->getIntersect() + $this->getSlope() * $xValue;
|
return $this->getIntersect() + $this->getSlope() * $xValue;
|
||||||
} // function getValueOfYForX()
|
} // function getValueOfYForX()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
*
|
*
|
||||||
* @param float $yValue Y-Value
|
* @param float $yValue Y-Value
|
||||||
* @return float X-Value
|
* @return float X-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfXForY($yValue) {
|
public function getValueOfXForY($yValue)
|
||||||
|
{
|
||||||
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
||||||
} // function getValueOfXForY()
|
} // function getValueOfXForY()
|
||||||
|
|
||||||
@ -75,14 +73,14 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getEquation($dp=0) {
|
public function getEquation($dp = 0)
|
||||||
|
{
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
return 'Y = '.$intersect.' + '.$slope.' * X';
|
return 'Y = '.$intersect.' + '.$slope.' * X';
|
||||||
} // function getEquation()
|
} // function getEquation()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
*
|
*
|
||||||
@ -90,11 +88,11 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _linear_regression($yValues, $xValues, $const) {
|
private function _linear_regression($yValues, $xValues, $const)
|
||||||
|
{
|
||||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||||
} // function _linear_regression()
|
} // function _linear_regression()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
*
|
*
|
||||||
@ -102,10 +100,10 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
function __construct($yValues, $xValues=array(), $const=True) {
|
function __construct($yValues, $xValues = array(), $const = true)
|
||||||
if (parent::__construct($yValues, $xValues) !== False) {
|
{
|
||||||
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_linear_regression($yValues, $xValues, $const);
|
$this->_linear_regression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
}
|
||||||
} // class linearBestFit
|
|
@ -25,10 +25,8 @@
|
|||||||
* @version ##VERSION##, ##DATE##
|
* @version ##VERSION##, ##DATE##
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHPExcel_Logarithmic_Best_Fit
|
* PHPExcel_Logarithmic_Best_Fit
|
||||||
*
|
*
|
||||||
@ -46,43 +44,42 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
**/
|
**/
|
||||||
protected $_bestFitType = 'logarithmic';
|
protected $_bestFitType = 'logarithmic';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Y-Value for a specified value of X
|
* Return the Y-Value for a specified value of X
|
||||||
*
|
*
|
||||||
* @param float $xValue X-Value
|
* @param float $xValue X-Value
|
||||||
* @return float Y-Value
|
* @return float Y-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue) {
|
public function getValueOfYForX($xValue)
|
||||||
|
{
|
||||||
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset);
|
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset);
|
||||||
} // function getValueOfYForX()
|
} // function getValueOfYForX()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the X-Value for a specified value of Y
|
* Return the X-Value for a specified value of Y
|
||||||
*
|
*
|
||||||
* @param float $yValue Y-Value
|
* @param float $yValue Y-Value
|
||||||
* @return float X-Value
|
* @return float X-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfXForY($yValue) {
|
public function getValueOfXForY($yValue)
|
||||||
|
{
|
||||||
return exp(($yValue - $this->getIntersect()) / $this->getSlope());
|
return exp(($yValue - $this->getIntersect()) / $this->getSlope());
|
||||||
} // function getValueOfXForY()
|
} // function getValueOfXForY()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the Equation of the best-fit line
|
* Return the Equation of the best-fit line
|
||||||
*
|
*
|
||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getEquation($dp=0) {
|
public function getEquation($dp = 0)
|
||||||
|
{
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
return 'Y = '.$intersect.' + '.$slope.' * log(X)';
|
return 'Y = '.$intersect.' + '.$slope.' * log(X)';
|
||||||
} // function getEquation()
|
} // function getEquation()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
* Execute the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
*
|
*
|
||||||
@ -90,7 +87,8 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _logarithmic_regression($yValues, $xValues, $const) {
|
private function _logarithmic_regression($yValues, $xValues, $const)
|
||||||
|
{
|
||||||
foreach ($xValues as &$value) {
|
foreach ($xValues as &$value) {
|
||||||
if ($value < 0.0) {
|
if ($value < 0.0) {
|
||||||
$value = 0 - log(abs($value));
|
$value = 0 - log(abs($value));
|
||||||
@ -103,7 +101,6 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
$this->_leastSquareFit($yValues, $xValues, $const);
|
$this->_leastSquareFit($yValues, $xValues, $const);
|
||||||
} // function _logarithmic_regression()
|
} // function _logarithmic_regression()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
* Define the regression and calculate the goodness of fit for a set of X and Y data values
|
||||||
*
|
*
|
||||||
@ -111,10 +108,10 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
function __construct($yValues, $xValues=array(), $const=True) {
|
function __construct($yValues, $xValues = array(), $const = true)
|
||||||
if (parent::__construct($yValues, $xValues) !== False) {
|
{
|
||||||
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_logarithmic_regression($yValues, $xValues, $const);
|
$this->_logarithmic_regression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
}
|
||||||
} // class logarithmicBestFit
|
|
@ -61,7 +61,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
**/
|
**/
|
||||||
public function getOrder() {
|
public function getOrder()
|
||||||
|
{
|
||||||
return $this->_order;
|
return $this->_order;
|
||||||
} // function getOrder()
|
} // function getOrder()
|
||||||
|
|
||||||
@ -72,7 +73,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float $xValue X-Value
|
* @param float $xValue X-Value
|
||||||
* @return float Y-Value
|
* @return float Y-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue) {
|
public function getValueOfYForX($xValue)
|
||||||
|
{
|
||||||
$retVal = $this->getIntersect();
|
$retVal = $this->getIntersect();
|
||||||
$slope = $this->getSlope();
|
$slope = $this->getSlope();
|
||||||
foreach ($slope as $key => $value) {
|
foreach ($slope as $key => $value) {
|
||||||
@ -90,7 +92,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float $yValue Y-Value
|
* @param float $yValue Y-Value
|
||||||
* @return float X-Value
|
* @return float X-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfXForY($yValue) {
|
public function getValueOfXForY($yValue)
|
||||||
|
{
|
||||||
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
return ($yValue - $this->getIntersect()) / $this->getSlope();
|
||||||
} // function getValueOfXForY()
|
} // function getValueOfXForY()
|
||||||
|
|
||||||
@ -101,7 +104,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getEquation($dp=0) {
|
public function getEquation($dp = 0)
|
||||||
|
{
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
@ -124,7 +128,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getSlope($dp=0) {
|
public function getSlope($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
$coefficients = array();
|
$coefficients = array();
|
||||||
foreach ($this->_slope as $coefficient) {
|
foreach ($this->_slope as $coefficient) {
|
||||||
@ -136,7 +141,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
} // function getSlope()
|
} // function getSlope()
|
||||||
|
|
||||||
|
|
||||||
public function getCoefficients($dp=0) {
|
public function getCoefficients($dp = 0)
|
||||||
|
{
|
||||||
return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
|
return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
|
||||||
} // function getCoefficients()
|
} // function getCoefficients()
|
||||||
|
|
||||||
@ -149,7 +155,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _polynomial_regression($order, $yValues, $xValues, $const) {
|
private function _polynomial_regression($order, $yValues, $xValues, $const)
|
||||||
|
{
|
||||||
// calculate sums
|
// calculate sums
|
||||||
$x_sum = array_sum($xValues);
|
$x_sum = array_sum($xValues);
|
||||||
$y_sum = array_sum($yValues);
|
$y_sum = array_sum($yValues);
|
||||||
@ -206,8 +213,9 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
function __construct($order, $yValues, $xValues=array(), $const=True) {
|
function __construct($order, $yValues, $xValues = array(), $const = true)
|
||||||
if (parent::__construct($yValues, $xValues) !== False) {
|
{
|
||||||
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
if ($order < $this->_valueCount) {
|
if ($order < $this->_valueCount) {
|
||||||
$this->_bestFitType .= '_'.$order;
|
$this->_bestFitType .= '_'.$order;
|
||||||
$this->_order = $order;
|
$this->_order = $order;
|
||||||
@ -220,5 +228,4 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // function __construct()
|
} // function __construct()
|
||||||
|
}
|
||||||
} // class polynomialBestFit
|
|
@ -53,7 +53,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float $xValue X-Value
|
* @param float $xValue X-Value
|
||||||
* @return float Y-Value
|
* @return float Y-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfYForX($xValue) {
|
public function getValueOfYForX($xValue)
|
||||||
|
{
|
||||||
return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope());
|
return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope());
|
||||||
} // function getValueOfYForX()
|
} // function getValueOfYForX()
|
||||||
|
|
||||||
@ -64,8 +65,9 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float $yValue Y-Value
|
* @param float $yValue Y-Value
|
||||||
* @return float X-Value
|
* @return float X-Value
|
||||||
**/
|
**/
|
||||||
public function getValueOfXForY($yValue) {
|
public function getValueOfXForY($yValue)
|
||||||
return pow((($yValue + $this->_Yoffset) / $this->getIntersect()),(1 / $this->getSlope()));
|
{
|
||||||
|
return pow((($yValue + $this->_Yoffset) / $this->getIntersect()), (1 / $this->getSlope()));
|
||||||
} // function getValueOfXForY()
|
} // function getValueOfXForY()
|
||||||
|
|
||||||
|
|
||||||
@ -75,7 +77,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getEquation($dp=0) {
|
public function getEquation($dp = 0)
|
||||||
|
{
|
||||||
$slope = $this->getSlope($dp);
|
$slope = $this->getSlope($dp);
|
||||||
$intersect = $this->getIntersect($dp);
|
$intersect = $this->getIntersect($dp);
|
||||||
|
|
||||||
@ -89,7 +92,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param int $dp Number of places of decimal precision to display
|
* @param int $dp Number of places of decimal precision to display
|
||||||
* @return string
|
* @return string
|
||||||
**/
|
**/
|
||||||
public function getIntersect($dp=0) {
|
public function getIntersect($dp = 0)
|
||||||
|
{
|
||||||
if ($dp != 0) {
|
if ($dp != 0) {
|
||||||
return round(exp($this->_intersect), $dp);
|
return round(exp($this->_intersect), $dp);
|
||||||
}
|
}
|
||||||
@ -104,7 +108,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
private function _power_regression($yValues, $xValues, $const) {
|
private function _power_regression($yValues, $xValues, $const)
|
||||||
|
{
|
||||||
foreach ($xValues as &$value) {
|
foreach ($xValues as &$value) {
|
||||||
if ($value < 0.0) {
|
if ($value < 0.0) {
|
||||||
$value = 0 - log(abs($value));
|
$value = 0 - log(abs($value));
|
||||||
@ -133,10 +138,10 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
|
|||||||
* @param float[] $xValues The set of X-values for this regression
|
* @param float[] $xValues The set of X-values for this regression
|
||||||
* @param boolean $const
|
* @param boolean $const
|
||||||
*/
|
*/
|
||||||
function __construct($yValues, $xValues=array(), $const=True) {
|
function __construct($yValues, $xValues = array(), $const = true)
|
||||||
if (parent::__construct($yValues, $xValues) !== False) {
|
{
|
||||||
|
if (parent::__construct($yValues, $xValues) !== false) {
|
||||||
$this->_power_regression($yValues, $xValues, $const);
|
$this->_power_regression($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
} // function __construct()
|
}
|
||||||
|
}
|
||||||
} // class powerBestFit
|
|
||||||
|
@ -84,7 +84,8 @@ class trendClass
|
|||||||
private static $_trendCache = array();
|
private static $_trendCache = array();
|
||||||
|
|
||||||
|
|
||||||
public static function calculate($trendType=self::TREND_BEST_FIT, $yValues, $xValues=array(), $const=True) {
|
public static function calculate($trendType = self::TREND_BEST_FIT, $yValues, $xValues = array(), $const = true)
|
||||||
|
{
|
||||||
// Calculate number of points in each dataset
|
// Calculate number of points in each dataset
|
||||||
$nY = count($yValues);
|
$nY = count($yValues);
|
||||||
$nX = count($xValues);
|
$nX = count($xValues);
|
||||||
@ -102,29 +103,29 @@ class trendClass
|
|||||||
// Determine which trend method has been requested
|
// Determine which trend method has been requested
|
||||||
switch ($trendType) {
|
switch ($trendType) {
|
||||||
// Instantiate and return the class for the requested trend method
|
// Instantiate and return the class for the requested trend method
|
||||||
case self::TREND_LINEAR :
|
case self::TREND_LINEAR:
|
||||||
case self::TREND_LOGARITHMIC :
|
case self::TREND_LOGARITHMIC:
|
||||||
case self::TREND_EXPONENTIAL :
|
case self::TREND_EXPONENTIAL:
|
||||||
case self::TREND_POWER :
|
case self::TREND_POWER:
|
||||||
if (!isset(self::$_trendCache[$key])) {
|
if (!isset(self::$_trendCache[$key])) {
|
||||||
$className = 'PHPExcel_'.$trendType.'_Best_Fit';
|
$className = 'PHPExcel_'.$trendType.'_Best_Fit';
|
||||||
self::$_trendCache[$key] = new $className($yValues, $xValues, $const);
|
self::$_trendCache[$key] = new $className($yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
return self::$_trendCache[$key];
|
return self::$_trendCache[$key];
|
||||||
break;
|
break;
|
||||||
case self::TREND_POLYNOMIAL_2 :
|
case self::TREND_POLYNOMIAL_2:
|
||||||
case self::TREND_POLYNOMIAL_3 :
|
case self::TREND_POLYNOMIAL_3:
|
||||||
case self::TREND_POLYNOMIAL_4 :
|
case self::TREND_POLYNOMIAL_4:
|
||||||
case self::TREND_POLYNOMIAL_5 :
|
case self::TREND_POLYNOMIAL_5:
|
||||||
case self::TREND_POLYNOMIAL_6 :
|
case self::TREND_POLYNOMIAL_6:
|
||||||
if (!isset(self::$_trendCache[$key])) {
|
if (!isset(self::$_trendCache[$key])) {
|
||||||
$order = substr($trendType,-1);
|
$order = substr($trendType, -1);
|
||||||
self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
||||||
}
|
}
|
||||||
return self::$_trendCache[$key];
|
return self::$_trendCache[$key];
|
||||||
break;
|
break;
|
||||||
case self::TREND_BEST_FIT :
|
case self::TREND_BEST_FIT:
|
||||||
case self::TREND_BEST_FIT_NO_POLY :
|
case self::TREND_BEST_FIT_NO_POLY:
|
||||||
// If the request is to determine the best fit regression, then we test each trend line in turn
|
// If the request is to determine the best fit regression, then we test each trend line in turn
|
||||||
// Start by generating an instance of each available trend method
|
// Start by generating an instance of each available trend method
|
||||||
foreach (self::$_trendTypes as $trendMethod) {
|
foreach (self::$_trendTypes as $trendMethod) {
|
||||||
@ -134,7 +135,7 @@ class trendClass
|
|||||||
}
|
}
|
||||||
if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
|
if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
|
||||||
foreach (self::$_trendTypePolyOrders as $trendMethod) {
|
foreach (self::$_trendTypePolyOrders as $trendMethod) {
|
||||||
$order = substr($trendMethod,-1);
|
$order = substr($trendMethod, -1);
|
||||||
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
|
||||||
if ($bestFit[$trendMethod]->getError()) {
|
if ($bestFit[$trendMethod]->getError()) {
|
||||||
unset($bestFit[$trendMethod]);
|
unset($bestFit[$trendMethod]);
|
||||||
@ -148,9 +149,8 @@ class trendClass
|
|||||||
$bestFitType = key($bestFitValue);
|
$bestFitType = key($bestFitValue);
|
||||||
return $bestFit[$bestFitType];
|
return $bestFit[$bestFitType];
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} // function calculate()
|
} // function calculate()
|
||||||
|
|
||||||
} // class trendClass
|
} // class trendClass
|
@ -434,8 +434,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
}
|
}
|
||||||
// Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'"
|
// Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'"
|
||||||
if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) ||
|
if ((str_replace(self::$_invalidCharacters, '', $pValue) !== $pValue) ||
|
||||||
(PHPExcel_Shared_String::Substring($pValue,-1,1)=='\'') ||
|
(PHPExcel_Shared_String::Substring($pValue, -1, 1)=='\'') ||
|
||||||
(PHPExcel_Shared_String::Substring($pValue,0,1)=='\'')) {
|
(PHPExcel_Shared_String::Substring($pValue, 0, 1)=='\'')) {
|
||||||
throw new PHPExcel_Exception('Invalid character found in sheet code name');
|
throw new PHPExcel_Exception('Invalid character found in sheet code name');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2066,7 +2066,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$highestRow = $this->getHighestDataRow();
|
$highestRow = $this->getHighestDataRow();
|
||||||
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
|
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
|
||||||
$objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this);
|
$objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this);
|
||||||
for($r = 0; $r < $pNumRows; ++$r) {
|
for ($r = 0; $r < $pNumRows; ++$r) {
|
||||||
$this->getCellCacheController()->removeRow($highestRow);
|
$this->getCellCacheController()->removeRow($highestRow);
|
||||||
--$highestRow;
|
--$highestRow;
|
||||||
}
|
}
|
||||||
@ -2091,7 +2091,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
|
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
|
||||||
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
|
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
|
||||||
$objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
|
$objReferenceHelper->insertNewBefore($pColumn . '1', -$pNumCols, 0, $this);
|
||||||
for($c = 0; $c < $pNumCols; ++$c) {
|
for ($c = 0; $c < $pNumCols; ++$c) {
|
||||||
$this->getCellCacheController()->removeColumn($highestColumn);
|
$this->getCellCacheController()->removeColumn($highestColumn);
|
||||||
$highestColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($highestColumn) - 2);
|
$highestColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($highestColumn) - 2);
|
||||||
}
|
}
|
||||||
@ -2502,9 +2502,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
|
||||||
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
|
||||||
$returnValue[$rRef][$cRef],
|
$returnValue[$rRef][$cRef],
|
||||||
($style && $style->getNumberFormat()) ?
|
($style && $style->getNumberFormat()) ? $style->getNumberFormat()->getFormatCode() : PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
||||||
$style->getNumberFormat()->getFormatCode() :
|
|
||||||
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2622,7 +2620,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
|
|
||||||
// Loop through column dimensions
|
// Loop through column dimensions
|
||||||
foreach ($this->_columnDimensions as $dimension) {
|
foreach ($this->_columnDimensions as $dimension) {
|
||||||
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
|
$highestColumn = max($highestColumn, PHPExcel_Cell::columnIndexFromString($dimension->getColumnIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through row dimensions
|
// Loop through row dimensions
|
||||||
@ -2674,7 +2672,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($returnRange) {
|
if ($returnRange) {
|
||||||
return array(trim(substr($pRange, 0, $sep),"'"), substr($pRange, $sep + 1));
|
return array(trim(substr($pRange, 0, $sep), "'"), substr($pRange, $sep + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return substr($pRange, $sep + 1);
|
return substr($pRange, $sep + 1);
|
||||||
@ -2833,9 +2831,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
public function getTabColor()
|
public function getTabColor()
|
||||||
{
|
{
|
||||||
if ($this->_tabColor === null)
|
if ($this->_tabColor === null) {
|
||||||
$this->_tabColor = new PHPExcel_Style_Color();
|
$this->_tabColor = new PHPExcel_Style_Color();
|
||||||
|
}
|
||||||
return $this->_tabColor;
|
return $this->_tabColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2867,7 +2865,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*
|
*
|
||||||
* @return PHPExcel_Worksheet
|
* @return PHPExcel_Worksheet
|
||||||
*/
|
*/
|
||||||
public function copy() {
|
public function copy()
|
||||||
|
{
|
||||||
$copied = clone $this;
|
$copied = clone $this;
|
||||||
|
|
||||||
return $copied;
|
return $copied;
|
||||||
@ -2908,7 +2907,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @return objWorksheet
|
* @return objWorksheet
|
||||||
* @throws PHPExcel_Exception
|
* @throws PHPExcel_Exception
|
||||||
*/
|
*/
|
||||||
public function setCodeName($pValue=null)
|
public function setCodeName($pValue = null)
|
||||||
{
|
{
|
||||||
// Is this a 'rename' or not?
|
// Is this a 'rename' or not?
|
||||||
if ($this->getCodeName() == $pValue) {
|
if ($this->getCodeName() == $pValue) {
|
||||||
@ -2927,18 +2926,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
// Use name, but append with lowest possible integer
|
// Use name, but append with lowest possible integer
|
||||||
|
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 29) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,29);
|
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 29);
|
||||||
}
|
}
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
|
while ($this->getParent()->sheetCodeNameExists($pValue . '_' . $i)) {
|
||||||
++$i;
|
++$i;
|
||||||
if ($i == 10) {
|
if ($i == 10) {
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 28) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,28);
|
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 28);
|
||||||
}
|
}
|
||||||
} elseif ($i == 100) {
|
} elseif ($i == 100) {
|
||||||
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
|
if (PHPExcel_Shared_String::CountCharacters($pValue) > 27) {
|
||||||
$pValue = PHPExcel_Shared_String::Substring($pValue,0,27);
|
$pValue = PHPExcel_Shared_String::Substring($pValue, 0, 27);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
public function setRange($pRange = '')
|
public function setRange($pRange = '')
|
||||||
{
|
{
|
||||||
// Uppercase coordinate
|
// Uppercase coordinate
|
||||||
$cellAddress = explode('!',strtoupper($pRange));
|
$cellAddress = explode('!', strtoupper($pRange));
|
||||||
if (count($cellAddress) > 1) {
|
if (count($cellAddress) > 1) {
|
||||||
list($worksheet, $pRange) = $cellAddress;
|
list($worksheet, $pRange) = $cellAddress;
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
}
|
}
|
||||||
foreach ($dateSet as $dateValue) {
|
foreach ($dateSet as $dateValue) {
|
||||||
// Use of substr to extract value at the appropriate group level
|
// Use of substr to extract value at the appropriate group level
|
||||||
if (substr($dtVal,0,strlen($dateValue)) == $dateValue) {
|
if (substr($dtVal, 0, strlen($dateValue)) == $dateValue) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -381,34 +381,34 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
if (is_numeric($rule['value'])) {
|
if (is_numeric($rule['value'])) {
|
||||||
// Numeric values are tested using the appropriate operator
|
// Numeric values are tested using the appropriate operator
|
||||||
switch ($rule['operator']) {
|
switch ($rule['operator']) {
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL:
|
||||||
$retVal = ($cellValue == $rule['value']);
|
$retVal = ($cellValue == $rule['value']);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL:
|
||||||
$retVal = ($cellValue != $rule['value']);
|
$retVal = ($cellValue != $rule['value']);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN:
|
||||||
$retVal = ($cellValue > $rule['value']);
|
$retVal = ($cellValue > $rule['value']);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL:
|
||||||
$retVal = ($cellValue >= $rule['value']);
|
$retVal = ($cellValue >= $rule['value']);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHAN:
|
||||||
$retVal = ($cellValue < $rule['value']);
|
$retVal = ($cellValue < $rule['value']);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_LESSTHANOREQUAL:
|
||||||
$retVal = ($cellValue <= $rule['value']);
|
$retVal = ($cellValue <= $rule['value']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} elseif ($rule['value'] == '') {
|
} elseif ($rule['value'] == '') {
|
||||||
switch ($rule['operator']) {
|
switch ($rule['operator']) {
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL:
|
||||||
$retVal = (($cellValue == '') || ($cellValue === null));
|
$retVal = (($cellValue == '') || ($cellValue === null));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_NOTEQUAL:
|
||||||
$retVal = (($cellValue != '') && ($cellValue !== null));
|
$retVal = (($cellValue != '') && ($cellValue !== null));
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
$retVal = true;
|
$retVal = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -418,7 +418,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
}
|
}
|
||||||
// If there are multiple conditions, then we need to test both using the appropriate join operator
|
// If there are multiple conditions, then we need to test both using the appropriate join operator
|
||||||
switch ($join) {
|
switch ($join) {
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR :
|
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_OR:
|
||||||
$returnVal = $returnVal || $retVal;
|
$returnVal = $returnVal || $retVal;
|
||||||
// Break as soon as we have a TRUE match for OR joins,
|
// Break as soon as we have a TRUE match for OR joins,
|
||||||
// to avoid unnecessary additional code execution
|
// to avoid unnecessary additional code execution
|
||||||
@ -426,7 +426,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
return $returnVal;
|
return $returnVal;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND :
|
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND:
|
||||||
$returnVal = $returnVal && $retVal;
|
$returnVal = $returnVal && $retVal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_numeric($cellValue)) {
|
if (is_numeric($cellValue)) {
|
||||||
$dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue));
|
$dateValue = date('m', PHPExcel_Shared_Date::ExcelToPHP($cellValue));
|
||||||
if (in_array($dateValue, $monthSet)) {
|
if (in_array($dateValue, $monthSet)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -485,69 +485,69 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
$baseDate = PHPExcel_Calculation_DateTime::DATENOW();
|
$baseDate = PHPExcel_Calculation_DateTime::DATENOW();
|
||||||
// Calculate start/end dates for the required date range based on current date
|
// Calculate start/end dates for the required date range based on current date
|
||||||
switch ($dynamicRuleType) {
|
switch ($dynamicRuleType) {
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK:
|
||||||
$baseDate = strtotime('-7 days', $baseDate);
|
$baseDate = strtotime('-7 days', $baseDate);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK:
|
||||||
$baseDate = strtotime('-7 days', $baseDate);
|
$baseDate = strtotime('-7 days', $baseDate);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH:
|
||||||
$baseDate = strtotime('-1 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
$baseDate = strtotime('-1 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH:
|
||||||
$baseDate = strtotime('+1 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
$baseDate = strtotime('+1 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER:
|
||||||
$baseDate = strtotime('-3 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
$baseDate = strtotime('-3 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER:
|
||||||
$baseDate = strtotime('+3 month',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
$baseDate = strtotime('+3 month', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR:
|
||||||
$baseDate = strtotime('-1 year',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
$baseDate = strtotime('-1 year', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR:
|
||||||
$baseDate = strtotime('+1 year',gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
$baseDate = strtotime('+1 year', gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($dynamicRuleType) {
|
switch ($dynamicRuleType) {
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW:
|
||||||
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
|
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
|
||||||
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate);
|
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE:
|
||||||
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
|
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
|
||||||
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
|
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR:
|
||||||
$maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 31, 12, date('Y', $baseDate)));
|
$maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 31, 12, date('Y', $baseDate)));
|
||||||
++$maxVal;
|
++$maxVal;
|
||||||
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
|
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1, date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER:
|
||||||
$thisMonth = date('m', $baseDate);
|
$thisMonth = date('m', $baseDate);
|
||||||
$thisQuarter = floor(--$thisMonth / 3);
|
$thisQuarter = floor(--$thisMonth / 3);
|
||||||
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1+$thisQuarter)*3, date('Y', $baseDate)));
|
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), (1+$thisQuarter)*3, date('Y', $baseDate)));
|
||||||
++$maxVal;
|
++$maxVal;
|
||||||
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1+$thisQuarter*3, date('Y', $baseDate)));
|
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, 1+$thisQuarter*3, date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH:
|
||||||
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), date('m', $baseDate), date('Y', $baseDate)));
|
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0, 0, 0, date('t', $baseDate), date('m', $baseDate), date('Y', $baseDate)));
|
||||||
++$maxVal;
|
++$maxVal;
|
||||||
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0, 0, 0, 1, date('m', $baseDate), date('Y', $baseDate)));
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK:
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK:
|
||||||
$dayOfWeek = date('w', $baseDate);
|
$dayOfWeek = date('w', $baseDate);
|
||||||
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek;
|
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek;
|
||||||
$maxVal = $val + 7;
|
$maxVal = $val + 7;
|
||||||
@ -556,11 +556,11 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
|
|
||||||
switch ($dynamicRuleType) {
|
switch ($dynamicRuleType) {
|
||||||
// Adjust Today dates for Yesterday and Tomorrow
|
// Adjust Today dates for Yesterday and Tomorrow
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY:
|
||||||
--$maxVal;
|
--$maxVal;
|
||||||
--$val;
|
--$val;
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW :
|
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW:
|
||||||
++$maxVal;
|
++$maxVal;
|
||||||
++$val;
|
++$val;
|
||||||
break;
|
break;
|
||||||
@ -589,7 +589,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
sort($dataValues);
|
sort($dataValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_pop(array_slice($dataValues,0, $ruleValue));
|
return array_pop(array_slice($dataValues, 0, $ruleValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -610,7 +610,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
foreach ($this->_columns as $columnID => $filterColumn) {
|
foreach ($this->_columns as $columnID => $filterColumn) {
|
||||||
$rules = $filterColumn->getRules();
|
$rules = $filterColumn->getRules();
|
||||||
switch ($filterColumn->getFilterType()) {
|
switch ($filterColumn->getFilterType()) {
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER :
|
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER:
|
||||||
$ruleValues = array();
|
$ruleValues = array();
|
||||||
// Build a list of the filter value selections
|
// Build a list of the filter value selections
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
@ -620,8 +620,9 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
// Test if we want to include blanks in our filter criteria
|
// Test if we want to include blanks in our filter criteria
|
||||||
$blanks = false;
|
$blanks = false;
|
||||||
$ruleDataSet = array_filter($ruleValues);
|
$ruleDataSet = array_filter($ruleValues);
|
||||||
if (count($ruleValues) != count($ruleDataSet))
|
if (count($ruleValues) != count($ruleDataSet)) {
|
||||||
$blanks = true;
|
$blanks = true;
|
||||||
|
}
|
||||||
if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) {
|
if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) {
|
||||||
// Filter on absolute values
|
// Filter on absolute values
|
||||||
$columnFilterTests[$columnID] = array(
|
$columnFilterTests[$columnID] = array(
|
||||||
@ -638,23 +639,29 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
foreach ($ruleDataSet as $ruleValue) {
|
foreach ($ruleDataSet as $ruleValue) {
|
||||||
$date = $time = '';
|
$date = $time = '';
|
||||||
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&
|
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&
|
||||||
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== ''))
|
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) {
|
||||||
$date .= sprintf('%04d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]);
|
$date .= sprintf('%04d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]);
|
||||||
|
}
|
||||||
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) &&
|
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) &&
|
||||||
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != ''))
|
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) {
|
||||||
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]);
|
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]);
|
||||||
|
}
|
||||||
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) &&
|
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) &&
|
||||||
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== ''))
|
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) {
|
||||||
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]);
|
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]);
|
||||||
|
}
|
||||||
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) &&
|
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) &&
|
||||||
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== ''))
|
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) {
|
||||||
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]);
|
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]);
|
||||||
|
}
|
||||||
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) &&
|
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) &&
|
||||||
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== ''))
|
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) {
|
||||||
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]);
|
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]);
|
||||||
|
}
|
||||||
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) &&
|
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) &&
|
||||||
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== ''))
|
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) {
|
||||||
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]);
|
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]);
|
||||||
|
}
|
||||||
$dateTime = $date . $time;
|
$dateTime = $date . $time;
|
||||||
$arguments['date'][] = $date;
|
$arguments['date'][] = $date;
|
||||||
$arguments['time'][] = $time;
|
$arguments['time'][] = $time;
|
||||||
@ -670,7 +677,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER :
|
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_CUSTOMFILTER:
|
||||||
$customRuleForBlanks = false;
|
$customRuleForBlanks = false;
|
||||||
$ruleValues = array();
|
$ruleValues = array();
|
||||||
// Build a list of the filter value selections
|
// Build a list of the filter value selections
|
||||||
@ -680,7 +687,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
if (!is_numeric($ruleValue)) {
|
if (!is_numeric($ruleValue)) {
|
||||||
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
|
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
|
||||||
$ruleValue = preg_quote($ruleValue);
|
$ruleValue = preg_quote($ruleValue);
|
||||||
$ruleValue = str_replace(self::$_fromReplace,self::$_toReplace, $ruleValue);
|
$ruleValue = str_replace(self::$_fromReplace, self::$_toReplace, $ruleValue);
|
||||||
if (trim($ruleValue) == '') {
|
if (trim($ruleValue) == '') {
|
||||||
$customRuleForBlanks = true;
|
$customRuleForBlanks = true;
|
||||||
$ruleValue = trim($ruleValue);
|
$ruleValue = trim($ruleValue);
|
||||||
@ -694,7 +701,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
'arguments' => array('filterRules' => $ruleValues, 'join' => $join, 'customRuleForBlanks' => $customRuleForBlanks)
|
'arguments' => array('filterRules' => $ruleValues, 'join' => $join, 'customRuleForBlanks' => $customRuleForBlanks)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER :
|
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER:
|
||||||
$ruleValues = array();
|
$ruleValues = array();
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
// We should only ever have one Dynamic Filter Rule anyway
|
// We should only ever have one Dynamic Filter Rule anyway
|
||||||
@ -704,7 +711,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
// Number (Average) based
|
// Number (Average) based
|
||||||
// Calculate the average
|
// Calculate the average
|
||||||
$averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')';
|
$averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')';
|
||||||
$average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula,null, $this->_workSheet->getCell('A1'));
|
$average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula, null, $this->_workSheet->getCell('A1'));
|
||||||
// Set above/below rule based on greaterThan or LessTan
|
// Set above/below rule based on greaterThan or LessTan
|
||||||
$operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE)
|
$operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE)
|
||||||
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN
|
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN
|
||||||
@ -720,14 +727,14 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
// Date based
|
// Date based
|
||||||
if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') {
|
if ($dynamicRuleType{0} == 'M' || $dynamicRuleType{0} == 'Q') {
|
||||||
// Month or Quarter
|
// Month or Quarter
|
||||||
sscanf($dynamicRuleType,'%[A-Z]%d', $periodType, $period);
|
sscanf($dynamicRuleType, '%[A-Z]%d', $periodType, $period);
|
||||||
if ($periodType == 'M') {
|
if ($periodType == 'M') {
|
||||||
$ruleValues = array($period);
|
$ruleValues = array($period);
|
||||||
} else {
|
} else {
|
||||||
--$period;
|
--$period;
|
||||||
$periodEnd = (1+$period)*3;
|
$periodEnd = (1+$period)*3;
|
||||||
$periodStart = 1+$period*3;
|
$periodStart = 1+$period*3;
|
||||||
$ruleValues = range($periodStart,periodEnd);
|
$ruleValues = range($periodStart, $periodEnd);
|
||||||
}
|
}
|
||||||
$columnFilterTests[$columnID] = array(
|
$columnFilterTests[$columnID] = array(
|
||||||
'method' => '_filterTestInPeriodDateSet',
|
'method' => '_filterTestInPeriodDateSet',
|
||||||
@ -742,7 +749,7 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER :
|
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER:
|
||||||
$ruleValues = array();
|
$ruleValues = array();
|
||||||
$dataRowCount = $rangeEnd[1] - $rangeStart[1];
|
$dataRowCount = $rangeEnd[1] - $rangeStart[1];
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
@ -754,8 +761,12 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
if ($ruleOperator === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) {
|
if ($ruleOperator === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) {
|
||||||
$ruleValue = floor($ruleValue * ($dataRowCount / 100));
|
$ruleValue = floor($ruleValue * ($dataRowCount / 100));
|
||||||
}
|
}
|
||||||
if ($ruleValue < 1) $ruleValue = 1;
|
if ($ruleValue < 1) {
|
||||||
if ($ruleValue > 500) $ruleValue = 500;
|
$ruleValue = 1;
|
||||||
|
}
|
||||||
|
if ($ruleValue > 500) {
|
||||||
|
$ruleValue = 500;
|
||||||
|
}
|
||||||
|
|
||||||
$maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue);
|
$maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue);
|
||||||
|
|
||||||
@ -836,7 +847,8 @@ class PHPExcel_Worksheet_AutoFilter
|
|||||||
* toString method replicates previous behavior by returning the range if object is
|
* toString method replicates previous behavior by returning the range if object is
|
||||||
* referenced as a property of its parent.
|
* referenced as a property of its parent.
|
||||||
*/
|
*/
|
||||||
public function __toString() {
|
public function __toString()
|
||||||
|
{
|
||||||
return (string) $this->_range;
|
return (string) $this->_range;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,8 @@ class PHPExcel_Worksheet_PageSetup
|
|||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function getFitToPage() {
|
public function getFitToPage()
|
||||||
|
{
|
||||||
return $this->_fitToPage;
|
return $this->_fitToPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user