More psr-2 goodness
This commit is contained in:
parent
121eccd4c8
commit
4c8dd00dff
|
@ -83,7 +83,7 @@ class PHPExcel_Calculation
|
||||||
* @access private
|
* @access private
|
||||||
* @var PHPExcel_Calculation
|
* @var PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
private static $_instance;
|
private static $instance;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +92,7 @@ class PHPExcel_Calculation
|
||||||
* @access private
|
* @access private
|
||||||
* @var PHPExcel
|
* @var PHPExcel
|
||||||
*/
|
*/
|
||||||
private $_workbook;
|
private $workbook;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of instances of the calculation engine that we've instantiated for individual workbooks
|
* List of instances of the calculation engine that we've instantiated for individual workbooks
|
||||||
|
@ -100,7 +100,7 @@ class PHPExcel_Calculation
|
||||||
* @access private
|
* @access private
|
||||||
* @var PHPExcel_Calculation[]
|
* @var PHPExcel_Calculation[]
|
||||||
*/
|
*/
|
||||||
private static $_workbookSets;
|
private static $workbookSets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculation cache
|
* Calculation cache
|
||||||
|
@ -108,7 +108,7 @@ class PHPExcel_Calculation
|
||||||
* @access private
|
* @access private
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $_calculationCache = array ();
|
private $calculationCache = array ();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,7 +117,7 @@ class PHPExcel_Calculation
|
||||||
* @access private
|
* @access private
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
private $_calculationCacheEnabled = true;
|
private $calculationCacheEnabled = true;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -127,7 +127,7 @@ class PHPExcel_Calculation
|
||||||
* @access private
|
* @access private
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_operators = array(
|
private static $operators = array(
|
||||||
'+' => true, '-' => true, '*' => true, '/' => true,
|
'+' => true, '-' => true, '*' => true, '/' => true,
|
||||||
'^' => true, '&' => true, '%' => false, '~' => false,
|
'^' => true, '&' => true, '%' => false, '~' => false,
|
||||||
'>' => true, '<' => true, '=' => true, '>=' => true,
|
'>' => true, '<' => true, '=' => true, '>=' => true,
|
||||||
|
@ -140,7 +140,7 @@ class PHPExcel_Calculation
|
||||||
* @access private
|
* @access private
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_binaryOperators = array(
|
private static $binaryOperators = array(
|
||||||
'+' => true, '-' => true, '*' => true, '/' => true,
|
'+' => true, '-' => true, '*' => true, '/' => true,
|
||||||
'^' => true, '&' => true, '>' => true, '<' => true,
|
'^' => true, '&' => true, '>' => true, '<' => true,
|
||||||
'=' => true, '>=' => true, '<=' => true, '<>' => true,
|
'=' => true, '>=' => true, '<=' => true, '<>' => true,
|
||||||
|
@ -183,9 +183,9 @@ class PHPExcel_Calculation
|
||||||
* @var array of string
|
* @var array of string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private $_cyclicReferenceStack;
|
private $cyclicReferenceStack;
|
||||||
|
|
||||||
private $_cellStack = array();
|
private $cellStack = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current iteration counter for cyclic formulae
|
* Current iteration counter for cyclic formulae
|
||||||
|
@ -195,9 +195,9 @@ class PHPExcel_Calculation
|
||||||
* @var integer
|
* @var integer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private $_cyclicFormulaCount = 1;
|
private $cyclicFormulaCounter = 1;
|
||||||
|
|
||||||
private $_cyclicFormulaCell = '';
|
private $cyclicFormulaCell = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of iterations for cyclic formulae
|
* Number of iterations for cyclic formulae
|
||||||
|
@ -213,7 +213,7 @@ class PHPExcel_Calculation
|
||||||
* @var integer
|
* @var integer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private $_savedPrecision = 14;
|
private $savedPrecision = 14;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -222,7 +222,7 @@ class PHPExcel_Calculation
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_localeLanguage = 'en_us'; // US English (default locale)
|
private static $localeLanguage = 'en_us'; // US English (default locale)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of available locale settings
|
* List of available locale settings
|
||||||
|
@ -231,7 +231,7 @@ class PHPExcel_Calculation
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_validLocaleLanguages = array(
|
private static $validLocaleLanguages = array(
|
||||||
'en' // English (default language)
|
'en' // English (default language)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -241,8 +241,8 @@ class PHPExcel_Calculation
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_localeArgumentSeparator = ',';
|
private static $localeArgumentSeparator = ',';
|
||||||
private static $_localeFunctions = array();
|
private static $localeFunctions = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locale-specific translations for Excel constants (True, False and Null)
|
* Locale-specific translations for Excel constants (True, False and Null)
|
||||||
|
@ -250,7 +250,7 @@ class PHPExcel_Calculation
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static $_localeBoolean = array(
|
public static $localeBoolean = array(
|
||||||
'TRUE' => 'TRUE',
|
'TRUE' => 'TRUE',
|
||||||
'FALSE' => 'FALSE',
|
'FALSE' => 'FALSE',
|
||||||
'NULL' => 'NULL'
|
'NULL' => 'NULL'
|
||||||
|
@ -263,14 +263,14 @@ class PHPExcel_Calculation
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static $_ExcelConstants = array(
|
private static $excelConstants = array(
|
||||||
'TRUE' => true,
|
'TRUE' => true,
|
||||||
'FALSE' => false,
|
'FALSE' => false,
|
||||||
'NULL' => null
|
'NULL' => null
|
||||||
);
|
);
|
||||||
|
|
||||||
// PHPExcel functions
|
// PHPExcel functions
|
||||||
private static $_PHPExcelFunctions = array( // PHPExcel functions
|
private static $PHPExcelFunctions = array( // PHPExcel functions
|
||||||
'ABS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
|
'ABS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
|
||||||
'functionCall' => 'abs',
|
'functionCall' => 'abs',
|
||||||
'argumentCount' => '1'
|
'argumentCount' => '1'
|
||||||
|
@ -1705,7 +1705,7 @@ class PHPExcel_Calculation
|
||||||
|
|
||||||
|
|
||||||
// Internal functions used for special control purposes
|
// Internal functions used for special control purposes
|
||||||
private static $_controlFunctions = array(
|
private static $controlFunctions = array(
|
||||||
'MKMATRIX' => array(
|
'MKMATRIX' => array(
|
||||||
'argumentCount' => '*',
|
'argumentCount' => '*',
|
||||||
'functionCall' => 'self::_mkMatrix'
|
'functionCall' => 'self::_mkMatrix'
|
||||||
|
@ -1716,26 +1716,26 @@ class PHPExcel_Calculation
|
||||||
private function __construct(PHPExcel $workbook = null)
|
private function __construct(PHPExcel $workbook = null)
|
||||||
{
|
{
|
||||||
$setPrecision = (PHP_INT_SIZE == 4) ? 14 : 16;
|
$setPrecision = (PHP_INT_SIZE == 4) ? 14 : 16;
|
||||||
$this->_savedPrecision = ini_get('precision');
|
$this->savedPrecision = ini_get('precision');
|
||||||
if ($this->_savedPrecision < $setPrecision) {
|
if ($this->savedPrecision < $setPrecision) {
|
||||||
ini_set('precision', $setPrecision);
|
ini_set('precision', $setPrecision);
|
||||||
}
|
}
|
||||||
$this->delta = 1 * pow(10, -$setPrecision);
|
$this->delta = 1 * pow(10, -$setPrecision);
|
||||||
|
|
||||||
if ($workbook !== null) {
|
if ($workbook !== null) {
|
||||||
self::$_workbookSets[$workbook->getID()] = $this;
|
self::$workbookSets[$workbook->getID()] = $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_workbook = $workbook;
|
$this->workbook = $workbook;
|
||||||
$this->_cyclicReferenceStack = new PHPExcel_CalcEngine_CyclicReferenceStack();
|
$this->cyclicReferenceStack = new PHPExcel_CalcEngine_CyclicReferenceStack();
|
||||||
$this->_debugLog = new PHPExcel_CalcEngine_Logger($this->_cyclicReferenceStack);
|
$this->_debugLog = new PHPExcel_CalcEngine_Logger($this->cyclicReferenceStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if ($this->_savedPrecision != ini_get('precision')) {
|
if ($this->savedPrecision != ini_get('precision')) {
|
||||||
ini_set('precision', $this->_savedPrecision);
|
ini_set('precision', $this->savedPrecision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1745,7 +1745,7 @@ class PHPExcel_Calculation
|
||||||
foreach (glob($localeFileDirectory.'/*', GLOB_ONLYDIR) as $filename) {
|
foreach (glob($localeFileDirectory.'/*', GLOB_ONLYDIR) as $filename) {
|
||||||
$filename = substr($filename, strlen($localeFileDirectory)+1);
|
$filename = substr($filename, strlen($localeFileDirectory)+1);
|
||||||
if ($filename != 'en') {
|
if ($filename != 'en') {
|
||||||
self::$_validLocaleLanguages[] = $filename;
|
self::$validLocaleLanguages[] = $filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1761,17 +1761,17 @@ class PHPExcel_Calculation
|
||||||
public static function getInstance(PHPExcel $workbook = null)
|
public static function getInstance(PHPExcel $workbook = null)
|
||||||
{
|
{
|
||||||
if ($workbook !== null) {
|
if ($workbook !== null) {
|
||||||
if (isset(self::$_workbookSets[$workbook->getID()])) {
|
if (isset(self::$workbookSets[$workbook->getID()])) {
|
||||||
return self::$_workbookSets[$workbook->getID()];
|
return self::$workbookSets[$workbook->getID()];
|
||||||
}
|
}
|
||||||
return new PHPExcel_Calculation($workbook);
|
return new PHPExcel_Calculation($workbook);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(self::$_instance) || (self::$_instance === null)) {
|
if (!isset(self::$instance) || (self::$instance === null)) {
|
||||||
self::$_instance = new PHPExcel_Calculation();
|
self::$instance = new PHPExcel_Calculation();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$_instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1783,8 +1783,8 @@ class PHPExcel_Calculation
|
||||||
public static function unsetInstance(PHPExcel $workbook = null)
|
public static function unsetInstance(PHPExcel $workbook = null)
|
||||||
{
|
{
|
||||||
if ($workbook !== null) {
|
if ($workbook !== null) {
|
||||||
if (isset(self::$_workbookSets[$workbook->getID()])) {
|
if (isset(self::$workbookSets[$workbook->getID()])) {
|
||||||
unset(self::$_workbookSets[$workbook->getID()]);
|
unset(self::$workbookSets[$workbook->getID()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1833,7 +1833,7 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public static function getTRUE()
|
public static function getTRUE()
|
||||||
{
|
{
|
||||||
return self::$_localeBoolean['TRUE'];
|
return self::$localeBoolean['TRUE'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1844,7 +1844,7 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public static function getFALSE()
|
public static function getFALSE()
|
||||||
{
|
{
|
||||||
return self::$_localeBoolean['FALSE'];
|
return self::$localeBoolean['FALSE'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1886,7 +1886,7 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public function getCalculationCacheEnabled()
|
public function getCalculationCacheEnabled()
|
||||||
{
|
{
|
||||||
return $this->_calculationCacheEnabled;
|
return $this->calculationCacheEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1897,7 +1897,7 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public function setCalculationCacheEnabled($pValue = true)
|
public function setCalculationCacheEnabled($pValue = true)
|
||||||
{
|
{
|
||||||
$this->_calculationCacheEnabled = $pValue;
|
$this->calculationCacheEnabled = $pValue;
|
||||||
$this->clearCalculationCache();
|
$this->clearCalculationCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1925,7 +1925,7 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public function clearCalculationCache()
|
public function clearCalculationCache()
|
||||||
{
|
{
|
||||||
$this->_calculationCache = array();
|
$this->calculationCache = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1935,8 +1935,8 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public function clearCalculationCacheForWorksheet($worksheetName)
|
public function clearCalculationCacheForWorksheet($worksheetName)
|
||||||
{
|
{
|
||||||
if (isset($this->_calculationCache[$worksheetName])) {
|
if (isset($this->calculationCache[$worksheetName])) {
|
||||||
unset($this->_calculationCache[$worksheetName]);
|
unset($this->calculationCache[$worksheetName]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1948,9 +1948,9 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName)
|
public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName)
|
||||||
{
|
{
|
||||||
if (isset($this->_calculationCache[$fromWorksheetName])) {
|
if (isset($this->calculationCache[$fromWorksheetName])) {
|
||||||
$this->_calculationCache[$toWorksheetName] = &$this->_calculationCache[$fromWorksheetName];
|
$this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName];
|
||||||
unset($this->_calculationCache[$fromWorksheetName]);
|
unset($this->calculationCache[$fromWorksheetName]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1962,7 +1962,7 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public function getLocale()
|
public function getLocale()
|
||||||
{
|
{
|
||||||
return self::$_localeLanguage;
|
return self::$localeLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1980,15 +1980,15 @@ class PHPExcel_Calculation
|
||||||
list($language) = explode('_', $locale);
|
list($language) = explode('_', $locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count(self::$_validLocaleLanguages) == 1) {
|
if (count(self::$validLocaleLanguages) == 1) {
|
||||||
self::_loadLocales();
|
self::_loadLocales();
|
||||||
}
|
}
|
||||||
// Test whether we have any language data for this language (any locale)
|
// Test whether we have any language data for this language (any locale)
|
||||||
if (in_array($language, self::$_validLocaleLanguages)) {
|
if (in_array($language, self::$validLocaleLanguages)) {
|
||||||
// initialise language/locale settings
|
// initialise language/locale settings
|
||||||
self::$_localeFunctions = array();
|
self::$localeFunctions = array();
|
||||||
self::$_localeArgumentSeparator = ',';
|
self::$localeArgumentSeparator = ',';
|
||||||
self::$_localeBoolean = array('TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL');
|
self::$localeBoolean = array('TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL');
|
||||||
// Default is English, if user isn't requesting english, then read the necessary data from the locale files
|
// Default is English, if user isn't requesting english, then read the necessary data from the locale files
|
||||||
if ($locale != 'en_us') {
|
if ($locale != 'en_us') {
|
||||||
// Search for a file with a list of function names for locale
|
// Search for a file with a list of function names for locale
|
||||||
|
@ -2008,17 +2008,17 @@ class PHPExcel_Calculation
|
||||||
list($fName, $lfName) = explode('=', $localeFunction);
|
list($fName, $lfName) = explode('=', $localeFunction);
|
||||||
$fName = trim($fName);
|
$fName = trim($fName);
|
||||||
$lfName = trim($lfName);
|
$lfName = trim($lfName);
|
||||||
if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
|
if ((isset(self::$PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
|
||||||
self::$_localeFunctions[$fName] = $lfName;
|
self::$localeFunctions[$fName] = $lfName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Default the TRUE and FALSE constants to the locale names of the TRUE() and FALSE() functions
|
// Default the TRUE and FALSE constants to the locale names of the TRUE() and FALSE() functions
|
||||||
if (isset(self::$_localeFunctions['TRUE'])) {
|
if (isset(self::$localeFunctions['TRUE'])) {
|
||||||
self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE'];
|
self::$localeBoolean['TRUE'] = self::$localeFunctions['TRUE'];
|
||||||
}
|
}
|
||||||
if (isset(self::$_localeFunctions['FALSE'])) {
|
if (isset(self::$localeFunctions['FALSE'])) {
|
||||||
self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE'];
|
self::$localeBoolean['FALSE'] = self::$localeFunctions['FALSE'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'config';
|
$configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'config';
|
||||||
|
@ -2034,7 +2034,7 @@ class PHPExcel_Calculation
|
||||||
$settingName = strtoupper(trim($settingName));
|
$settingName = strtoupper(trim($settingName));
|
||||||
switch ($settingName) {
|
switch ($settingName) {
|
||||||
case 'ARGUMENTSEPARATOR':
|
case 'ARGUMENTSEPARATOR':
|
||||||
self::$_localeArgumentSeparator = trim($settingValue);
|
self::$localeArgumentSeparator = trim($settingValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2044,7 +2044,7 @@ class PHPExcel_Calculation
|
||||||
|
|
||||||
self::$functionReplaceFromExcel = self::$functionReplaceToExcel =
|
self::$functionReplaceFromExcel = self::$functionReplaceToExcel =
|
||||||
self::$functionReplaceFromLocale = self::$functionReplaceToLocale = null;
|
self::$functionReplaceFromLocale = self::$functionReplaceToLocale = null;
|
||||||
self::$_localeLanguage = $locale;
|
self::$localeLanguage = $locale;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -2076,7 +2076,7 @@ class PHPExcel_Calculation
|
||||||
private static function _translateFormula($from, $to, $formula, $fromSeparator, $toSeparator)
|
private static function _translateFormula($from, $to, $formula, $fromSeparator, $toSeparator)
|
||||||
{
|
{
|
||||||
// Convert any Excel function names to the required language
|
// Convert any Excel function names to the required language
|
||||||
if (self::$_localeLanguage !== 'en_us') {
|
if (self::$localeLanguage !== 'en_us') {
|
||||||
$inBraces = false;
|
$inBraces = false;
|
||||||
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
|
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
|
||||||
if (strpos($formula, '"') !== false) {
|
if (strpos($formula, '"') !== false) {
|
||||||
|
@ -2111,10 +2111,10 @@ class PHPExcel_Calculation
|
||||||
{
|
{
|
||||||
if (self::$functionReplaceFromExcel === null) {
|
if (self::$functionReplaceFromExcel === null) {
|
||||||
self::$functionReplaceFromExcel = array();
|
self::$functionReplaceFromExcel = array();
|
||||||
foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) {
|
foreach (array_keys(self::$localeFunctions) as $excelFunctionName) {
|
||||||
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
|
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
|
||||||
}
|
}
|
||||||
foreach (array_keys(self::$_localeBoolean) as $excelBoolean) {
|
foreach (array_keys(self::$localeBoolean) as $excelBoolean) {
|
||||||
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
|
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2122,15 +2122,15 @@ class PHPExcel_Calculation
|
||||||
|
|
||||||
if (self::$functionReplaceToLocale === null) {
|
if (self::$functionReplaceToLocale === null) {
|
||||||
self::$functionReplaceToLocale = array();
|
self::$functionReplaceToLocale = array();
|
||||||
foreach (array_values(self::$_localeFunctions) as $localeFunctionName) {
|
foreach (array_values(self::$localeFunctions) as $localeFunctionName) {
|
||||||
self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
|
self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
|
||||||
}
|
}
|
||||||
foreach (array_values(self::$_localeBoolean) as $localeBoolean) {
|
foreach (array_values(self::$localeBoolean) as $localeBoolean) {
|
||||||
self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2';
|
self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::_translateFormula(self::$functionReplaceFromExcel, self::$functionReplaceToLocale, $formula, ',', self::$_localeArgumentSeparator);
|
return self::_translateFormula(self::$functionReplaceFromExcel, self::$functionReplaceToLocale, $formula, ',', self::$localeArgumentSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2141,35 +2141,35 @@ class PHPExcel_Calculation
|
||||||
{
|
{
|
||||||
if (self::$functionReplaceFromLocale === null) {
|
if (self::$functionReplaceFromLocale === null) {
|
||||||
self::$functionReplaceFromLocale = array();
|
self::$functionReplaceFromLocale = array();
|
||||||
foreach (array_values(self::$_localeFunctions) as $localeFunctionName) {
|
foreach (array_values(self::$localeFunctions) as $localeFunctionName) {
|
||||||
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
|
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
|
||||||
}
|
}
|
||||||
foreach (array_values(self::$_localeBoolean) as $excelBoolean) {
|
foreach (array_values(self::$localeBoolean) as $excelBoolean) {
|
||||||
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
|
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$functionReplaceToExcel === null) {
|
if (self::$functionReplaceToExcel === null) {
|
||||||
self::$functionReplaceToExcel = array();
|
self::$functionReplaceToExcel = array();
|
||||||
foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) {
|
foreach (array_keys(self::$localeFunctions) as $excelFunctionName) {
|
||||||
self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
|
self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
|
||||||
}
|
}
|
||||||
foreach (array_keys(self::$_localeBoolean) as $excelBoolean) {
|
foreach (array_keys(self::$localeBoolean) as $excelBoolean) {
|
||||||
self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2';
|
self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::_translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$_localeArgumentSeparator, ',');
|
return self::_translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$localeArgumentSeparator, ',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function _localeFunc($function)
|
public static function localeFunc($function)
|
||||||
{
|
{
|
||||||
if (self::$_localeLanguage !== 'en_us') {
|
if (self::$localeLanguage !== 'en_us') {
|
||||||
$functionName = trim($function, '(');
|
$functionName = trim($function, '(');
|
||||||
if (isset(self::$_localeFunctions[$functionName])) {
|
if (isset(self::$localeFunctions[$functionName])) {
|
||||||
$brace = ($functionName != $function);
|
$brace = ($functionName != $function);
|
||||||
$function = self::$_localeFunctions[$functionName];
|
$function = self::$localeFunctions[$functionName];
|
||||||
if ($brace) {
|
if ($brace) {
|
||||||
$function .= '(';
|
$function .= '(';
|
||||||
}
|
}
|
||||||
|
@ -2267,24 +2267,24 @@ class PHPExcel_Calculation
|
||||||
// Initialise the logging settings if requested
|
// Initialise the logging settings if requested
|
||||||
$this->formulaError = null;
|
$this->formulaError = null;
|
||||||
$this->_debugLog->clearLog();
|
$this->_debugLog->clearLog();
|
||||||
$this->_cyclicReferenceStack->clear();
|
$this->cyclicReferenceStack->clear();
|
||||||
$this->_cyclicFormulaCount = 1;
|
$this->cyclicFormulaCounter = 1;
|
||||||
|
|
||||||
self::$returnArrayAsType = self::RETURN_ARRAY_AS_ARRAY;
|
self::$returnArrayAsType = self::RETURN_ARRAY_AS_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the calculation for the cell formula
|
// Execute the calculation for the cell formula
|
||||||
$this->_cellStack[] = array(
|
$this->cellStack[] = array(
|
||||||
'sheet' => $pCell->getWorksheet()->getTitle(),
|
'sheet' => $pCell->getWorksheet()->getTitle(),
|
||||||
'cell' => $pCell->getCoordinate(),
|
'cell' => $pCell->getCoordinate(),
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
$result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
|
$result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
|
||||||
$cellAddress = array_pop($this->_cellStack);
|
$cellAddress = array_pop($this->cellStack);
|
||||||
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
|
$this->workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
|
||||||
} catch (PHPExcel_Exception $e) {
|
} catch (PHPExcel_Exception $e) {
|
||||||
$cellAddress = array_pop($this->_cellStack);
|
$cellAddress = array_pop($this->cellStack);
|
||||||
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
|
$this->workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
|
||||||
throw new PHPExcel_Calculation_Exception($e->getMessage());
|
throw new PHPExcel_Calculation_Exception($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2363,12 +2363,12 @@ class PHPExcel_Calculation
|
||||||
// Initialise the logging settings
|
// Initialise the logging settings
|
||||||
$this->formulaError = null;
|
$this->formulaError = null;
|
||||||
$this->_debugLog->clearLog();
|
$this->_debugLog->clearLog();
|
||||||
$this->_cyclicReferenceStack->clear();
|
$this->cyclicReferenceStack->clear();
|
||||||
|
|
||||||
// Disable calculation cacheing because it only applies to cell calculations, not straight formulae
|
// Disable calculation cacheing because it only applies to cell calculations, not straight formulae
|
||||||
// But don't actually flush any cache
|
// But don't actually flush any cache
|
||||||
$resetCache = $this->getCalculationCacheEnabled();
|
$resetCache = $this->getCalculationCacheEnabled();
|
||||||
$this->_calculationCacheEnabled = false;
|
$this->calculationCacheEnabled = false;
|
||||||
// Execute the calculation
|
// Execute the calculation
|
||||||
try {
|
try {
|
||||||
$result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
|
$result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
|
||||||
|
@ -2377,7 +2377,7 @@ class PHPExcel_Calculation
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset calculation cacheing to its previous state
|
// Reset calculation cacheing to its previous state
|
||||||
$this->_calculationCacheEnabled = $resetCache;
|
$this->calculationCacheEnabled = $resetCache;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -2388,10 +2388,10 @@ class PHPExcel_Calculation
|
||||||
// Is calculation cacheing enabled?
|
// Is calculation cacheing enabled?
|
||||||
// Is the value present in calculation cache?
|
// Is the value present in calculation cache?
|
||||||
$this->_debugLog->writeDebugLog('Testing cache value for cell ', $cellReference);
|
$this->_debugLog->writeDebugLog('Testing cache value for cell ', $cellReference);
|
||||||
if (($this->_calculationCacheEnabled) && (isset($this->_calculationCache[$cellReference]))) {
|
if (($this->calculationCacheEnabled) && (isset($this->calculationCache[$cellReference]))) {
|
||||||
$this->_debugLog->writeDebugLog('Retrieving value for cell ', $cellReference, ' from cache');
|
$this->_debugLog->writeDebugLog('Retrieving value for cell ', $cellReference, ' from cache');
|
||||||
// Return the cached result
|
// Return the cached result
|
||||||
$cellValue = $this->_calculationCache[$cellReference];
|
$cellValue = $this->calculationCache[$cellReference];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -2399,8 +2399,8 @@ class PHPExcel_Calculation
|
||||||
|
|
||||||
public function saveValueToCache($cellReference, $cellValue)
|
public function saveValueToCache($cellReference, $cellValue)
|
||||||
{
|
{
|
||||||
if ($this->_calculationCacheEnabled) {
|
if ($this->calculationCacheEnabled) {
|
||||||
$this->_calculationCache[$cellReference] = $cellValue;
|
$this->calculationCache[$cellReference] = $cellValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2436,28 +2436,28 @@ class PHPExcel_Calculation
|
||||||
return $cellValue;
|
return $cellValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsCellReference))) {
|
if (($wsTitle{0} !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) {
|
||||||
if ($this->cyclicFormulaCount <= 0) {
|
if ($this->cyclicFormulaCount <= 0) {
|
||||||
$this->_cyclicFormulaCell = '';
|
$this->cyclicFormulaCell = '';
|
||||||
return $this->_raiseFormulaError('Cyclic Reference in Formula');
|
return $this->_raiseFormulaError('Cyclic Reference in Formula');
|
||||||
} elseif ($this->_cyclicFormulaCell === $wsCellReference) {
|
} elseif ($this->cyclicFormulaCell === $wsCellReference) {
|
||||||
++$this->_cyclicFormulaCount;
|
++$this->cyclicFormulaCounter;
|
||||||
if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
|
if ($this->cyclicFormulaCounter >= $this->cyclicFormulaCount) {
|
||||||
$this->_cyclicFormulaCell = '';
|
$this->cyclicFormulaCell = '';
|
||||||
return $cellValue;
|
return $cellValue;
|
||||||
}
|
}
|
||||||
} elseif ($this->_cyclicFormulaCell == '') {
|
} elseif ($this->cyclicFormulaCell == '') {
|
||||||
if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
|
if ($this->cyclicFormulaCounter >= $this->cyclicFormulaCount) {
|
||||||
return $cellValue;
|
return $cellValue;
|
||||||
}
|
}
|
||||||
$this->_cyclicFormulaCell = $wsCellReference;
|
$this->cyclicFormulaCell = $wsCellReference;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the formula onto the token stack and calculate the value
|
// Parse the formula onto the token stack and calculate the value
|
||||||
$this->_cyclicReferenceStack->push($wsCellReference);
|
$this->cyclicReferenceStack->push($wsCellReference);
|
||||||
$cellValue = $this->_processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell);
|
$cellValue = $this->_processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell);
|
||||||
$this->_cyclicReferenceStack->pop();
|
$this->cyclicReferenceStack->pop();
|
||||||
|
|
||||||
// Save to calculation cache
|
// Save to calculation cache
|
||||||
if ($cellID !== null) {
|
if ($cellID !== null) {
|
||||||
|
@ -2656,7 +2656,7 @@ class PHPExcel_Calculation
|
||||||
} elseif (is_string($value) && (trim($value, '"') == $value)) {
|
} elseif (is_string($value) && (trim($value, '"') == $value)) {
|
||||||
return '"'.$value.'"';
|
return '"'.$value.'"';
|
||||||
} elseif (is_bool($value)) {
|
} elseif (is_bool($value)) {
|
||||||
return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
|
return ($value) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
return PHPExcel_Calculation_Functions::flattenSingleValue($value);
|
||||||
|
@ -2848,11 +2848,11 @@ class PHPExcel_Calculation
|
||||||
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal
|
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal
|
||||||
return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
|
return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
|
||||||
|
|
||||||
} elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
|
} elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
|
||||||
//echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL;
|
//echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL;
|
||||||
while ($stack->count() > 0 &&
|
while ($stack->count() > 0 &&
|
||||||
($o2 = $stack->last()) &&
|
($o2 = $stack->last()) &&
|
||||||
isset(self::$_operators[$o2['value']]) &&
|
isset(self::$operators[$o2['value']]) &&
|
||||||
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
|
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
|
||||||
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
|
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
|
||||||
}
|
}
|
||||||
|
@ -2885,14 +2885,14 @@ class PHPExcel_Calculation
|
||||||
//}
|
//}
|
||||||
$output[] = $d; // Dump the argument count on the output
|
$output[] = $d; // Dump the argument count on the output
|
||||||
$output[] = $stack->pop(); // Pop the function and push onto the output
|
$output[] = $stack->pop(); // Pop the function and push onto the output
|
||||||
if (isset(self::$_controlFunctions[$functionName])) {
|
if (isset(self::$controlFunctions[$functionName])) {
|
||||||
//echo 'Built-in function '.$functionName, PHP_EOL;
|
//echo 'Built-in function '.$functionName, PHP_EOL;
|
||||||
$expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount'];
|
$expectedArgumentCount = self::$controlFunctions[$functionName]['argumentCount'];
|
||||||
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
$functionCall = self::$controlFunctions[$functionName]['functionCall'];
|
||||||
} elseif (isset(self::$_PHPExcelFunctions[$functionName])) {
|
} elseif (isset(self::$PHPExcelFunctions[$functionName])) {
|
||||||
//echo 'PHPExcel function '.$functionName, PHP_EOL;
|
//echo 'PHPExcel function '.$functionName, PHP_EOL;
|
||||||
$expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount'];
|
$expectedArgumentCount = self::$PHPExcelFunctions[$functionName]['argumentCount'];
|
||||||
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
$functionCall = self::$PHPExcelFunctions[$functionName]['functionCall'];
|
||||||
} else { // did we somehow push a non-function on the stack? this should never happen
|
} else { // did we somehow push a non-function on the stack? this should never happen
|
||||||
return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack");
|
return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack");
|
||||||
}
|
}
|
||||||
|
@ -2955,7 +2955,7 @@ class PHPExcel_Calculation
|
||||||
// If we've a comma when we're expecting an operand, then what we actually have is a null operand;
|
// If we've a comma when we're expecting an operand, then what we actually have is a null operand;
|
||||||
// so push a null onto the stack
|
// so push a null onto the stack
|
||||||
if (($expectingOperand) || (!$expectingOperator)) {
|
if (($expectingOperand) || (!$expectingOperator)) {
|
||||||
$output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
|
$output[] = array('type' => 'NULL Value', 'value' => self::$excelConstants['NULL'], 'reference' => null);
|
||||||
}
|
}
|
||||||
// make sure there was a function
|
// make sure there was a function
|
||||||
$d = $stack->last(2);
|
$d = $stack->last(2);
|
||||||
|
@ -2984,7 +2984,7 @@ class PHPExcel_Calculation
|
||||||
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
|
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
|
||||||
$val = preg_replace('/\s/u', '', $val);
|
$val = preg_replace('/\s/u', '', $val);
|
||||||
// echo 'Element '.$val.' is a Function<br />';
|
// echo 'Element '.$val.' is a Function<br />';
|
||||||
if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function
|
if (isset(self::$PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$controlFunctions[strtoupper($matches[1])])) { // it's a function
|
||||||
$stack->push('Function', strtoupper($val));
|
$stack->push('Function', strtoupper($val));
|
||||||
$ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index+$length), $amatch);
|
$ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index+$length), $amatch);
|
||||||
if ($ax) {
|
if ($ax) {
|
||||||
|
@ -3071,13 +3071,13 @@ class PHPExcel_Calculation
|
||||||
// echo 'Casting '.$val.' to integer<br />';
|
// echo 'Casting '.$val.' to integer<br />';
|
||||||
$val = (integer) $val;
|
$val = (integer) $val;
|
||||||
}
|
}
|
||||||
} elseif (isset(self::$_ExcelConstants[trim(strtoupper($val))])) {
|
} elseif (isset(self::$excelConstants[trim(strtoupper($val))])) {
|
||||||
$excelConstant = trim(strtoupper($val));
|
$excelConstant = trim(strtoupper($val));
|
||||||
// echo 'Element '.$excelConstant.' is an Excel Constant<br />';
|
// echo 'Element '.$excelConstant.' is an Excel Constant<br />';
|
||||||
$val = self::$_ExcelConstants[$excelConstant];
|
$val = self::$excelConstants[$excelConstant];
|
||||||
} elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== false) {
|
} elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$localeBoolean)) !== false) {
|
||||||
// echo 'Element '.$localeConstant.' is an Excel Constant<br />';
|
// echo 'Element '.$localeConstant.' is an Excel Constant<br />';
|
||||||
$val = self::$_ExcelConstants[$localeConstant];
|
$val = self::$excelConstants[$localeConstant];
|
||||||
}
|
}
|
||||||
$details = array('type' => 'Value', 'value' => $val, 'reference' => null);
|
$details = array('type' => 'Value', 'value' => $val, 'reference' => null);
|
||||||
if ($localeConstant) {
|
if ($localeConstant) {
|
||||||
|
@ -3091,13 +3091,13 @@ class PHPExcel_Calculation
|
||||||
++$index;
|
++$index;
|
||||||
} elseif ($opCharacter == ')') { // miscellaneous error checking
|
} elseif ($opCharacter == ')') { // miscellaneous error checking
|
||||||
if ($expectingOperand) {
|
if ($expectingOperand) {
|
||||||
$output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => null);
|
$output[] = array('type' => 'NULL Value', 'value' => self::$excelConstants['NULL'], 'reference' => null);
|
||||||
$expectingOperand = false;
|
$expectingOperand = false;
|
||||||
$expectingOperator = true;
|
$expectingOperator = true;
|
||||||
} else {
|
} else {
|
||||||
return $this->_raiseFormulaError("Formula Error: Unexpected ')'");
|
return $this->_raiseFormulaError("Formula Error: Unexpected ')'");
|
||||||
}
|
}
|
||||||
} elseif (isset(self::$_operators[$opCharacter]) && !$expectingOperator) {
|
} elseif (isset(self::$operators[$opCharacter]) && !$expectingOperator) {
|
||||||
return $this->_raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'");
|
return $this->_raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'");
|
||||||
} else { // I don't even want to know what you did to get here
|
} else { // I don't even want to know what you did to get here
|
||||||
return $this->_raiseFormulaError("Formula Error: An unexpected error occured");
|
return $this->_raiseFormulaError("Formula Error: An unexpected error occured");
|
||||||
|
@ -3106,7 +3106,7 @@ class PHPExcel_Calculation
|
||||||
if ($index == strlen($formula)) {
|
if ($index == strlen($formula)) {
|
||||||
// Did we end with an operator?.
|
// Did we end with an operator?.
|
||||||
// Only valid for the % unary operator
|
// Only valid for the % unary operator
|
||||||
if ((isset(self::$_operators[$opCharacter])) && ($opCharacter != '%')) {
|
if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) {
|
||||||
return $this->_raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
|
return $this->_raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -3128,7 +3128,7 @@ class PHPExcel_Calculation
|
||||||
// echo 'Element is an Intersect Operator<br />';
|
// echo 'Element is an Intersect Operator<br />';
|
||||||
while ($stack->count() > 0 &&
|
while ($stack->count() > 0 &&
|
||||||
($o2 = $stack->last()) &&
|
($o2 = $stack->last()) &&
|
||||||
isset(self::$_operators[$o2['value']]) &&
|
isset(self::$operators[$o2['value']]) &&
|
||||||
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
|
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
|
||||||
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
|
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
|
||||||
}
|
}
|
||||||
|
@ -3183,7 +3183,7 @@ class PHPExcel_Calculation
|
||||||
$token = $tokenData['value'];
|
$token = $tokenData['value'];
|
||||||
// echo '<b>Token is '.$token.'</b><br />';
|
// echo '<b>Token is '.$token.'</b><br />';
|
||||||
// if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
|
// if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
|
||||||
if (isset(self::$_binaryOperators[$token])) {
|
if (isset(self::$binaryOperators[$token])) {
|
||||||
// echo 'Token is a binary operator<br />';
|
// echo 'Token is a binary operator<br />';
|
||||||
// We must have two operands, error if we don't
|
// We must have two operands, error if we don't
|
||||||
if (($operand2Data = $stack->pop()) === null) {
|
if (($operand2Data = $stack->pop()) === null) {
|
||||||
|
@ -3256,7 +3256,7 @@ class PHPExcel_Calculation
|
||||||
}
|
}
|
||||||
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
|
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
|
||||||
if ($pCellParent !== null) {
|
if ($pCellParent !== null) {
|
||||||
$cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($sheet1), false);
|
$cellValue = $this->extractCellRange($cellRef, $this->workbook->getSheetByName($sheet1), false);
|
||||||
} else {
|
} else {
|
||||||
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
||||||
}
|
}
|
||||||
|
@ -3285,10 +3285,10 @@ class PHPExcel_Calculation
|
||||||
// (converting the other operand to a matrix if need be); then perform the required
|
// (converting the other operand to a matrix if need be); then perform the required
|
||||||
// matrix operation
|
// matrix operation
|
||||||
if (is_bool($operand1)) {
|
if (is_bool($operand1)) {
|
||||||
$operand1 = ($operand1) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
|
$operand1 = ($operand1) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];
|
||||||
}
|
}
|
||||||
if (is_bool($operand2)) {
|
if (is_bool($operand2)) {
|
||||||
$operand2 = ($operand2) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
|
$operand2 = ($operand2) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];
|
||||||
}
|
}
|
||||||
if ((is_array($operand1)) || (is_array($operand2))) {
|
if ((is_array($operand1)) || (is_array($operand2))) {
|
||||||
// Ensure that both operands are arrays/matrices
|
// Ensure that both operands are arrays/matrices
|
||||||
|
@ -3377,7 +3377,7 @@ class PHPExcel_Calculation
|
||||||
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
|
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
|
||||||
$this->_debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in worksheet ', $matches[2]);
|
$this->_debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in worksheet ', $matches[2]);
|
||||||
if ($pCellParent !== null) {
|
if ($pCellParent !== null) {
|
||||||
$cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), false);
|
$cellValue = $this->extractCellRange($cellRef, $this->workbook->getSheetByName($matches[2]), false);
|
||||||
} else {
|
} else {
|
||||||
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
return $this->_raiseFormulaError('Unable to access Cell Reference');
|
||||||
}
|
}
|
||||||
|
@ -3410,9 +3410,9 @@ class PHPExcel_Calculation
|
||||||
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
|
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
|
||||||
$this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in worksheet ', $matches[2]);
|
$this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in worksheet ', $matches[2]);
|
||||||
if ($pCellParent !== null) {
|
if ($pCellParent !== null) {
|
||||||
$cellSheet = $this->_workbook->getSheetByName($matches[2]);
|
$cellSheet = $this->workbook->getSheetByName($matches[2]);
|
||||||
if ($cellSheet && $cellSheet->cellExists($cellRef)) {
|
if ($cellSheet && $cellSheet->cellExists($cellRef)) {
|
||||||
$cellValue = $this->extractCellRange($cellRef, $this->_workbook->getSheetByName($matches[2]), false);
|
$cellValue = $this->extractCellRange($cellRef, $this->workbook->getSheetByName($matches[2]), false);
|
||||||
$pCell->attach($pCellParent);
|
$pCell->attach($pCellParent);
|
||||||
} else {
|
} else {
|
||||||
$cellValue = null;
|
$cellValue = null;
|
||||||
|
@ -3444,17 +3444,17 @@ class PHPExcel_Calculation
|
||||||
$argCount = $stack->pop();
|
$argCount = $stack->pop();
|
||||||
$argCount = $argCount['value'];
|
$argCount = $argCount['value'];
|
||||||
if ($functionName != 'MKMATRIX') {
|
if ($functionName != 'MKMATRIX') {
|
||||||
$this->_debugLog->writeDebugLog('Evaluating Function ', self::_localeFunc($functionName), '() with ', (($argCount == 0) ? 'no' : $argCount), ' argument', (($argCount == 1) ? '' : 's'));
|
$this->_debugLog->writeDebugLog('Evaluating Function ', self::localeFunc($functionName), '() with ', (($argCount == 0) ? 'no' : $argCount), ' argument', (($argCount == 1) ? '' : 's'));
|
||||||
}
|
}
|
||||||
if ((isset(self::$_PHPExcelFunctions[$functionName])) || (isset(self::$_controlFunctions[$functionName]))) { // function
|
if ((isset(self::$PHPExcelFunctions[$functionName])) || (isset(self::$controlFunctions[$functionName]))) { // function
|
||||||
if (isset(self::$_PHPExcelFunctions[$functionName])) {
|
if (isset(self::$PHPExcelFunctions[$functionName])) {
|
||||||
$functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
|
$functionCall = self::$PHPExcelFunctions[$functionName]['functionCall'];
|
||||||
$passByReference = isset(self::$_PHPExcelFunctions[$functionName]['passByReference']);
|
$passByReference = isset(self::$PHPExcelFunctions[$functionName]['passByReference']);
|
||||||
$passCellReference = isset(self::$_PHPExcelFunctions[$functionName]['passCellReference']);
|
$passCellReference = isset(self::$PHPExcelFunctions[$functionName]['passCellReference']);
|
||||||
} elseif (isset(self::$_controlFunctions[$functionName])) {
|
} elseif (isset(self::$controlFunctions[$functionName])) {
|
||||||
$functionCall = self::$_controlFunctions[$functionName]['functionCall'];
|
$functionCall = self::$controlFunctions[$functionName]['functionCall'];
|
||||||
$passByReference = isset(self::$_controlFunctions[$functionName]['passByReference']);
|
$passByReference = isset(self::$controlFunctions[$functionName]['passByReference']);
|
||||||
$passCellReference = isset(self::$_controlFunctions[$functionName]['passCellReference']);
|
$passCellReference = isset(self::$controlFunctions[$functionName]['passCellReference']);
|
||||||
}
|
}
|
||||||
// get the arguments for this function
|
// get the arguments for this function
|
||||||
// echo 'Function '.$functionName.' expects '.$argCount.' arguments<br />';
|
// echo 'Function '.$functionName.' expects '.$argCount.' arguments<br />';
|
||||||
|
@ -3463,8 +3463,8 @@ class PHPExcel_Calculation
|
||||||
$arg = $stack->pop();
|
$arg = $stack->pop();
|
||||||
$a = $argCount - $i - 1;
|
$a = $argCount - $i - 1;
|
||||||
if (($passByReference) &&
|
if (($passByReference) &&
|
||||||
(isset(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
|
(isset(self::$PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
|
||||||
(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
|
(self::$PHPExcelFunctions[$functionName]['passByReference'][$a])) {
|
||||||
if ($arg['reference'] === null) {
|
if ($arg['reference'] === null) {
|
||||||
$args[] = $cellID;
|
$args[] = $cellID;
|
||||||
if ($functionName != 'MKMATRIX') {
|
if ($functionName != 'MKMATRIX') {
|
||||||
|
@ -3495,7 +3495,7 @@ class PHPExcel_Calculation
|
||||||
if ($functionName != 'MKMATRIX') {
|
if ($functionName != 'MKMATRIX') {
|
||||||
if ($this->_debugLog->getWriteDebugLog()) {
|
if ($this->_debugLog->getWriteDebugLog()) {
|
||||||
krsort($argArrayVals);
|
krsort($argArrayVals);
|
||||||
$this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', implode(self::$_localeArgumentSeparator.' ', PHPExcel_Calculation_Functions::flattenArray($argArrayVals)), ' )');
|
$this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', implode(self::$localeArgumentSeparator.' ', PHPExcel_Calculation_Functions::flattenArray($argArrayVals)), ' )');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Process each argument in turn, building the return value as an array
|
// Process each argument in turn, building the return value as an array
|
||||||
|
@ -3507,16 +3507,16 @@ class PHPExcel_Calculation
|
||||||
// foreach($operand1 as $args) {
|
// foreach($operand1 as $args) {
|
||||||
// if (is_array($args)) {
|
// if (is_array($args)) {
|
||||||
// foreach($args as $arg) {
|
// foreach($args as $arg) {
|
||||||
// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($arg), ' )');
|
// $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', $this->_showValue($arg), ' )');
|
||||||
// $r = call_user_func_array($functionCall, $arg);
|
// $r = call_user_func_array($functionCall, $arg);
|
||||||
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
|
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
|
||||||
// $result[$row][] = $r;
|
// $result[$row][] = $r;
|
||||||
// }
|
// }
|
||||||
// ++$row;
|
// ++$row;
|
||||||
// } else {
|
// } else {
|
||||||
// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($args), ' )');
|
// $this->_debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', $this->_showValue($args), ' )');
|
||||||
// $r = call_user_func_array($functionCall, $args);
|
// $r = call_user_func_array($functionCall, $args);
|
||||||
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
|
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
|
||||||
// $result[] = $r;
|
// $result[] = $r;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -3535,18 +3535,18 @@ class PHPExcel_Calculation
|
||||||
$result = call_user_func_array($functionCall, $args);
|
$result = call_user_func_array($functionCall, $args);
|
||||||
}
|
}
|
||||||
if ($functionName != 'MKMATRIX') {
|
if ($functionName != 'MKMATRIX') {
|
||||||
$this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($result));
|
$this->_debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->_showTypeDetails($result));
|
||||||
}
|
}
|
||||||
$stack->push('Value', self::_wrapResult($result));
|
$stack->push('Value', self::_wrapResult($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// if the token is a number, boolean, string or an Excel error, push it onto the stack
|
// if the token is a number, boolean, string or an Excel error, push it onto the stack
|
||||||
if (isset(self::$_ExcelConstants[strtoupper($token)])) {
|
if (isset(self::$excelConstants[strtoupper($token)])) {
|
||||||
$excelConstant = strtoupper($token);
|
$excelConstant = strtoupper($token);
|
||||||
// echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />';
|
// echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />';
|
||||||
$stack->push('Constant Value', self::$_ExcelConstants[$excelConstant]);
|
$stack->push('Constant Value', self::$excelConstants[$excelConstant]);
|
||||||
$this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
|
$this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->_showTypeDetails(self::$excelConstants[$excelConstant]));
|
||||||
} elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
|
} elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
|
||||||
// echo 'Token is a number, boolean, string, null or an Excel error<br />';
|
// echo 'Token is a number, boolean, string, null or an Excel error<br />';
|
||||||
$stack->push('Value', $token);
|
$stack->push('Value', $token);
|
||||||
|
@ -3828,7 +3828,7 @@ class PHPExcel_Calculation
|
||||||
protected function _raiseFormulaError($errorMessage)
|
protected function _raiseFormulaError($errorMessage)
|
||||||
{
|
{
|
||||||
$this->formulaError = $errorMessage;
|
$this->formulaError = $errorMessage;
|
||||||
$this->_cyclicReferenceStack->clear();
|
$this->cyclicReferenceStack->clear();
|
||||||
if (!$this->suppressFormulaErrors) {
|
if (!$this->suppressFormulaErrors) {
|
||||||
throw new PHPExcel_Calculation_Exception($errorMessage);
|
throw new PHPExcel_Calculation_Exception($errorMessage);
|
||||||
}
|
}
|
||||||
|
@ -3860,7 +3860,7 @@ class PHPExcel_Calculation
|
||||||
list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
|
list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
|
||||||
// echo 'New sheet name is '.$pSheetName, PHP_EOL;
|
// echo 'New sheet name is '.$pSheetName, PHP_EOL;
|
||||||
// echo 'Adjusted Range reference is '.$pRange, PHP_EOL;
|
// echo 'Adjusted Range reference is '.$pRange, PHP_EOL;
|
||||||
$pSheet = $this->_workbook->getSheetByName($pSheetName);
|
$pSheet = $this->workbook->getSheetByName($pSheetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract range
|
// Extract range
|
||||||
|
@ -3918,7 +3918,7 @@ class PHPExcel_Calculation
|
||||||
list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
|
list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
|
||||||
// echo 'New sheet name is '.$pSheetName, PHP_EOL;
|
// echo 'New sheet name is '.$pSheetName, PHP_EOL;
|
||||||
// echo 'Adjusted Range reference is '.$pRange, PHP_EOL;
|
// echo 'Adjusted Range reference is '.$pRange, PHP_EOL;
|
||||||
$pSheet = $this->_workbook->getSheetByName($pSheetName);
|
$pSheet = $this->workbook->getSheetByName($pSheetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Named range?
|
// Named range?
|
||||||
|
@ -3990,8 +3990,8 @@ class PHPExcel_Calculation
|
||||||
public function isImplemented($pFunction = '')
|
public function isImplemented($pFunction = '')
|
||||||
{
|
{
|
||||||
$pFunction = strtoupper($pFunction);
|
$pFunction = strtoupper($pFunction);
|
||||||
if (isset(self::$_PHPExcelFunctions[$pFunction])) {
|
if (isset(self::$PHPExcelFunctions[$pFunction])) {
|
||||||
return (self::$_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY');
|
return (self::$PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY');
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -4007,7 +4007,7 @@ class PHPExcel_Calculation
|
||||||
{
|
{
|
||||||
$returnValue = array();
|
$returnValue = array();
|
||||||
|
|
||||||
foreach (self::$_PHPExcelFunctions as $functionName => $function) {
|
foreach (self::$PHPExcelFunctions as $functionName => $function) {
|
||||||
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
|
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
|
||||||
$returnValue[$functionName] = new PHPExcel_Calculation_Function(
|
$returnValue[$functionName] = new PHPExcel_Calculation_Function(
|
||||||
$function['category'],
|
$function['category'],
|
||||||
|
@ -4028,7 +4028,7 @@ class PHPExcel_Calculation
|
||||||
*/
|
*/
|
||||||
public function listAllFunctionNames()
|
public function listAllFunctionNames()
|
||||||
{
|
{
|
||||||
return array_keys(self::$_PHPExcelFunctions);
|
return array_keys(self::$PHPExcelFunctions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4039,7 +4039,7 @@ class PHPExcel_Calculation
|
||||||
public function listFunctionNames()
|
public function listFunctionNames()
|
||||||
{
|
{
|
||||||
$returnValue = array();
|
$returnValue = array();
|
||||||
foreach (self::$_PHPExcelFunctions as $functionName => $function) {
|
foreach (self::$PHPExcelFunctions as $functionName => $function) {
|
||||||
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
|
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
|
||||||
$returnValue[] = $functionName;
|
$returnValue[] = $functionName;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ class PHPExcel_Calculation_Token_Stack
|
||||||
'reference' => $reference
|
'reference' => $reference
|
||||||
);
|
);
|
||||||
if ($type == 'Function') {
|
if ($type == 'Function') {
|
||||||
$localeFunction = PHPExcel_Calculation::_localeFunc($value);
|
$localeFunction = PHPExcel_Calculation::localeFunc($value);
|
||||||
if ($localeFunction != $value) {
|
if ($localeFunction != $value) {
|
||||||
$this->stack[($this->count - 1)]['localeValue'] = $localeFunction;
|
$this->stack[($this->count - 1)]['localeValue'] = $localeFunction;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,14 +40,14 @@ class PHPExcel_Cell
|
||||||
*
|
*
|
||||||
* @var PHPExcel_Cell_IValueBinder
|
* @var PHPExcel_Cell_IValueBinder
|
||||||
*/
|
*/
|
||||||
private static $_valueBinder;
|
private static $valueBinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of the cell
|
* Value of the cell
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
*/
|
*/
|
||||||
private $_value;
|
private $value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculated value of the cell (used for caching)
|
* Calculated value of the cell (used for caching)
|
||||||
|
@ -59,34 +59,34 @@ class PHPExcel_Cell
|
||||||
*
|
*
|
||||||
* @var mixed
|
* @var mixed
|
||||||
*/
|
*/
|
||||||
private $_calculatedValue;
|
private $calculatedValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of the cell data
|
* Type of the cell data
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $_dataType;
|
private $dataType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent worksheet
|
* Parent worksheet
|
||||||
*
|
*
|
||||||
* @var PHPExcel_CachedObjectStorage_CacheBase
|
* @var PHPExcel_CachedObjectStorage_CacheBase
|
||||||
*/
|
*/
|
||||||
private $_parent;
|
private $parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Index to cellXf
|
* Index to cellXf
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $_xfIndex = 0;
|
private $xfIndex = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attributes of the formula
|
* Attributes of the formula
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private $_formulaAttributes;
|
private $formulaAttributes;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,19 +96,19 @@ class PHPExcel_Cell
|
||||||
**/
|
**/
|
||||||
public function notifyCacheController()
|
public function notifyCacheController()
|
||||||
{
|
{
|
||||||
$this->_parent->updateCacheData($this);
|
$this->parent->updateCacheData($this);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function detach()
|
public function detach()
|
||||||
{
|
{
|
||||||
$this->_parent = null;
|
$this->parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent)
|
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent)
|
||||||
{
|
{
|
||||||
$this->_parent = $parent;
|
$this->parent = $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,17 +123,17 @@ class PHPExcel_Cell
|
||||||
public function __construct($pValue = null, $pDataType = null, PHPExcel_Worksheet $pSheet = null)
|
public function __construct($pValue = null, $pDataType = null, PHPExcel_Worksheet $pSheet = null)
|
||||||
{
|
{
|
||||||
// Initialise cell value
|
// Initialise cell value
|
||||||
$this->_value = $pValue;
|
$this->value = $pValue;
|
||||||
|
|
||||||
// Set worksheet cache
|
// Set worksheet cache
|
||||||
$this->_parent = $pSheet->getCellCacheController();
|
$this->parent = $pSheet->getCellCacheController();
|
||||||
|
|
||||||
// Set datatype?
|
// Set datatype?
|
||||||
if ($pDataType !== null) {
|
if ($pDataType !== null) {
|
||||||
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) {
|
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) {
|
||||||
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
}
|
}
|
||||||
$this->_dataType = $pDataType;
|
$this->dataType = $pDataType;
|
||||||
} elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
|
} elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
|
||||||
throw new PHPExcel_Exception("Value could not be bound to cell.");
|
throw new PHPExcel_Exception("Value could not be bound to cell.");
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getColumn()
|
public function getColumn()
|
||||||
{
|
{
|
||||||
return $this->_parent->getCurrentColumn();
|
return $this->parent->getCurrentColumn();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +156,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getRow()
|
public function getRow()
|
||||||
{
|
{
|
||||||
return $this->_parent->getCurrentRow();
|
return $this->parent->getCurrentRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +166,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getCoordinate()
|
public function getCoordinate()
|
||||||
{
|
{
|
||||||
return $this->_parent->getCurrentAddress();
|
return $this->parent->getCurrentAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,7 +176,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getValue()
|
public function getValue()
|
||||||
{
|
{
|
||||||
return $this->_value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -223,7 +223,7 @@ class PHPExcel_Cell
|
||||||
// set the value according to data type
|
// set the value according to data type
|
||||||
switch ($pDataType) {
|
switch ($pDataType) {
|
||||||
case PHPExcel_Cell_DataType::TYPE_NULL:
|
case PHPExcel_Cell_DataType::TYPE_NULL:
|
||||||
$this->_value = $pValue;
|
$this->value = $pValue;
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Cell_DataType::TYPE_STRING2:
|
case PHPExcel_Cell_DataType::TYPE_STRING2:
|
||||||
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
|
@ -231,19 +231,19 @@ class PHPExcel_Cell
|
||||||
// Synonym for string
|
// Synonym for string
|
||||||
case PHPExcel_Cell_DataType::TYPE_INLINE:
|
case PHPExcel_Cell_DataType::TYPE_INLINE:
|
||||||
// Rich text
|
// Rich text
|
||||||
$this->_value = PHPExcel_Cell_DataType::checkString($pValue);
|
$this->value = PHPExcel_Cell_DataType::checkString($pValue);
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
|
case PHPExcel_Cell_DataType::TYPE_NUMERIC:
|
||||||
$this->_value = (float) $pValue;
|
$this->value = (float) $pValue;
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Cell_DataType::TYPE_FORMULA:
|
case PHPExcel_Cell_DataType::TYPE_FORMULA:
|
||||||
$this->_value = (string) $pValue;
|
$this->value = (string) $pValue;
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Cell_DataType::TYPE_BOOL:
|
case PHPExcel_Cell_DataType::TYPE_BOOL:
|
||||||
$this->_value = (bool) $pValue;
|
$this->value = (bool) $pValue;
|
||||||
break;
|
break;
|
||||||
case PHPExcel_Cell_DataType::TYPE_ERROR:
|
case PHPExcel_Cell_DataType::TYPE_ERROR:
|
||||||
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
|
$this->value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
|
throw new PHPExcel_Exception('Invalid datatype: ' . $pDataType);
|
||||||
|
@ -251,7 +251,7 @@ class PHPExcel_Cell
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the datatype
|
// set the datatype
|
||||||
$this->_dataType = $pDataType;
|
$this->dataType = $pDataType;
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
}
|
}
|
||||||
|
@ -267,8 +267,8 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getCalculatedValue($resetLog = true)
|
public function getCalculatedValue($resetLog = true)
|
||||||
{
|
{
|
||||||
//echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL;
|
//echo 'Cell '.$this->getCoordinate().' value is a '.$this->dataType.' with a value of '.$this->getValue().PHP_EOL;
|
||||||
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
if ($this->dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
|
||||||
try {
|
try {
|
||||||
//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL;
|
//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL;
|
||||||
$result = PHPExcel_Calculation::getInstance(
|
$result = PHPExcel_Calculation::getInstance(
|
||||||
|
@ -282,9 +282,9 @@ class PHPExcel_Cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (PHPExcel_Exception $ex) {
|
} catch (PHPExcel_Exception $ex) {
|
||||||
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== null)) {
|
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->calculatedValue !== null)) {
|
||||||
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
//echo 'Returning fallback value of '.$this->calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $this->_calculatedValue; // Fallback for calculations referencing external files.
|
return $this->calculatedValue; // Fallback for calculations referencing external files.
|
||||||
}
|
}
|
||||||
//echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL;
|
//echo 'Calculation Exception: '.$ex->getMessage().PHP_EOL;
|
||||||
$result = '#N/A';
|
$result = '#N/A';
|
||||||
|
@ -294,17 +294,17 @@ class PHPExcel_Cell
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result === '#Not Yet Implemented') {
|
if ($result === '#Not Yet Implemented') {
|
||||||
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
//echo 'Returning fallback value of '.$this->calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $this->_calculatedValue; // Fallback if calculation engine does not support the formula.
|
return $this->calculatedValue; // Fallback if calculation engine does not support the formula.
|
||||||
}
|
}
|
||||||
//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL;
|
//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL;
|
||||||
return $result;
|
return $result;
|
||||||
} elseif ($this->_value instanceof PHPExcel_RichText) {
|
} elseif ($this->value instanceof PHPExcel_RichText) {
|
||||||
// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'<br />';
|
// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->value.'<br />';
|
||||||
return $this->_value->getPlainText();
|
return $this->value->getPlainText();
|
||||||
}
|
}
|
||||||
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->_value.'<br />';
|
// echo 'Cell value for '.$this->getCoordinate().' is not a formula: Returning data value of '.$this->value.'<br />';
|
||||||
return $this->_value;
|
return $this->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -316,7 +316,7 @@ class PHPExcel_Cell
|
||||||
public function setCalculatedValue($pValue = null)
|
public function setCalculatedValue($pValue = null)
|
||||||
{
|
{
|
||||||
if ($pValue !== null) {
|
if ($pValue !== null) {
|
||||||
$this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
|
$this->calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
|
@ -334,7 +334,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getOldCalculatedValue()
|
public function getOldCalculatedValue()
|
||||||
{
|
{
|
||||||
return $this->_calculatedValue;
|
return $this->calculatedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -344,7 +344,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getDataType()
|
public function getDataType()
|
||||||
{
|
{
|
||||||
return $this->_dataType;
|
return $this->dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -358,7 +358,7 @@ class PHPExcel_Cell
|
||||||
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) {
|
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) {
|
||||||
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
|
||||||
}
|
}
|
||||||
$this->_dataType = $pDataType;
|
$this->dataType = $pDataType;
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
}
|
}
|
||||||
|
@ -370,7 +370,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function isFormula()
|
public function isFormula()
|
||||||
{
|
{
|
||||||
return $this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA;
|
return $this->dataType == PHPExcel_Cell_DataType::TYPE_FORMULA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -381,7 +381,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function hasDataValidation()
|
public function hasDataValidation()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
if (!isset($this->parent)) {
|
||||||
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot check for data validation when cell is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getDataValidation()
|
public function getDataValidation()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
if (!isset($this->parent)) {
|
||||||
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot get data validation for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null)
|
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null)
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
if (!isset($this->parent)) {
|
||||||
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +429,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function hasHyperlink()
|
public function hasHyperlink()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
if (!isset($this->parent)) {
|
||||||
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot check for hyperlink when cell is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getHyperlink()
|
public function getHyperlink()
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
if (!isset($this->parent)) {
|
||||||
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot get hyperlink for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null)
|
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null)
|
||||||
{
|
{
|
||||||
if (!isset($this->_parent)) {
|
if (!isset($this->parent)) {
|
||||||
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
|
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +476,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return $this->_parent;
|
return $this->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -486,7 +486,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getWorksheet()
|
public function getWorksheet()
|
||||||
{
|
{
|
||||||
return $this->_parent->getParent();
|
return $this->parent->getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -549,7 +549,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function rebindParent(PHPExcel_Worksheet $parent)
|
public function rebindParent(PHPExcel_Worksheet $parent)
|
||||||
{
|
{
|
||||||
$this->_parent = $parent->getCellCacheController();
|
$this->parent = $parent->getCellCacheController();
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
}
|
}
|
||||||
|
@ -943,11 +943,11 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public static function getValueBinder()
|
public static function getValueBinder()
|
||||||
{
|
{
|
||||||
if (self::$_valueBinder === null) {
|
if (self::$valueBinder === null) {
|
||||||
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder();
|
self::$valueBinder = new PHPExcel_Cell_DefaultValueBinder();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$_valueBinder;
|
return self::$valueBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -962,7 +962,7 @@ class PHPExcel_Cell
|
||||||
throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
|
throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_valueBinder = $binder;
|
self::$valueBinder = $binder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -972,7 +972,7 @@ class PHPExcel_Cell
|
||||||
{
|
{
|
||||||
$vars = get_object_vars($this);
|
$vars = get_object_vars($this);
|
||||||
foreach ($vars as $key => $value) {
|
foreach ($vars as $key => $value) {
|
||||||
if ((is_object($value)) && ($key != '_parent')) {
|
if ((is_object($value)) && ($key != 'parent')) {
|
||||||
$this->$key = clone $value;
|
$this->$key = clone $value;
|
||||||
} else {
|
} else {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
|
@ -987,7 +987,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getXfIndex()
|
public function getXfIndex()
|
||||||
{
|
{
|
||||||
return $this->_xfIndex;
|
return $this->xfIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -998,7 +998,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function setXfIndex($pValue = 0)
|
public function setXfIndex($pValue = 0)
|
||||||
{
|
{
|
||||||
$this->_xfIndex = $pValue;
|
$this->xfIndex = $pValue;
|
||||||
|
|
||||||
return $this->notifyCacheController();
|
return $this->notifyCacheController();
|
||||||
}
|
}
|
||||||
|
@ -1008,7 +1008,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function setFormulaAttributes($pAttributes)
|
public function setFormulaAttributes($pAttributes)
|
||||||
{
|
{
|
||||||
$this->_formulaAttributes = $pAttributes;
|
$this->formulaAttributes = $pAttributes;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,7 +1017,7 @@ class PHPExcel_Cell
|
||||||
*/
|
*/
|
||||||
public function getFormulaAttributes()
|
public function getFormulaAttributes()
|
||||||
{
|
{
|
||||||
return $this->_formulaAttributes;
|
return $this->formulaAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,39 +58,41 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
|
|
||||||
private $graph;
|
private $graph;
|
||||||
|
|
||||||
private static $_plotColour = 0;
|
private static $plotColour = 0;
|
||||||
|
|
||||||
private static $_plotMark = 0;
|
private static $plotMark = 0;
|
||||||
|
|
||||||
|
|
||||||
private function formatPointMarker($seriesPlot, $markerID) {
|
private function formatPointMarker($seriesPlot, $markerID)
|
||||||
|
{
|
||||||
$plotMarkKeys = array_keys(self::$markSet);
|
$plotMarkKeys = array_keys(self::$markSet);
|
||||||
if (is_null($markerID)) {
|
if (is_null($markerID)) {
|
||||||
// Use default plot marker (next marker in the series)
|
// Use default plot marker (next marker in the series)
|
||||||
self::$_plotMark %= count(self::$markSet);
|
self::$plotMark %= count(self::$markSet);
|
||||||
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$_plotMark++]]);
|
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$plotMark++]]);
|
||||||
} elseif ($markerID !== 'none') {
|
} elseif ($markerID !== 'none') {
|
||||||
// Use specified plot marker (if it exists)
|
// Use specified plot marker (if it exists)
|
||||||
if (isset(self::$markSet[$markerID])) {
|
if (isset(self::$markSet[$markerID])) {
|
||||||
$seriesPlot->mark->SetType(self::$markSet[$markerID]);
|
$seriesPlot->mark->SetType(self::$markSet[$markerID]);
|
||||||
} else {
|
} else {
|
||||||
// If the specified plot marker doesn't exist, use default plot marker (next marker in the series)
|
// If the specified plot marker doesn't exist, use default plot marker (next marker in the series)
|
||||||
self::$_plotMark %= count(self::$markSet);
|
self::$plotMark %= count(self::$markSet);
|
||||||
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$_plotMark++]]);
|
$seriesPlot->mark->SetType(self::$markSet[$plotMarkKeys[self::$plotMark++]]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Hide plot marker
|
// Hide plot marker
|
||||||
$seriesPlot->mark->Hide();
|
$seriesPlot->mark->Hide();
|
||||||
}
|
}
|
||||||
$seriesPlot->mark->SetColor(self::$colourSet[self::$_plotColour]);
|
$seriesPlot->mark->SetColor(self::$colourSet[self::$plotColour]);
|
||||||
$seriesPlot->mark->SetFillColor(self::$colourSet[self::$_plotColour]);
|
$seriesPlot->mark->SetFillColor(self::$colourSet[self::$plotColour]);
|
||||||
$seriesPlot->SetColor(self::$colourSet[self::$_plotColour++]);
|
$seriesPlot->SetColor(self::$colourSet[self::$plotColour++]);
|
||||||
|
|
||||||
return $seriesPlot;
|
return $seriesPlot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '') {
|
private function formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '')
|
||||||
|
{
|
||||||
$datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
|
$datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode();
|
||||||
if (!is_null($datasetLabelFormatCode)) {
|
if (!is_null($datasetLabelFormatCode)) {
|
||||||
// Retrieve any label formatting code
|
// Retrieve any label formatting code
|
||||||
|
@ -119,7 +121,8 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _percentageSumCalculation($groupID, $seriesCount) {
|
private function percentageSumCalculation($groupID, $seriesCount)
|
||||||
|
{
|
||||||
// Adjust our values to a percentage value across all series in the group
|
// Adjust our values to a percentage value across all series in the group
|
||||||
for ($i = 0; $i < $seriesCount; ++$i) {
|
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||||
if ($i == 0) {
|
if ($i == 0) {
|
||||||
|
@ -137,21 +140,23 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sumValues;
|
return $sumValues;
|
||||||
} // function _percentageSumCalculation()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _percentageAdjustValues($dataValues, $sumValues) {
|
private function percentageAdjustValues($dataValues, $sumValues)
|
||||||
|
{
|
||||||
foreach ($dataValues as $k => $dataValue) {
|
foreach ($dataValues as $k => $dataValue) {
|
||||||
$dataValues[$k] = $dataValue / $sumValues[$k] * 100;
|
$dataValues[$k] = $dataValue / $sumValues[$k] * 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dataValues;
|
return $dataValues;
|
||||||
} // function _percentageAdjustValues()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _getCaption($captionElement) {
|
private function getCaption($captionElement)
|
||||||
|
{
|
||||||
// Read any caption
|
// Read any caption
|
||||||
$caption = (!is_null($captionElement)) ? $captionElement->getCaption() : NULL;
|
$caption = (!is_null($captionElement)) ? $captionElement->getCaption() : null;
|
||||||
// Test if we have a title caption to display
|
// Test if we have a title caption to display
|
||||||
if (!is_null($caption)) {
|
if (!is_null($caption)) {
|
||||||
// If we do, it could be a plain string or an array
|
// If we do, it could be a plain string or an array
|
||||||
|
@ -161,18 +166,20 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $caption;
|
return $caption;
|
||||||
} // function _getCaption()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderTitle() {
|
private function renderTitle()
|
||||||
$title = $this->_getCaption($this->chart->getTitle());
|
{
|
||||||
|
$title = $this->getCaption($this->chart->getTitle());
|
||||||
if (!is_null($title)) {
|
if (!is_null($title)) {
|
||||||
$this->graph->title->Set($title);
|
$this->graph->title->Set($title);
|
||||||
}
|
}
|
||||||
} // function _renderTitle()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderLegend() {
|
private function renderLegend()
|
||||||
|
{
|
||||||
$legend = $this->chart->getLegend();
|
$legend = $this->chart->getLegend();
|
||||||
if (!is_null($legend)) {
|
if (!is_null($legend)) {
|
||||||
$legendPosition = $legend->getPosition();
|
$legendPosition = $legend->getPosition();
|
||||||
|
@ -200,14 +207,15 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
} else {
|
} else {
|
||||||
$this->graph->legend->Hide();
|
$this->graph->legend->Hide();
|
||||||
}
|
}
|
||||||
} // function _renderLegend()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderCartesianPlotArea($type='textlin') {
|
private function renderCartesianPlotArea($type = 'textlin')
|
||||||
|
{
|
||||||
$this->graph = new Graph(self::$width, self::$height);
|
$this->graph = new Graph(self::$width, self::$height);
|
||||||
$this->graph->SetScale($type);
|
$this->graph->SetScale($type);
|
||||||
|
|
||||||
$this->_renderTitle();
|
$this->renderTitle();
|
||||||
|
|
||||||
// Rotate for bar rather than column chart
|
// Rotate for bar rather than column chart
|
||||||
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection();
|
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection();
|
||||||
|
@ -215,7 +223,7 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
|
|
||||||
$xAxisLabel = $this->chart->getXAxisLabel();
|
$xAxisLabel = $this->chart->getXAxisLabel();
|
||||||
if (!is_null($xAxisLabel)) {
|
if (!is_null($xAxisLabel)) {
|
||||||
$title = $this->_getCaption($xAxisLabel);
|
$title = $this->getCaption($xAxisLabel);
|
||||||
if (!is_null($title)) {
|
if (!is_null($title)) {
|
||||||
$this->graph->xaxis->SetTitle($title, 'center');
|
$this->graph->xaxis->SetTitle($title, 'center');
|
||||||
$this->graph->xaxis->title->SetMargin(35);
|
$this->graph->xaxis->title->SetMargin(35);
|
||||||
|
@ -228,7 +236,7 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
|
|
||||||
$yAxisLabel = $this->chart->getYAxisLabel();
|
$yAxisLabel = $this->chart->getYAxisLabel();
|
||||||
if (!is_null($yAxisLabel)) {
|
if (!is_null($yAxisLabel)) {
|
||||||
$title = $this->_getCaption($yAxisLabel);
|
$title = $this->getCaption($yAxisLabel);
|
||||||
if (!is_null($title)) {
|
if (!is_null($title)) {
|
||||||
$this->graph->yaxis->SetTitle($title, 'center');
|
$this->graph->yaxis->SetTitle($title, 'center');
|
||||||
if ($reverse) {
|
if ($reverse) {
|
||||||
|
@ -237,25 +245,28 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // function _renderCartesianPlotArea()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderPiePlotArea($doughnut = False) {
|
private function renderPiePlotArea($doughnut = false)
|
||||||
|
{
|
||||||
$this->graph = new PieGraph(self::$width, self::$height);
|
$this->graph = new PieGraph(self::$width, self::$height);
|
||||||
|
|
||||||
$this->_renderTitle();
|
$this->renderTitle();
|
||||||
} // function _renderPiePlotArea()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderRadarPlotArea() {
|
private function renderRadarPlotArea()
|
||||||
|
{
|
||||||
$this->graph = new RadarGraph(self::$width, self::$height);
|
$this->graph = new RadarGraph(self::$width, self::$height);
|
||||||
$this->graph->SetScale('lin');
|
$this->graph->SetScale('lin');
|
||||||
|
|
||||||
$this->_renderTitle();
|
$this->renderTitle();
|
||||||
} // function _renderRadarPlotArea()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') {
|
private function renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d')
|
||||||
|
{
|
||||||
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||||
|
|
||||||
$labelCount = count($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
|
$labelCount = count($this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount());
|
||||||
|
@ -268,7 +279,7 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||||
$seriesPlots = array();
|
$seriesPlots = array();
|
||||||
if ($grouping == 'percentStacked') {
|
if ($grouping == 'percentStacked') {
|
||||||
$sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
|
$sumValues = $this->percentageSumCalculation($groupID, $seriesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through each data series in turn
|
// Loop through each data series in turn
|
||||||
|
@ -277,7 +288,7 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
$marker = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
|
||||||
|
|
||||||
if ($grouping == 'percentStacked') {
|
if ($grouping == 'percentStacked') {
|
||||||
$dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
|
$dataValues = $this->percentageAdjustValues($dataValues, $sumValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in any missing values in the $dataValues array
|
// Fill in any missing values in the $dataValues array
|
||||||
|
@ -298,7 +309,7 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
if ($filled) {
|
if ($filled) {
|
||||||
$seriesPlot->SetFilled(true);
|
$seriesPlot->SetFilled(true);
|
||||||
$seriesPlot->SetColor('black');
|
$seriesPlot->SetColor('black');
|
||||||
$seriesPlot->SetFillColor(self::$colourSet[self::$_plotColour++]);
|
$seriesPlot->SetFillColor(self::$colourSet[self::$plotColour++]);
|
||||||
} else {
|
} else {
|
||||||
// Set the appropriate plot marker
|
// Set the appropriate plot marker
|
||||||
$this->formatPointMarker($seriesPlot, $marker);
|
$this->formatPointMarker($seriesPlot, $marker);
|
||||||
|
@ -315,10 +326,11 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$groupPlot = new AccLinePlot($seriesPlots);
|
$groupPlot = new AccLinePlot($seriesPlots);
|
||||||
}
|
}
|
||||||
$this->graph->Add($groupPlot);
|
$this->graph->Add($groupPlot);
|
||||||
} // function _renderPlotLine()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderPlotBar($groupID, $dimensions = '2d') {
|
private function renderPlotBar($groupID, $dimensions = '2d')
|
||||||
|
{
|
||||||
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
|
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection();
|
||||||
// Rotate for bar rather than column chart
|
// Rotate for bar rather than column chart
|
||||||
if (($groupID == 0) && ($rotation == 'bar')) {
|
if (($groupID == 0) && ($rotation == 'bar')) {
|
||||||
|
@ -344,14 +356,14 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||||
$seriesPlots = array();
|
$seriesPlots = array();
|
||||||
if ($grouping == 'percentStacked') {
|
if ($grouping == 'percentStacked') {
|
||||||
$sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
|
$sumValues = $this->percentageSumCalculation($groupID, $seriesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through each data series in turn
|
// Loop through each data series in turn
|
||||||
for ($j = 0; $j < $seriesCount; ++$j) {
|
for ($j = 0; $j < $seriesCount; ++$j) {
|
||||||
$dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
|
$dataValues = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
|
||||||
if ($grouping == 'percentStacked') {
|
if ($grouping == 'percentStacked') {
|
||||||
$dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
|
$dataValues = $this->percentageAdjustValues($dataValues, $sumValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill in any missing values in the $dataValues array
|
// Fill in any missing values in the $dataValues array
|
||||||
|
@ -370,7 +382,7 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
}
|
}
|
||||||
$seriesPlot = new BarPlot($dataValues);
|
$seriesPlot = new BarPlot($dataValues);
|
||||||
$seriesPlot->SetColor('black');
|
$seriesPlot->SetColor('black');
|
||||||
$seriesPlot->SetFillColor(self::$colourSet[self::$_plotColour++]);
|
$seriesPlot->SetFillColor(self::$colourSet[self::$plotColour++]);
|
||||||
if ($dimensions == '3d') {
|
if ($dimensions == '3d') {
|
||||||
$seriesPlot->SetShadow();
|
$seriesPlot->SetShadow();
|
||||||
}
|
}
|
||||||
|
@ -400,10 +412,11 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->graph->Add($groupPlot);
|
$this->graph->Add($groupPlot);
|
||||||
} // function _renderPlotBar()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderPlotScatter($groupID, $bubble) {
|
private function renderPlotScatter($groupID, $bubble)
|
||||||
|
{
|
||||||
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
$grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
|
||||||
$scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
$scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||||
|
|
||||||
|
@ -422,12 +435,12 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
|
$seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
|
||||||
if ($scatterStyle == 'lineMarker') {
|
if ($scatterStyle == 'lineMarker') {
|
||||||
$seriesPlot->SetLinkPoints();
|
$seriesPlot->SetLinkPoints();
|
||||||
$seriesPlot->link->SetColor(self::$colourSet[self::$_plotColour]);
|
$seriesPlot->link->SetColor(self::$colourSet[self::$plotColour]);
|
||||||
} elseif ($scatterStyle == 'smoothMarker') {
|
} elseif ($scatterStyle == 'smoothMarker') {
|
||||||
$spline = new Spline($dataValuesY, $dataValuesX);
|
$spline = new Spline($dataValuesY, $dataValuesX);
|
||||||
list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$width / 20);
|
list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$width / 20);
|
||||||
$lplot = new LinePlot($splineDataX, $splineDataY);
|
$lplot = new LinePlot($splineDataX, $splineDataY);
|
||||||
$lplot->SetColor(self::$colourSet[self::$_plotColour]);
|
$lplot->SetColor(self::$colourSet[self::$plotColour]);
|
||||||
|
|
||||||
$this->graph->Add($lplot);
|
$this->graph->Add($lplot);
|
||||||
}
|
}
|
||||||
|
@ -445,10 +458,11 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
|
|
||||||
$this->graph->Add($seriesPlot);
|
$this->graph->Add($seriesPlot);
|
||||||
}
|
}
|
||||||
} // function _renderPlotScatter()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderPlotRadar($groupID) {
|
private function renderPlotRadar($groupID)
|
||||||
|
{
|
||||||
$radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
$radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||||
|
|
||||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||||
|
@ -474,19 +488,20 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$seriesPlot = new RadarPlot(array_reverse($dataValuesX));
|
$seriesPlot = new RadarPlot(array_reverse($dataValuesX));
|
||||||
|
|
||||||
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
$dataLabel = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
|
||||||
$seriesPlot->SetColor(self::$colourSet[self::$_plotColour++]);
|
$seriesPlot->SetColor(self::$colourSet[self::$plotColour++]);
|
||||||
if ($radarStyle == 'filled') {
|
if ($radarStyle == 'filled') {
|
||||||
$seriesPlot->SetFillColor(self::$colourSet[self::$_plotColour]);
|
$seriesPlot->SetFillColor(self::$colourSet[self::$plotColour]);
|
||||||
}
|
}
|
||||||
$this->formatPointMarker($seriesPlot, $marker);
|
$this->formatPointMarker($seriesPlot, $marker);
|
||||||
$seriesPlot->SetLegend($dataLabel);
|
$seriesPlot->SetLegend($dataLabel);
|
||||||
|
|
||||||
$this->graph->Add($seriesPlot);
|
$this->graph->Add($seriesPlot);
|
||||||
}
|
}
|
||||||
} // function _renderPlotRadar()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderPlotContour($groupID) {
|
private function renderPlotContour($groupID)
|
||||||
|
{
|
||||||
$contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
$contourStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
|
||||||
|
|
||||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||||
|
@ -503,10 +518,11 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$seriesPlot = new ContourPlot($dataValues);
|
$seriesPlot = new ContourPlot($dataValues);
|
||||||
|
|
||||||
$this->graph->Add($seriesPlot);
|
$this->graph->Add($seriesPlot);
|
||||||
} // function _renderPlotContour()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderPlotStock($groupID) {
|
private function renderPlotStock($groupID)
|
||||||
|
{
|
||||||
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
$seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
|
||||||
$plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
|
$plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder();
|
||||||
|
|
||||||
|
@ -524,8 +540,8 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
|
|
||||||
$dataValuesPlot = array();
|
$dataValuesPlot = array();
|
||||||
// Flatten the plot arrays to a single dimensional array to work with jpgraph
|
// Flatten the plot arrays to a single dimensional array to work with jpgraph
|
||||||
for($j = 0; $j < count($dataValues[0]); $j++) {
|
for ($j = 0; $j < count($dataValues[0]); ++$j) {
|
||||||
for($i = 0; $i < $seriesCount; $i++) {
|
for ($i = 0; $i < $seriesCount; ++$i) {
|
||||||
$dataValuesPlot[] = $dataValues[$i][$j];
|
$dataValuesPlot[] = $dataValues[$i][$j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -542,73 +558,79 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$seriesPlot->SetWidth(20);
|
$seriesPlot->SetWidth(20);
|
||||||
|
|
||||||
$this->graph->Add($seriesPlot);
|
$this->graph->Add($seriesPlot);
|
||||||
} // function _renderPlotStock()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderAreaChart($groupCount, $dimensions = '2d') {
|
private function renderAreaChart($groupCount, $dimensions = '2d')
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea();
|
$this->renderCartesianPlotArea();
|
||||||
|
|
||||||
for ($i = 0; $i < $groupCount; ++$i) {
|
for ($i = 0; $i < $groupCount; ++$i) {
|
||||||
$this->_renderPlotLine($i,True,False, $dimensions);
|
$this->renderPlotLine($i, true, false, $dimensions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderAreaChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderLineChart($groupCount, $dimensions = '2d') {
|
private function renderLineChart($groupCount, $dimensions = '2d')
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea();
|
$this->renderCartesianPlotArea();
|
||||||
|
|
||||||
for ($i = 0; $i < $groupCount; ++$i) {
|
for ($i = 0; $i < $groupCount; ++$i) {
|
||||||
$this->_renderPlotLine($i,False,False, $dimensions);
|
$this->renderPlotLine($i, false, false, $dimensions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderLineChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderBarChart($groupCount, $dimensions = '2d') {
|
private function renderBarChart($groupCount, $dimensions = '2d')
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea();
|
$this->renderCartesianPlotArea();
|
||||||
|
|
||||||
for ($i = 0; $i < $groupCount; ++$i) {
|
for ($i = 0; $i < $groupCount; ++$i) {
|
||||||
$this->_renderPlotBar($i, $dimensions);
|
$this->renderPlotBar($i, $dimensions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderBarChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderScatterChart($groupCount) {
|
private function renderScatterChart($groupCount)
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php');
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea('linlin');
|
$this->renderCartesianPlotArea('linlin');
|
||||||
|
|
||||||
for ($i = 0; $i < $groupCount; ++$i) {
|
for ($i = 0; $i < $groupCount; ++$i) {
|
||||||
$this->_renderPlotScatter($i,false);
|
$this->renderPlotScatter($i, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderScatterChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderBubbleChart($groupCount) {
|
private function renderBubbleChart($groupCount)
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea('linlin');
|
$this->renderCartesianPlotArea('linlin');
|
||||||
|
|
||||||
for ($i = 0; $i < $groupCount; ++$i) {
|
for ($i = 0; $i < $groupCount; ++$i) {
|
||||||
$this->_renderPlotScatter($i,true);
|
$this->renderPlotScatter($i, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderBubbleChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) {
|
private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false)
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie.php');
|
||||||
if ($dimensions == '3d') {
|
if ($dimensions == '3d') {
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie3d.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie3d.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_renderPiePlotArea($doughnut);
|
$this->renderPiePlotArea($doughnut);
|
||||||
|
|
||||||
$iLimit = ($multiplePlots) ? $groupCount : 1;
|
$iLimit = ($multiplePlots) ? $groupCount : 1;
|
||||||
for ($groupID = 0; $groupID < $iLimit; ++$groupID) {
|
for ($groupID = 0; $groupID < $iLimit; ++$groupID) {
|
||||||
|
@ -658,9 +680,10 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$seriesPlot->SetMidColor('white');
|
$seriesPlot->SetMidColor('white');
|
||||||
}
|
}
|
||||||
|
|
||||||
$seriesPlot->SetColor(self::$colourSet[self::$_plotColour++]);
|
$seriesPlot->SetColor(self::$colourSet[self::$plotColour++]);
|
||||||
if (count($datasetLabels) > 0)
|
if (count($datasetLabels) > 0) {
|
||||||
$seriesPlot->SetLabels(array_fill(0, count($datasetLabels), ''));
|
$seriesPlot->SetLabels(array_fill(0, count($datasetLabels), ''));
|
||||||
|
}
|
||||||
if ($dimensions != '3d') {
|
if ($dimensions != '3d') {
|
||||||
$seriesPlot->SetGuideLines(false);
|
$seriesPlot->SetGuideLines(false);
|
||||||
}
|
}
|
||||||
|
@ -674,50 +697,54 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
$this->graph->Add($seriesPlot);
|
$this->graph->Add($seriesPlot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // function _renderPieChart()
|
}
|
||||||
|
|
||||||
|
|
||||||
private function _renderRadarChart($groupCount) {
|
private function renderRadarChart($groupCount)
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_radar.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_radar.php');
|
||||||
|
|
||||||
$this->_renderRadarPlotArea();
|
$this->renderRadarPlotArea();
|
||||||
|
|
||||||
for ($groupID = 0; $groupID < $groupCount; ++$groupID) {
|
for ($groupID = 0; $groupID < $groupCount; ++$groupID) {
|
||||||
$this->_renderPlotRadar($groupID);
|
$this->renderPlotRadar($groupID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderRadarChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderStockChart($groupCount) {
|
private function renderStockChart($groupCount)
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_stock.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_stock.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea('intint');
|
$this->renderCartesianPlotArea('intint');
|
||||||
|
|
||||||
for ($groupID = 0; $groupID < $groupCount; ++$groupID) {
|
for ($groupID = 0; $groupID < $groupCount; ++$groupID) {
|
||||||
$this->_renderPlotStock($groupID);
|
$this->renderPlotStock($groupID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderStockChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderContourChart($groupCount, $dimensions) {
|
private function renderContourChart($groupCount, $dimensions)
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea('intint');
|
$this->renderCartesianPlotArea('intint');
|
||||||
|
|
||||||
for ($i = 0; $i < $groupCount; ++$i) {
|
for ($i = 0; $i < $groupCount; ++$i) {
|
||||||
$this->_renderPlotContour($i);
|
$this->renderPlotContour($i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // function _renderContourChart()
|
|
||||||
|
|
||||||
|
|
||||||
private function _renderCombinationChart($groupCount, $dimensions, $outputDestination) {
|
private function renderCombinationChart($groupCount, $dimensions, $outputDestination)
|
||||||
|
{
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php');
|
||||||
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
|
||||||
|
|
||||||
$this->_renderCartesianPlotArea();
|
$this->renderCartesianPlotArea();
|
||||||
|
|
||||||
for ($i = 0; $i < $groupCount; ++$i) {
|
for ($i = 0; $i < $groupCount; ++$i) {
|
||||||
$dimensions = null;
|
$dimensions = null;
|
||||||
|
@ -726,23 +753,23 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
case 'area3DChart':
|
case 'area3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'areaChart':
|
case 'areaChart':
|
||||||
$this->_renderPlotLine($i,True,True, $dimensions);
|
$this->renderPlotLine($i, true, true, $dimensions);
|
||||||
break;
|
break;
|
||||||
case 'bar3DChart':
|
case 'bar3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'barChart':
|
case 'barChart':
|
||||||
$this->_renderPlotBar($i, $dimensions);
|
$this->renderPlotBar($i, $dimensions);
|
||||||
break;
|
break;
|
||||||
case 'line3DChart':
|
case 'line3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'lineChart':
|
case 'lineChart':
|
||||||
$this->_renderPlotLine($i,False,True, $dimensions);
|
$this->renderPlotLine($i, false, true, $dimensions);
|
||||||
break;
|
break;
|
||||||
case 'scatterChart':
|
case 'scatterChart':
|
||||||
$this->_renderPlotScatter($i,false);
|
$this->renderPlotScatter($i, false);
|
||||||
break;
|
break;
|
||||||
case 'bubbleChart':
|
case 'bubbleChart':
|
||||||
$this->_renderPlotScatter($i,true);
|
$this->renderPlotScatter($i, true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->graph = null;
|
$this->graph = null;
|
||||||
|
@ -750,15 +777,16 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_renderLegend();
|
$this->renderLegend();
|
||||||
|
|
||||||
$this->graph->Stroke($outputDestination);
|
$this->graph->Stroke($outputDestination);
|
||||||
return true;
|
return true;
|
||||||
} // function _renderCombinationChart()
|
}
|
||||||
|
|
||||||
|
|
||||||
public function render($outputDestination) {
|
public function render($outputDestination)
|
||||||
self::$_plotColour = 0;
|
{
|
||||||
|
self::$plotColour = 0;
|
||||||
|
|
||||||
$groupCount = $this->chart->getPlotArea()->getPlotGroupCount();
|
$groupCount = $this->chart->getPlotArea()->getPlotGroupCount();
|
||||||
|
|
||||||
|
@ -777,7 +805,7 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
echo 'Chart is not yet implemented<br />';
|
echo 'Chart is not yet implemented<br />';
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return $this->_renderCombinationChart($groupCount, $dimensions, $outputDestination);
|
return $this->renderCombinationChart($groupCount, $dimensions, $outputDestination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -785,50 +813,50 @@ class PHPExcel_Chart_Renderer_jpgraph
|
||||||
case 'area3DChart':
|
case 'area3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'areaChart':
|
case 'areaChart':
|
||||||
$this->_renderAreaChart($groupCount, $dimensions);
|
$this->renderAreaChart($groupCount, $dimensions);
|
||||||
break;
|
break;
|
||||||
case 'bar3DChart':
|
case 'bar3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'barChart':
|
case 'barChart':
|
||||||
$this->_renderBarChart($groupCount, $dimensions);
|
$this->renderBarChart($groupCount, $dimensions);
|
||||||
break;
|
break;
|
||||||
case 'line3DChart':
|
case 'line3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'lineChart':
|
case 'lineChart':
|
||||||
$this->_renderLineChart($groupCount, $dimensions);
|
$this->renderLineChart($groupCount, $dimensions);
|
||||||
break;
|
break;
|
||||||
case 'pie3DChart':
|
case 'pie3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'pieChart':
|
case 'pieChart':
|
||||||
$this->_renderPieChart($groupCount, $dimensions,False,False);
|
$this->renderPieChart($groupCount, $dimensions, false, false);
|
||||||
break;
|
break;
|
||||||
case 'doughnut3DChart':
|
case 'doughnut3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'doughnutChart':
|
case 'doughnutChart':
|
||||||
$this->_renderPieChart($groupCount, $dimensions,True,True);
|
$this->renderPieChart($groupCount, $dimensions, true, true);
|
||||||
break;
|
break;
|
||||||
case 'scatterChart':
|
case 'scatterChart':
|
||||||
$this->_renderScatterChart($groupCount);
|
$this->renderScatterChart($groupCount);
|
||||||
break;
|
break;
|
||||||
case 'bubbleChart':
|
case 'bubbleChart':
|
||||||
$this->_renderBubbleChart($groupCount);
|
$this->renderBubbleChart($groupCount);
|
||||||
break;
|
break;
|
||||||
case 'radarChart':
|
case 'radarChart':
|
||||||
$this->_renderRadarChart($groupCount);
|
$this->renderRadarChart($groupCount);
|
||||||
break;
|
break;
|
||||||
case 'surface3DChart':
|
case 'surface3DChart':
|
||||||
$dimensions = '3d';
|
$dimensions = '3d';
|
||||||
case 'surfaceChart':
|
case 'surfaceChart':
|
||||||
$this->_renderContourChart($groupCount, $dimensions);
|
$this->renderContourChart($groupCount, $dimensions);
|
||||||
break;
|
break;
|
||||||
case 'stockChart':
|
case 'stockChart':
|
||||||
$this->_renderStockChart($groupCount, $dimensions);
|
$this->renderStockChart($groupCount, $dimensions);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
echo $chartType.' is not yet implemented<br />';
|
echo $chartType.' is not yet implemented<br />';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->_renderLegend();
|
$this->renderLegend();
|
||||||
|
|
||||||
$this->graph->Stroke($outputDestination);
|
$this->graph->Stroke($outputDestination);
|
||||||
return true;
|
return true;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,7 @@
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* License along with this library; if not, write to the Free Software
|
* License along with this library; if not,241 write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
* @category PHPExcel
|
* @category PHPExcel
|
||||||
|
@ -237,7 +237,7 @@ class PHPExcel_Worksheet_HeaderFooter
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getEvenHeader()
|
public function getEvenHeader()
|
||||||
|
{
|
||||||
return $this->_evenHeader;
|
return $this->_evenHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue