diff --git a/Classes/PHPExcel/Cell.php b/Classes/PHPExcel/Cell.php index 4e1c863c..4ca7e532 100644 --- a/Classes/PHPExcel/Cell.php +++ b/Classes/PHPExcel/Cell.php @@ -40,7 +40,7 @@ class PHPExcel_Cell * * @var PHPExcel_Cell_IValueBinder */ - private static $_valueBinder = NULL; + private static $_valueBinder; /** * Value of the cell @@ -59,7 +59,7 @@ class PHPExcel_Cell * * @var mixed */ - private $_calculatedValue = NULL; + private $_calculatedValue; /** * Type of the cell data @@ -94,17 +94,20 @@ class PHPExcel_Cell * * @return void **/ - public function notifyCacheController() { + public function notifyCacheController() + { $this->_parent->updateCacheData($this); return $this; } - public function detach() { - $this->_parent = NULL; + public function detach() + { + $this->_parent = null; } - public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) { + public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) + { $this->_parent = $parent; } @@ -117,7 +120,7 @@ class PHPExcel_Cell * @param PHPExcel_Worksheet $pSheet * @throws PHPExcel_Exception */ - 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 $this->_value = $pValue; @@ -126,9 +129,10 @@ class PHPExcel_Cell $this->_parent = $pSheet->getCellCacheController(); // Set datatype? - if ($pDataType !== NULL) { - if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) + if ($pDataType !== null) { + if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) { $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; + } $this->_dataType = $pDataType; } elseif (!self::getValueBinder()->bindValue($this, $pValue)) { throw new PHPExcel_Exception("Value could not be bound to cell."); @@ -183,10 +187,10 @@ class PHPExcel_Cell public function getFormattedValue() { return (string) PHPExcel_Style_NumberFormat::toFormattedString( - $this->getCalculatedValue(), - $this->getStyle() - ->getNumberFormat()->getFormatCode() - ); + $this->getCalculatedValue(), + $this->getStyle() + ->getNumberFormat()->getFormatCode() + ); } /** @@ -198,7 +202,7 @@ class PHPExcel_Cell * @return PHPExcel_Cell * @throws PHPExcel_Exception */ - public function setValue($pValue = NULL) + public function setValue($pValue = null) { if (!self::getValueBinder()->bindValue($this, $pValue)) { throw new PHPExcel_Exception("Value could not be bound to cell."); @@ -214,7 +218,7 @@ class PHPExcel_Cell * @return PHPExcel_Cell * @throws PHPExcel_Exception */ - public function setValueExplicit($pValue = NULL, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING) + public function setValueExplicit($pValue = null, $pDataType = PHPExcel_Cell_DataType::TYPE_STRING) { // set the value according to data type switch ($pDataType) { @@ -224,17 +228,19 @@ class PHPExcel_Cell case PHPExcel_Cell_DataType::TYPE_STRING2: $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; case PHPExcel_Cell_DataType::TYPE_STRING: + // Synonym for string case PHPExcel_Cell_DataType::TYPE_INLINE: + // Rich text $this->_value = PHPExcel_Cell_DataType::checkString($pValue); break; case PHPExcel_Cell_DataType::TYPE_NUMERIC: - $this->_value = (float)$pValue; + $this->_value = (float) $pValue; break; case PHPExcel_Cell_DataType::TYPE_FORMULA: - $this->_value = (string)$pValue; + $this->_value = (string) $pValue; break; case PHPExcel_Cell_DataType::TYPE_BOOL: - $this->_value = (bool)$pValue; + $this->_value = (bool) $pValue; break; case PHPExcel_Cell_DataType::TYPE_ERROR: $this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue); @@ -259,7 +265,7 @@ class PHPExcel_Cell * @return mixed * @throws PHPExcel_Exception */ - 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; if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) { @@ -267,7 +273,7 @@ class PHPExcel_Cell //echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL; $result = PHPExcel_Calculation::getInstance( $this->getWorksheet()->getParent() - )->calculateCellValue($this,$resetLog); + )->calculateCellValue($this, $resetLog); //echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL; // We don't yet handle array returns if (is_array($result)) { @@ -275,8 +281,8 @@ class PHPExcel_Cell $result = array_pop($result); } } - } catch ( PHPExcel_Exception $ex ) { - if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) { + } catch (PHPExcel_Exception $ex) { + if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== null)) { //echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL; return $this->_calculatedValue; // Fallback for calculations referencing external files. } @@ -293,7 +299,7 @@ class PHPExcel_Cell } //echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL; 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.'
'; return $this->_value->getPlainText(); } @@ -307,9 +313,9 @@ class PHPExcel_Cell * @param mixed $pValue Value * @return 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; } @@ -349,9 +355,9 @@ class PHPExcel_Cell */ public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING) { - if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) + if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) { $pDataType = PHPExcel_Cell_DataType::TYPE_STRING; - + } $this->_dataType = $pDataType; return $this->notifyCacheController(); @@ -404,7 +410,7 @@ class PHPExcel_Cell * @return PHPExcel_Cell * @throws PHPExcel_Exception */ - public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = NULL) + public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null) { if (!isset($this->_parent)) { throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet'); @@ -452,7 +458,7 @@ class PHPExcel_Cell * @return PHPExcel_Cell * @throws PHPExcel_Exception */ - public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = NULL) + public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null) { if (!isset($this->_parent)) { throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); @@ -468,7 +474,8 @@ class PHPExcel_Cell * * @return PHPExcel_CachedObjectStorage_CacheBase */ - public function getParent() { + public function getParent() + { return $this->_parent; } @@ -477,7 +484,8 @@ class PHPExcel_Cell * * @return PHPExcel_Worksheet */ - public function getWorksheet() { + public function getWorksheet() + { return $this->_parent->getParent(); } @@ -486,7 +494,8 @@ class PHPExcel_Cell * * @return boolean */ - public function isInMergeRange() { + public function isInMergeRange() + { return (boolean) $this->getMergeRange(); } @@ -495,7 +504,8 @@ class PHPExcel_Cell * * @return boolean */ - public function isMergeRangeValueCell() { + public function isMergeRangeValueCell() + { if ($mergeRange = $this->getMergeRange()) { $mergeRange = PHPExcel_Cell::splitRange($mergeRange); list($startCell) = $mergeRange[0]; @@ -511,8 +521,9 @@ class PHPExcel_Cell * * @return string */ - public function getMergeRange() { - foreach($this->getWorksheet()->getMergeCells() as $mergeRange) { + public function getMergeRange() + { + foreach ($this->getWorksheet()->getMergeCells() as $mergeRange) { if ($this->isInRange($mergeRange)) { return $mergeRange; } @@ -536,7 +547,8 @@ class PHPExcel_Cell * @param PHPExcel_Worksheet $parent * @return PHPExcel_Cell */ - public function rebindParent(PHPExcel_Worksheet $parent) { + public function rebindParent(PHPExcel_Worksheet $parent) + { $this->_parent = $parent->getCellCacheController(); return $this->notifyCacheController(); @@ -550,11 +562,11 @@ class PHPExcel_Cell */ public function isInRange($pRange = 'A1:A1') { - list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange); + list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange); // Translate properties - $myColumn = self::columnIndexFromString($this->getColumn()); - $myRow = $this->getRow(); + $myColumn = self::columnIndexFromString($this->getColumn()); + $myRow = $this->getRow(); // Verify if cell is in range return (($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) && @@ -573,7 +585,7 @@ class PHPExcel_Cell { if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) { return array($matches[1],$matches[2]); - } elseif ((strpos($pCoordinateString,':') !== FALSE) || (strpos($pCoordinateString,',') !== FALSE)) { + } elseif ((strpos($pCoordinateString,':') !== false) || (strpos($pCoordinateString,',') !== false)) { throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells'); } elseif ($pCoordinateString == '') { throw new PHPExcel_Exception('Cell coordinate can not be zero-length string'); @@ -592,14 +604,16 @@ class PHPExcel_Cell */ public static function absoluteReference($pCoordinateString = 'A1') { - if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) { + if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) { // Split out any worksheet name from the reference $worksheet = ''; - $cellAddress = explode('!',$pCoordinateString); + $cellAddress = explode('!', $pCoordinateString); if (count($cellAddress) > 1) { - list($worksheet,$pCoordinateString) = $cellAddress; + list($worksheet, $pCoordinateString) = $cellAddress; + } + if ($worksheet > '') { + $worksheet .= '!'; } - if ($worksheet > '') $worksheet .= '!'; // Create absolute coordinate if (ctype_digit($pCoordinateString)) { @@ -622,19 +636,21 @@ class PHPExcel_Cell */ public static function absoluteCoordinate($pCoordinateString = 'A1') { - if (strpos($pCoordinateString,':') === FALSE && strpos($pCoordinateString,',') === FALSE) { + if (strpos($pCoordinateString, ':') === false && strpos($pCoordinateString, ',') === false) { // Split out any worksheet name from the coordinate $worksheet = ''; - $cellAddress = explode('!',$pCoordinateString); + $cellAddress = explode('!', $pCoordinateString); if (count($cellAddress) > 1) { - list($worksheet,$pCoordinateString) = $cellAddress; + list($worksheet, $pCoordinateString) = $cellAddress; + } + if ($worksheet > '') { + $worksheet .= '!'; } - if ($worksheet > '') $worksheet .= '!'; // Create absolute coordinate list($column, $row) = self::coordinateFromString($pCoordinateString); - $column = ltrim($column,'$'); - $row = ltrim($row,'$'); + $column = ltrim($column, '$'); + $row = ltrim($row, '$'); return $worksheet . '$' . $column . '$' . $row; } @@ -652,7 +668,7 @@ class PHPExcel_Cell public static function splitRange($pRange = 'A1:A1') { // Ensure $pRange is a valid range - if(empty($pRange)) { + if (empty($pRange)) { $pRange = self::DEFAULT_RANGE; } @@ -699,7 +715,7 @@ class PHPExcel_Cell public static function rangeBoundaries($pRange = 'A1:A1') { // Ensure $pRange is a valid range - if(empty($pRange)) { + if (empty($pRange)) { $pRange = self::DEFAULT_RANGE; } @@ -707,7 +723,7 @@ class PHPExcel_Cell $pRange = strtoupper($pRange); // Extract range - if (strpos($pRange, ':') === FALSE) { + if (strpos($pRange, ':') === false) { $rangeA = $rangeB = $pRange; } else { list($rangeA, $rangeB) = explode(':', $pRange); @@ -733,7 +749,7 @@ class PHPExcel_Cell public static function rangeDimension($pRange = 'A1:A1') { // Calculate range outer borders - list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange); + list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange); return array( ($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1) ); } @@ -748,7 +764,7 @@ class PHPExcel_Cell public static function getRangeBoundaries($pRange = 'A1:A1') { // Ensure $pRange is a valid range - if(empty($pRange)) { + if (empty($pRange)) { $pRange = self::DEFAULT_RANGE; } @@ -756,7 +772,7 @@ class PHPExcel_Cell $pRange = strtoupper($pRange); // Extract range - if (strpos($pRange, ':') === FALSE) { + if (strpos($pRange, ':') === false) { $rangeA = $rangeB = $pRange; } else { list($rangeA, $rangeB) = explode(':', $pRange); @@ -778,9 +794,9 @@ class PHPExcel_Cell // though it's additional memory overhead static $_indexCache = array(); - if (isset($_indexCache[$pString])) + if (isset($_indexCache[$pString])) { return $_indexCache[$pString]; - + } // It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord() // and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant // memory overhead either @@ -797,10 +813,10 @@ class PHPExcel_Cell if (!isset($pString{1})) { $_indexCache[$pString] = $_columnLookup[$pString]; return $_indexCache[$pString]; - } elseif(!isset($pString{2})) { + } elseif (!isset($pString{2})) { $_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}]; return $_indexCache[$pString]; - } elseif(!isset($pString{3})) { + } elseif (!isset($pString{3})) { $_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}]; return $_indexCache[$pString]; } @@ -843,7 +859,8 @@ class PHPExcel_Cell * @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25) * @return array Array containing single cell references */ - public static function extractAllCellReferencesInRange($pRange = 'A1') { + public static function extractAllCellReferencesInRange($pRange = 'A1') + { // Returnvalue $returnValue = array(); @@ -851,14 +868,14 @@ class PHPExcel_Cell $cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange))); foreach ($cellBlocks as $cellBlock) { // Single cell? - if (strpos($cellBlock,':') === FALSE && strpos($cellBlock,',') === FALSE) { + if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) { $returnValue[] = $cellBlock; continue; } // Range... $ranges = self::splitRange($cellBlock); - foreach($ranges as $range) { + foreach ($ranges as $range) { // Single cell? if (!isset($range[1])) { $returnValue[] = $range[0]; @@ -867,13 +884,13 @@ class PHPExcel_Cell // Range... list($rangeStart, $rangeEnd) = $range; - sscanf($rangeStart,'%[A-Z]%d', $startCol, $startRow); - sscanf($rangeEnd,'%[A-Z]%d', $endCol, $endRow); - $endCol++; + sscanf($rangeStart, '%[A-Z]%d', $startCol, $startRow); + sscanf($rangeEnd, '%[A-Z]%d', $endCol, $endRow); + ++$endCol; // Current data - $currentCol = $startCol; - $currentRow = $startRow; + $currentCol = $startCol; + $currentRow = $startRow; // Loop cells while ($currentCol != $endCol) { @@ -890,8 +907,8 @@ class PHPExcel_Cell // Sort the result by column and row $sortKeys = array(); foreach (array_unique($returnValue) as $coord) { - sscanf($coord,'%[A-Z]%d', $column, $row); - $sortKeys[sprintf('%3s%09d',$column,$row)] = $coord; + sscanf($coord, '%[A-Z]%d', $column, $row); + $sortKeys[sprintf('%3s%09d', $column, $row)] = $coord; } ksort($sortKeys); @@ -924,8 +941,9 @@ class PHPExcel_Cell * * @return PHPExcel_Cell_IValueBinder */ - public static function getValueBinder() { - if (self::$_valueBinder === NULL) { + public static function getValueBinder() + { + if (self::$_valueBinder === null) { self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder(); } @@ -938,8 +956,9 @@ class PHPExcel_Cell * @param PHPExcel_Cell_IValueBinder $binder * @throws PHPExcel_Exception */ - public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) { - if ($binder === NULL) { + public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = null) + { + if ($binder === null) { throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly."); } @@ -949,7 +968,8 @@ class PHPExcel_Cell /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ - public function __clone() { + public function __clone() + { $vars = get_object_vars($this); foreach ($vars as $key => $value) { if ((is_object($value)) && ($key != '_parent')) { @@ -1009,6 +1029,4 @@ class PHPExcel_Cell { return (string) $this->getValue(); } - } - diff --git a/Classes/PHPExcel/Cell/AdvancedValueBinder.php b/Classes/PHPExcel/Cell/AdvancedValueBinder.php index bc7a19f1..ee2de791 100644 --- a/Classes/PHPExcel/Cell/AdvancedValueBinder.php +++ b/Classes/PHPExcel/Cell/AdvancedValueBinder.php @@ -59,7 +59,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder if ($value == PHPExcel_Calculation::getTRUE()) { $cell->setValueExplicit(true, PHPExcel_Cell_DataType::TYPE_BOOL); return true; - } elseif($value == PHPExcel_Calculation::getFALSE()) { + } elseif ($value == PHPExcel_Calculation::getFALSE()) { $cell->setValueExplicit(false, PHPExcel_Cell_DataType::TYPE_BOOL); return true; } @@ -74,20 +74,24 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder if (preg_match('/^([+-]?)\s*([0-9]+)\s?\/\s*([0-9]+)$/', $value, $matches)) { // Convert value to number $value = $matches[2] / $matches[3]; - if ($matches[1] == '-') $value = 0 - $value; + if ($matches[1] == '-') { + $value = 0 - $value; + } $cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); // Set style - $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( '??/??' ); + $cell->getWorksheet()->getStyle($cell->getCoordinate()) + ->getNumberFormat()->setFormatCode('??/??'); return true; } elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { // Convert value to number $value = $matches[2] + ($matches[3] / $matches[4]); - if ($matches[1] == '-') $value = 0 - $value; + if ($matches[1] == '-') { + $value = 0 - $value; + } $cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); // Set style - $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) - ->getNumberFormat()->setFormatCode( '# ??/??' ); + $cell->getWorksheet()->getStyle($cell->getCoordinate()) + ->getNumberFormat()->setFormatCode('# ??/??'); return true; } @@ -95,9 +99,9 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) { // Convert value to number $value = (float) str_replace('%', '', $value) / 100; - $cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); + $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC); // Set style - $cell->getWorksheet()->getStyle( $cell->getCoordinate() ) + $cell->getWorksheet()->getStyle($cell->getCoordinate()) ->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00); return true; } diff --git a/Classes/PHPExcel/Cell/DataType.php b/Classes/PHPExcel/Cell/DataType.php index dda18ed8..fc010e65 100644 --- a/Classes/PHPExcel/Cell/DataType.php +++ b/Classes/PHPExcel/Cell/DataType.php @@ -112,5 +112,4 @@ class PHPExcel_Cell_DataType return $pValue; } - } diff --git a/Classes/PHPExcel/Cell/DataValidation.php b/Classes/PHPExcel/Cell/DataValidation.php index 38d59e85..a9963b08 100644 --- a/Classes/PHPExcel/Cell/DataValidation.php +++ b/Classes/PHPExcel/Cell/DataValidation.php @@ -57,91 +57,91 @@ class PHPExcel_Cell_DataValidation * * @var string */ - private $_formula1; + private $formula1; /** * Formula 2 * * @var string */ - private $_formula2; + private $formula2; /** * Type * * @var string */ - private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE; + private $type = PHPExcel_Cell_DataValidation::TYPE_NONE; /** * Error style * * @var string */ - private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; + private $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; /** * Operator * * @var string */ - private $_operator; + private $operator; /** * Allow Blank * * @var boolean */ - private $_allowBlank; + private $allowBlank; /** * Show DropDown * * @var boolean */ - private $_showDropDown; + private $showDropDown; /** * Show InputMessage * * @var boolean */ - private $_showInputMessage; + private $showInputMessage; /** * Show ErrorMessage * * @var boolean */ - private $_showErrorMessage; + private $showErrorMessage; /** * Error title * * @var string */ - private $_errorTitle; + private $errorTitle; /** * Error * * @var string */ - private $_error; + private $error; /** * Prompt title * * @var string */ - private $_promptTitle; + private $promptTitle; /** * Prompt * * @var string */ - private $_prompt; + private $prompt; /** * Create a new PHPExcel_Cell_DataValidation @@ -149,19 +149,19 @@ class PHPExcel_Cell_DataValidation public function __construct() { // Initialise member variables - $this->_formula1 = ''; - $this->_formula2 = ''; - $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE; - $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; - $this->_operator = ''; - $this->_allowBlank = FALSE; - $this->_showDropDown = FALSE; - $this->_showInputMessage = FALSE; - $this->_showErrorMessage = FALSE; - $this->_errorTitle = ''; - $this->_error = ''; - $this->_promptTitle = ''; - $this->_prompt = ''; + $this->formula1 = ''; + $this->formula2 = ''; + $this->type = PHPExcel_Cell_DataValidation::TYPE_NONE; + $this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; + $this->operator = ''; + $this->allowBlank = false; + $this->showDropDown = false; + $this->showInputMessage = false; + $this->showErrorMessage = false; + $this->errorTitle = ''; + $this->error = ''; + $this->promptTitle = ''; + $this->prompt = ''; } /** @@ -169,8 +169,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getFormula1() { - return $this->_formula1; + public function getFormula1() + { + return $this->formula1; } /** @@ -179,8 +180,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setFormula1($value = '') { - $this->_formula1 = $value; + public function setFormula1($value = '') + { + $this->formula1 = $value; return $this; } @@ -190,7 +192,7 @@ class PHPExcel_Cell_DataValidation * @return string */ public function getFormula2() { - return $this->_formula2; + return $this->formula2; } /** @@ -199,8 +201,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setFormula2($value = '') { - $this->_formula2 = $value; + public function setFormula2($value = '') + { + $this->formula2 = $value; return $this; } @@ -209,8 +212,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getType() { - return $this->_type; + public function getType() + { + return $this->type; } /** @@ -219,8 +223,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) { - $this->_type = $value; + public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) + { + $this->type = $value; return $this; } @@ -229,8 +234,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getErrorStyle() { - return $this->_errorStyle; + public function getErrorStyle() + { + return $this->errorStyle; } /** @@ -239,8 +245,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) { - $this->_errorStyle = $value; + public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) + { + $this->errorStyle = $value; return $this; } @@ -249,8 +256,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getOperator() { - return $this->_operator; + public function getOperator() + { + return $this->operator; } /** @@ -259,8 +267,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setOperator($value = '') { - $this->_operator = $value; + public function setOperator($value = '') + { + $this->operator = $value; return $this; } @@ -269,8 +278,9 @@ class PHPExcel_Cell_DataValidation * * @return boolean */ - public function getAllowBlank() { - return $this->_allowBlank; + public function getAllowBlank() + { + return $this->allowBlank; } /** @@ -279,8 +289,9 @@ class PHPExcel_Cell_DataValidation * @param boolean $value * @return PHPExcel_Cell_DataValidation */ - public function setAllowBlank($value = false) { - $this->_allowBlank = $value; + public function setAllowBlank($value = false) + { + $this->allowBlank = $value; return $this; } @@ -289,8 +300,9 @@ class PHPExcel_Cell_DataValidation * * @return boolean */ - public function getShowDropDown() { - return $this->_showDropDown; + public function getShowDropDown() + { + return $this->showDropDown; } /** @@ -299,8 +311,9 @@ class PHPExcel_Cell_DataValidation * @param boolean $value * @return PHPExcel_Cell_DataValidation */ - public function setShowDropDown($value = false) { - $this->_showDropDown = $value; + public function setShowDropDown($value = false) + { + $this->showDropDown = $value; return $this; } @@ -309,8 +322,9 @@ class PHPExcel_Cell_DataValidation * * @return boolean */ - public function getShowInputMessage() { - return $this->_showInputMessage; + public function getShowInputMessage() + { + return $this->showInputMessage; } /** @@ -319,8 +333,9 @@ class PHPExcel_Cell_DataValidation * @param boolean $value * @return PHPExcel_Cell_DataValidation */ - public function setShowInputMessage($value = false) { - $this->_showInputMessage = $value; + public function setShowInputMessage($value = false) + { + $this->showInputMessage = $value; return $this; } @@ -329,8 +344,9 @@ class PHPExcel_Cell_DataValidation * * @return boolean */ - public function getShowErrorMessage() { - return $this->_showErrorMessage; + public function getShowErrorMessage() + { + return $this->showErrorMessage; } /** @@ -339,8 +355,9 @@ class PHPExcel_Cell_DataValidation * @param boolean $value * @return PHPExcel_Cell_DataValidation */ - public function setShowErrorMessage($value = false) { - $this->_showErrorMessage = $value; + public function setShowErrorMessage($value = false) + { + $this->showErrorMessage = $value; return $this; } @@ -349,8 +366,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getErrorTitle() { - return $this->_errorTitle; + public function getErrorTitle() + { + return $this->errorTitle; } /** @@ -359,8 +377,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setErrorTitle($value = '') { - $this->_errorTitle = $value; + public function setErrorTitle($value = '') + { + $this->errorTitle = $value; return $this; } @@ -369,8 +388,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getError() { - return $this->_error; + public function getError() + { + return $this->error; } /** @@ -379,8 +399,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setError($value = '') { - $this->_error = $value; + public function setError($value = '') + { + $this->error = $value; return $this; } @@ -389,8 +410,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getPromptTitle() { - return $this->_promptTitle; + public function getPromptTitle() + { + return $this->promptTitle; } /** @@ -399,8 +421,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setPromptTitle($value = '') { - $this->_promptTitle = $value; + public function setPromptTitle($value = '') + { + $this->promptTitle = $value; return $this; } @@ -409,8 +432,9 @@ class PHPExcel_Cell_DataValidation * * @return string */ - public function getPrompt() { - return $this->_prompt; + public function getPrompt() + { + return $this->prompt; } /** @@ -419,8 +443,9 @@ class PHPExcel_Cell_DataValidation * @param string $value * @return PHPExcel_Cell_DataValidation */ - public function setPrompt($value = '') { - $this->_prompt = $value; + public function setPrompt($value = '') + { + $this->prompt = $value; return $this; } @@ -429,29 +454,31 @@ class PHPExcel_Cell_DataValidation * * @return string Hash code */ - public function getHashCode() { + public function getHashCode() + { return md5( - $this->_formula1 - . $this->_formula2 - . $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE - . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP - . $this->_operator - . ($this->_allowBlank ? 't' : 'f') - . ($this->_showDropDown ? 't' : 'f') - . ($this->_showInputMessage ? 't' : 'f') - . ($this->_showErrorMessage ? 't' : 'f') - . $this->_errorTitle - . $this->_error - . $this->_promptTitle - . $this->_prompt - . __CLASS__ + $this->formula1 . + $this->formula2 . + $this->type = PHPExcel_Cell_DataValidation::TYPE_NONE . + $this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP . + $this->operator . + ($this->allowBlank ? 't' : 'f') . + ($this->showDropDown ? 't' : 'f') . + ($this->showInputMessage ? 't' : 'f') . + ($this->showErrorMessage ? 't' : 'f') . + $this->errorTitle . + $this->error . + $this->promptTitle . + $this->prompt . + __CLASS__ ); } /** * Implement PHP __clone to create a deep clone, not just a shallow copy. */ - public function __clone() { + public function __clone() + { $vars = get_object_vars($this); foreach ($vars as $key => $value) { if (is_object($value)) { diff --git a/Classes/PHPExcel/Cell/DefaultValueBinder.php b/Classes/PHPExcel/Cell/DefaultValueBinder.php index 779380ac..dc19e6c4 100644 --- a/Classes/PHPExcel/Cell/DefaultValueBinder.php +++ b/Classes/PHPExcel/Cell/DefaultValueBinder.php @@ -87,9 +87,9 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder return PHPExcel_Cell_DataType::TYPE_NUMERIC; } elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) { $tValue = ltrim($pValue, '+-'); - if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.' ) { + if (is_string($pValue) && $tValue{0} === '0' && strlen($tValue) > 1 && $tValue{1} !== '.') { return PHPExcel_Cell_DataType::TYPE_STRING; - } elseif((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) { + } elseif ((strpos($pValue, '.') === false) && ($pValue > PHP_INT_MAX)) { return PHPExcel_Cell_DataType::TYPE_STRING; } return PHPExcel_Cell_DataType::TYPE_NUMERIC; diff --git a/Classes/PHPExcel/Chart/Axis.php b/Classes/PHPExcel/Chart/Axis.php index f5018183..65abf9ca 100644 --- a/Classes/PHPExcel/Chart/Axis.php +++ b/Classes/PHPExcel/Chart/Axis.php @@ -7,8 +7,8 @@ * Time: 12:11 PM */ -class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { - +class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties +{ /** * Axis Number * @@ -25,16 +25,16 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * @var array of mixed */ private $_axis_options = array( - 'minimum' => NULL, - 'maximum' => NULL, - 'major_unit' => NULL, - 'minor_unit' => NULL, + 'minimum' => null, + 'maximum' => null, + 'major_unit' => null, + 'minor_unit' => null, 'orientation' => self::ORIENTATION_NORMAL, 'minor_tick_mark' => self::TICK_MARK_NONE, 'major_tick_mark' => self::TICK_MARK_NONE, 'axis_labels' => self::AXIS_LABELS_NEXT_TO, 'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO, - 'horizontal_crosses_value' => NULL + 'horizontal_crosses_value' => null ); /** @@ -44,7 +44,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { */ private $_fill_properties = array( 'type' => self::EXCEL_COLOR_TYPE_ARGB, - 'value' => NULL, + 'value' => null, 'alpha' => 0 ); @@ -55,7 +55,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { */ private $_line_properties = array( 'type' => self::EXCEL_COLOR_TYPE_ARGB, - 'value' => NULL, + 'value' => null, 'alpha' => 0 ); @@ -89,22 +89,22 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { */ private $_shadow_properties = array( 'presets' => self::SHADOW_PRESETS_NOSHADOW, - 'effect' => NULL, + 'effect' => null, 'color' => array( 'type' => self::EXCEL_COLOR_TYPE_STANDARD, 'value' => 'black', 'alpha' => 40, ), 'size' => array( - 'sx' => NULL, - 'sy' => NULL, - 'kx' => NULL + 'sx' => null, + 'sy' => null, + 'kx' => null ), - 'blur' => NULL, - 'direction' => NULL, - 'distance' => NULL, - 'algn' => NULL, - 'rotWithShape' => NULL + 'blur' => null, + 'direction' => null, + 'distance' => null, + 'algn' => null, + 'rotWithShape' => null ); /** @@ -113,7 +113,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * @var array of mixed */ private $_glow_properties = array( - 'size' => NULL, + 'size' => null, 'color' => array( 'type' => self::EXCEL_COLOR_TYPE_STANDARD, 'value' => 'black', @@ -127,7 +127,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * @var array of mixed */ private $_soft_edges = array( - 'size' => NULL + 'size' => null ); /** @@ -135,7 +135,8 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * * @return string */ - public function setAxisNumberProperties($format_code) { + public function setAxisNumberProperties($format_code) + { $this->_axis_number['format'] = (string) $format_code; $this->_axis_number['source_linked'] = 0; } @@ -145,7 +146,8 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * * @return string */ - public function getAxisNumberFormat() { + public function getAxisNumberFormat() + { return $this->_axis_number['format']; } @@ -154,7 +156,8 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * * @return string */ - public function getAxisNumberSourceLinked() { + public function getAxisNumberSourceLinked() + { return (string) $this->_axis_number['source_linked']; } @@ -173,22 +176,22 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * @param string $minor_unit * */ - public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = NULL, $horizontal_crosses = NULL, - $axis_orientation = NULL, $major_tmt = NULL, $minor_tmt = NULL, $minimum = NULL, $maximum = NULL, $major_unit = NULL, - $minor_unit = NULL) + public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = null, $horizontal_crosses = null, + $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null, + $minor_unit = null) { $this->_axis_options['axis_labels'] = (string) $axis_labels; - ($horizontal_crosses_value !== NULL) - ? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : NULL; - ($horizontal_crosses !== NULL) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : NULL; - ($axis_orientation !== NULL) ? $this->_axis_options['orientation'] = (string) $axis_orientation : NULL; - ($major_tmt !== NULL) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : NULL; - ($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL; - ($minor_tmt !== NULL) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : NULL; - ($minimum !== NULL) ? $this->_axis_options['minimum'] = (string) $minimum : NULL; - ($maximum !== NULL) ? $this->_axis_options['maximum'] = (string) $maximum : NULL; - ($major_unit !== NULL) ? $this->_axis_options['major_unit'] = (string) $major_unit : NULL; - ($minor_unit !== NULL) ? $this->_axis_options['minor_unit'] = (string) $minor_unit : NULL; + ($horizontal_crosses_value !== null) + ? $this->_axis_options['horizontal_crosses_value'] = (string) $horizontal_crosses_value : null; + ($horizontal_crosses !== null) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : null; + ($axis_orientation !== null) ? $this->_axis_options['orientation'] = (string) $axis_orientation : null; + ($major_tmt !== null) ? $this->_axis_options['major_tick_mark'] = (string) $major_tmt : null; + ($minor_tmt !== null) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : null; + ($minor_tmt !== null) ? $this->_axis_options['minor_tick_mark'] = (string) $minor_tmt : null; + ($minimum !== null) ? $this->_axis_options['minimum'] = (string) $minimum : null; + ($maximum !== null) ? $this->_axis_options['maximum'] = (string) $maximum : null; + ($major_unit !== null) ? $this->_axis_options['major_unit'] = (string) $major_unit : null; + ($minor_unit !== null) ? $this->_axis_options['minor_unit'] = (string) $minor_unit : null; } /** @@ -273,24 +276,24 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * */ - public function setLineStyleProperties($line_width = NULL, $compound_type = NULL, - $dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_type = NULL, - $head_arrow_size = NULL, $end_arrow_type = NULL, $end_arrow_size = NULL) { + public function setLineStyleProperties($line_width = null, $compound_type = null, + $dash_type = null, $cap_type = null, $join_type = null, $head_arrow_type = null, + $head_arrow_size = null, $end_arrow_type = null, $end_arrow_size = null) { (!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width) - : NULL; - (!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : NULL; - (!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : NULL; - (!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : NULL; - (!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : NULL; + : null; + (!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : null; + (!is_null($dash_type)) ? $this->_line_style_properties['dash'] = (string) $dash_type : null; + (!is_null($cap_type)) ? $this->_line_style_properties['cap'] = (string) $cap_type : null; + (!is_null($join_type)) ? $this->_line_style_properties['join'] = (string) $join_type : null; (!is_null($head_arrow_type)) ? $this->_line_style_properties['arrow']['head']['type'] = (string) $head_arrow_type - : NULL; + : null; (!is_null($head_arrow_size)) ? $this->_line_style_properties['arrow']['head']['size'] = (string) $head_arrow_size - : NULL; + : null; (!is_null($end_arrow_type)) ? $this->_line_style_properties['arrow']['end']['type'] = (string) $end_arrow_type - : NULL; + : null; (!is_null($end_arrow_size)) ? $this->_line_style_properties['arrow']['end']['size'] = (string) $end_arrow_size - : NULL; + : null; } /** @@ -342,7 +345,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * */ - public function setShadowProperties($sh_presets, $sh_color_value = NULL, $sh_color_type = NULL, $sh_color_alpha = NULL, $sh_blur = NULL, $sh_angle = NULL, $sh_distance = NULL) { + public function setShadowProperties($sh_presets, $sh_color_value = null, $sh_color_type = null, $sh_color_alpha = null, $sh_blur = null, $sh_angle = null, $sh_distance = null) { $this ->_setShadowPresetsProperties((int) $sh_presets) ->_setShadowColor( @@ -378,18 +381,18 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * @return PHPExcel_Chart_Axis */ - private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) { + private function _setShadowProperiesMapValues(array $properties_map, &$reference = null) { $base_reference = $reference; foreach ($properties_map as $property_key => $property_val) { if (is_array($property_val)) { - if ($reference === NULL) { + if ($reference === null) { $reference = & $this->_shadow_properties[$property_key]; } else { $reference = & $reference[$property_key]; } $this->_setShadowProperiesMapValues($property_val, $reference); } else { - if ($base_reference === NULL) { + if ($base_reference === null) { $this->_shadow_properties[$property_key] = $property_val; } else { $reference[$property_key] = $property_val; @@ -425,7 +428,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { */ private function _setShadowBlur($blur) { - if ($blur !== NULL) { + if ($blur !== null) { $this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur); } @@ -441,7 +444,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { */ private function _setShadowAngle($angle) { - if ($angle !== NULL) { + if ($angle !== null) { $this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle); } @@ -457,7 +460,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { */ private function _setShadowDistance($distance) { - if ($distance !== NULL) { + if ($distance !== null) { $this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance); } @@ -486,7 +489,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { * @param string $color_type */ - public function setGlowProperties($size, $color_value = NULL, $color_alpha = NULL, $color_type = NULL) { + public function setGlowProperties($size, $color_value = null, $color_alpha = null, $color_type = null) { $this ->_setGlowSize($size) ->_setGlowColor( diff --git a/Classes/PHPExcel/Chart/DataSeries.php b/Classes/PHPExcel/Chart/DataSeries.php index e6d27712..711f16ce 100644 --- a/Classes/PHPExcel/Chart/DataSeries.php +++ b/Classes/PHPExcel/Chart/DataSeries.php @@ -18,353 +18,352 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PHPExcel - * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @category PHPExcel + * @package PHPExcel_Chart + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ /** * PHPExcel_Chart_DataSeries * - * @category PHPExcel - * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel_Chart + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_DataSeries { + const TYPE_BARCHART = 'barChart'; + const TYPE_BARCHART_3D = 'bar3DChart'; + const TYPE_LINECHART = 'lineChart'; + const TYPE_LINECHART_3D = 'line3DChart'; + const TYPE_AREACHART = 'areaChart'; + const TYPE_AREACHART_3D = 'area3DChart'; + const TYPE_PIECHART = 'pieChart'; + const TYPE_PIECHART_3D = 'pie3DChart'; + const TYPE_DOUGHTNUTCHART = 'doughnutChart'; + const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym + const TYPE_SCATTERCHART = 'scatterChart'; + const TYPE_SURFACECHART = 'surfaceChart'; + const TYPE_SURFACECHART_3D = 'surface3DChart'; + const TYPE_RADARCHART = 'radarChart'; + const TYPE_BUBBLECHART = 'bubbleChart'; + const TYPE_STOCKCHART = 'stockChart'; + const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym - const TYPE_BARCHART = 'barChart'; - const TYPE_BARCHART_3D = 'bar3DChart'; - const TYPE_LINECHART = 'lineChart'; - const TYPE_LINECHART_3D = 'line3DChart'; - const TYPE_AREACHART = 'areaChart'; - const TYPE_AREACHART_3D = 'area3DChart'; - const TYPE_PIECHART = 'pieChart'; - const TYPE_PIECHART_3D = 'pie3DChart'; - const TYPE_DOUGHTNUTCHART = 'doughnutChart'; - const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym - const TYPE_SCATTERCHART = 'scatterChart'; - const TYPE_SURFACECHART = 'surfaceChart'; - const TYPE_SURFACECHART_3D = 'surface3DChart'; - const TYPE_RADARCHART = 'radarChart'; - const TYPE_BUBBLECHART = 'bubbleChart'; - const TYPE_STOCKCHART = 'stockChart'; - const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym + const GROUPING_CLUSTERED = 'clustered'; + const GROUPING_STACKED = 'stacked'; + const GROUPING_PERCENT_STACKED = 'percentStacked'; + const GROUPING_STANDARD = 'standard'; - const GROUPING_CLUSTERED = 'clustered'; - const GROUPING_STACKED = 'stacked'; - const GROUPING_PERCENT_STACKED = 'percentStacked'; - const GROUPING_STANDARD = 'standard'; + const DIRECTION_BAR = 'bar'; + const DIRECTION_HORIZONTAL = self::DIRECTION_BAR; + const DIRECTION_COL = 'col'; + const DIRECTION_COLUMN = self::DIRECTION_COL; + const DIRECTION_VERTICAL = self::DIRECTION_COL; - const DIRECTION_BAR = 'bar'; - const DIRECTION_HORIZONTAL = self::DIRECTION_BAR; - const DIRECTION_COL = 'col'; - const DIRECTION_COLUMN = self::DIRECTION_COL; - const DIRECTION_VERTICAL = self::DIRECTION_COL; - - const STYLE_LINEMARKER = 'lineMarker'; - const STYLE_SMOOTHMARKER = 'smoothMarker'; - const STYLE_MARKER = 'marker'; - const STYLE_FILLED = 'filled'; + const STYLE_LINEMARKER = 'lineMarker'; + const STYLE_SMOOTHMARKER = 'smoothMarker'; + const STYLE_MARKER = 'marker'; + const STYLE_FILLED = 'filled'; - /** - * Series Plot Type - * - * @var string - */ - private $_plotType = null; + /** + * Series Plot Type + * + * @var string + */ + private $_plotType = null; - /** - * Plot Grouping Type - * - * @var boolean - */ - private $_plotGrouping = null; + /** + * Plot Grouping Type + * + * @var boolean + */ + private $_plotGrouping = null; - /** - * Plot Direction - * - * @var boolean - */ - private $_plotDirection = null; + /** + * Plot Direction + * + * @var boolean + */ + private $_plotDirection = null; - /** - * Plot Style - * - * @var string - */ - private $_plotStyle = null; + /** + * Plot Style + * + * @var string + */ + private $_plotStyle = null; - /** - * Order of plots in Series - * - * @var array of integer - */ - private $_plotOrder = array(); + /** + * Order of plots in Series + * + * @var array of integer + */ + private $_plotOrder = array(); - /** - * Plot Label - * - * @var array of PHPExcel_Chart_DataSeriesValues - */ - private $_plotLabel = array(); + /** + * Plot Label + * + * @var array of PHPExcel_Chart_DataSeriesValues + */ + private $_plotLabel = array(); - /** - * Plot Category - * - * @var array of PHPExcel_Chart_DataSeriesValues - */ - private $_plotCategory = array(); + /** + * Plot Category + * + * @var array of PHPExcel_Chart_DataSeriesValues + */ + private $_plotCategory = array(); - /** - * Smooth Line - * - * @var string - */ - private $_smoothLine = null; + /** + * Smooth Line + * + * @var string + */ + private $_smoothLine = null; - /** - * Plot Values - * - * @var array of PHPExcel_Chart_DataSeriesValues - */ - private $_plotValues = array(); + /** + * Plot Values + * + * @var array of PHPExcel_Chart_DataSeriesValues + */ + private $_plotValues = array(); - /** - * Create a new PHPExcel_Chart_DataSeries - */ - public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null) - { - $this->_plotType = $plotType; - $this->_plotGrouping = $plotGrouping; - $this->_plotOrder = $plotOrder; - $keys = array_keys($plotValues); - $this->_plotValues = $plotValues; - if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) { - $plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); - } + /** + * Create a new PHPExcel_Chart_DataSeries + */ + public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null) + { + $this->_plotType = $plotType; + $this->_plotGrouping = $plotGrouping; + $this->_plotOrder = $plotOrder; + $keys = array_keys($plotValues); + $this->_plotValues = $plotValues; + if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) { + $plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); + } - $this->_plotLabel = $plotLabel; - if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) { - $plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); - } - $this->_plotCategory = $plotCategory; - $this->_smoothLine = $smoothLine; - $this->_plotStyle = $plotStyle; - - if (is_null($plotDirection)) { - $plotDirection = self::DIRECTION_COL; - } - $this->_plotDirection = $plotDirection; - } + $this->_plotLabel = $plotLabel; + if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) { + $plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); + } + $this->_plotCategory = $plotCategory; + $this->_smoothLine = $smoothLine; + $this->_plotStyle = $plotStyle; + + if (is_null($plotDirection)) { + $plotDirection = self::DIRECTION_COL; + } + $this->_plotDirection = $plotDirection; + } - /** - * Get Plot Type - * - * @return string - */ - public function getPlotType() { - return $this->_plotType; - } + /** + * Get Plot Type + * + * @return string + */ + public function getPlotType() { + return $this->_plotType; + } - /** - * Set Plot Type - * - * @param string $plotType + /** + * Set Plot Type + * + * @param string $plotType * @return PHPExcel_Chart_DataSeries - */ - public function setPlotType($plotType = '') { - $this->_plotType = $plotType; + */ + public function setPlotType($plotType = '') { + $this->_plotType = $plotType; return $this; - } + } - /** - * Get Plot Grouping Type - * - * @return string - */ - public function getPlotGrouping() { - return $this->_plotGrouping; - } + /** + * Get Plot Grouping Type + * + * @return string + */ + public function getPlotGrouping() { + return $this->_plotGrouping; + } - /** - * Set Plot Grouping Type - * - * @param string $groupingType + /** + * Set Plot Grouping Type + * + * @param string $groupingType * @return PHPExcel_Chart_DataSeries - */ - public function setPlotGrouping($groupingType = null) { - $this->_plotGrouping = $groupingType; + */ + public function setPlotGrouping($groupingType = null) { + $this->_plotGrouping = $groupingType; return $this; - } + } - /** - * Get Plot Direction - * - * @return string - */ - public function getPlotDirection() { - return $this->_plotDirection; - } + /** + * Get Plot Direction + * + * @return string + */ + public function getPlotDirection() { + return $this->_plotDirection; + } - /** - * Set Plot Direction - * - * @param string $plotDirection + /** + * Set Plot Direction + * + * @param string $plotDirection * @return PHPExcel_Chart_DataSeries - */ - public function setPlotDirection($plotDirection = null) { - $this->_plotDirection = $plotDirection; + */ + public function setPlotDirection($plotDirection = null) { + $this->_plotDirection = $plotDirection; return $this; - } + } - /** - * Get Plot Order - * - * @return string - */ - public function getPlotOrder() { - return $this->_plotOrder; - } + /** + * Get Plot Order + * + * @return string + */ + public function getPlotOrder() { + return $this->_plotOrder; + } - /** - * Get Plot Labels - * - * @return array of PHPExcel_Chart_DataSeriesValues - */ - public function getPlotLabels() { - return $this->_plotLabel; - } + /** + * Get Plot Labels + * + * @return array of PHPExcel_Chart_DataSeriesValues + */ + public function getPlotLabels() { + return $this->_plotLabel; + } - /** - * Get Plot Label by Index - * - * @return PHPExcel_Chart_DataSeriesValues - */ - public function getPlotLabelByIndex($index) { - $keys = array_keys($this->_plotLabel); - if (in_array($index,$keys)) { - return $this->_plotLabel[$index]; - } elseif(isset($keys[$index])) { - return $this->_plotLabel[$keys[$index]]; - } - return false; - } + /** + * Get Plot Label by Index + * + * @return PHPExcel_Chart_DataSeriesValues + */ + public function getPlotLabelByIndex($index) { + $keys = array_keys($this->_plotLabel); + if (in_array($index,$keys)) { + return $this->_plotLabel[$index]; + } elseif(isset($keys[$index])) { + return $this->_plotLabel[$keys[$index]]; + } + return false; + } - /** - * Get Plot Categories - * - * @return array of PHPExcel_Chart_DataSeriesValues - */ - public function getPlotCategories() { - return $this->_plotCategory; - } + /** + * Get Plot Categories + * + * @return array of PHPExcel_Chart_DataSeriesValues + */ + public function getPlotCategories() { + return $this->_plotCategory; + } - /** - * Get Plot Category by Index - * - * @return PHPExcel_Chart_DataSeriesValues - */ - public function getPlotCategoryByIndex($index) { - $keys = array_keys($this->_plotCategory); - if (in_array($index,$keys)) { - return $this->_plotCategory[$index]; - } elseif(isset($keys[$index])) { - return $this->_plotCategory[$keys[$index]]; - } - return false; - } + /** + * Get Plot Category by Index + * + * @return PHPExcel_Chart_DataSeriesValues + */ + public function getPlotCategoryByIndex($index) { + $keys = array_keys($this->_plotCategory); + if (in_array($index,$keys)) { + return $this->_plotCategory[$index]; + } elseif(isset($keys[$index])) { + return $this->_plotCategory[$keys[$index]]; + } + return false; + } - /** - * Get Plot Style - * - * @return string - */ - public function getPlotStyle() { - return $this->_plotStyle; - } + /** + * Get Plot Style + * + * @return string + */ + public function getPlotStyle() { + return $this->_plotStyle; + } - /** - * Set Plot Style - * - * @param string $plotStyle + /** + * Set Plot Style + * + * @param string $plotStyle * @return PHPExcel_Chart_DataSeries - */ - public function setPlotStyle($plotStyle = null) { - $this->_plotStyle = $plotStyle; + */ + public function setPlotStyle($plotStyle = null) { + $this->_plotStyle = $plotStyle; return $this; - } + } - /** - * Get Plot Values - * - * @return array of PHPExcel_Chart_DataSeriesValues - */ - public function getPlotValues() { - return $this->_plotValues; - } + /** + * Get Plot Values + * + * @return array of PHPExcel_Chart_DataSeriesValues + */ + public function getPlotValues() { + return $this->_plotValues; + } - /** - * Get Plot Values by Index - * - * @return PHPExcel_Chart_DataSeriesValues - */ - public function getPlotValuesByIndex($index) { - $keys = array_keys($this->_plotValues); - if (in_array($index,$keys)) { - return $this->_plotValues[$index]; - } elseif(isset($keys[$index])) { - return $this->_plotValues[$keys[$index]]; - } - return false; - } + /** + * Get Plot Values by Index + * + * @return PHPExcel_Chart_DataSeriesValues + */ + public function getPlotValuesByIndex($index) { + $keys = array_keys($this->_plotValues); + if (in_array($index,$keys)) { + return $this->_plotValues[$index]; + } elseif(isset($keys[$index])) { + return $this->_plotValues[$keys[$index]]; + } + return false; + } - /** - * Get Number of Plot Series - * - * @return integer - */ - public function getPlotSeriesCount() { - return count($this->_plotValues); - } + /** + * Get Number of Plot Series + * + * @return integer + */ + public function getPlotSeriesCount() { + return count($this->_plotValues); + } - /** - * Get Smooth Line - * - * @return boolean - */ - public function getSmoothLine() { - return $this->_smoothLine; - } + /** + * Get Smooth Line + * + * @return boolean + */ + public function getSmoothLine() { + return $this->_smoothLine; + } - /** - * Set Smooth Line - * - * @param boolean $smoothLine + /** + * Set Smooth Line + * + * @param boolean $smoothLine * @return PHPExcel_Chart_DataSeries - */ - public function setSmoothLine($smoothLine = TRUE) { - $this->_smoothLine = $smoothLine; + */ + public function setSmoothLine($smoothLine = TRUE) { + $this->_smoothLine = $smoothLine; return $this; - } + } - public function refresh(PHPExcel_Worksheet $worksheet) { - foreach($this->_plotValues as $plotValues) { - if ($plotValues !== NULL) - $plotValues->refresh($worksheet, TRUE); - } - foreach($this->_plotLabel as $plotValues) { - if ($plotValues !== NULL) - $plotValues->refresh($worksheet, TRUE); - } - foreach($this->_plotCategory as $plotValues) { - if ($plotValues !== NULL) - $plotValues->refresh($worksheet, FALSE); - } - } + public function refresh(PHPExcel_Worksheet $worksheet) { + foreach($this->_plotValues as $plotValues) { + if ($plotValues !== NULL) + $plotValues->refresh($worksheet, TRUE); + } + foreach($this->_plotLabel as $plotValues) { + if ($plotValues !== NULL) + $plotValues->refresh($worksheet, TRUE); + } + foreach($this->_plotCategory as $plotValues) { + if ($plotValues !== NULL) + $plotValues->refresh($worksheet, FALSE); + } + } } diff --git a/Classes/PHPExcel/Chart/DataSeriesValues.php b/Classes/PHPExcel/Chart/DataSeriesValues.php index eda73fd6..a14b47a1 100644 --- a/Classes/PHPExcel/Chart/DataSeriesValues.php +++ b/Classes/PHPExcel/Chart/DataSeriesValues.php @@ -1,6 +1,7 @@ setDataType($dataType); - $this->_dataSource = $dataSource; - $this->_formatCode = $formatCode; - $this->_pointCount = $pointCount; - $this->_dataValues = $dataValues; - $this->_marker = $marker; - } + /** + * Create a new PHPExcel_Chart_DataSeriesValues object + */ + public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null) + { + $this->setDataType($dataType); + $this->_dataSource = $dataSource; + $this->_formatCode = $formatCode; + $this->_pointCount = $pointCount; + $this->_dataValues = $dataValues; + $this->_marker = $marker; + } - /** - * Get Series Data Type - * - * @return string - */ - public function getDataType() { - return $this->_dataType; - } + /** + * Get Series Data Type + * + * @return string + */ + public function getDataType() { + return $this->_dataType; + } - /** - * Set Series Data Type - * - * @param string $dataType Datatype of this data series - * Typical values are: - * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING - * Normally used for axis point values - * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER - * Normally used for chart data values - * @return PHPExcel_Chart_DataSeriesValues - */ - public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) { - if (!in_array($dataType, self::$_dataTypeValues)) { - throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values'); - } - $this->_dataType = $dataType; + /** + * Set Series Data Type + * + * @param string $dataType Datatype of this data series + * Typical values are: + * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING + * Normally used for axis point values + * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER + * Normally used for chart data values + * @return PHPExcel_Chart_DataSeriesValues + */ + public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) { + if (!in_array($dataType, self::$_dataTypeValues)) { + throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values'); + } + $this->_dataType = $dataType; - return $this; - } + return $this; + } - /** - * Get Series Data Source (formula) - * - * @return string - */ - public function getDataSource() { - return $this->_dataSource; - } + /** + * Get Series Data Source (formula) + * + * @return string + */ + public function getDataSource() { + return $this->_dataSource; + } - /** - * Set Series Data Source (formula) - * - * @param string $dataSource - * @return PHPExcel_Chart_DataSeriesValues - */ - public function setDataSource($dataSource = null, $refreshDataValues = true) { - $this->_dataSource = $dataSource; + /** + * Set Series Data Source (formula) + * + * @param string $dataSource + * @return PHPExcel_Chart_DataSeriesValues + */ + public function setDataSource($dataSource = null, $refreshDataValues = true) { + $this->_dataSource = $dataSource; - if ($refreshDataValues) { - // TO DO - } + if ($refreshDataValues) { + // TO DO + } - return $this; - } + return $this; + } - /** - * Get Point Marker - * - * @return string - */ - public function getPointMarker() { - return $this->_marker; - } + /** + * Get Point Marker + * + * @return string + */ + public function getPointMarker() { + return $this->_marker; + } - /** - * Set Point Marker - * - * @param string $marker - * @return PHPExcel_Chart_DataSeriesValues - */ - public function setPointMarker($marker = null) { - $this->_marker = $marker; + /** + * Set Point Marker + * + * @param string $marker + * @return PHPExcel_Chart_DataSeriesValues + */ + public function setPointMarker($marker = null) { + $this->_marker = $marker; - return $this; - } + return $this; + } - /** - * Get Series Format Code - * - * @return string - */ - public function getFormatCode() { - return $this->_formatCode; - } + /** + * Get Series Format Code + * + * @return string + */ + public function getFormatCode() { + return $this->_formatCode; + } - /** - * Set Series Format Code - * - * @param string $formatCode - * @return PHPExcel_Chart_DataSeriesValues - */ - public function setFormatCode($formatCode = null) { - $this->_formatCode = $formatCode; + /** + * Set Series Format Code + * + * @param string $formatCode + * @return PHPExcel_Chart_DataSeriesValues + */ + public function setFormatCode($formatCode = null) { + $this->_formatCode = $formatCode; - return $this; - } + return $this; + } - /** - * Get Series Point Count - * - * @return integer - */ - public function getPointCount() { - return $this->_pointCount; - } + /** + * Get Series Point Count + * + * @return integer + */ + public function getPointCount() { + return $this->_pointCount; + } - /** - * Identify if the Data Series is a multi-level or a simple series - * - * @return boolean - */ - public function isMultiLevelSeries() { - if (count($this->_dataValues) > 0) { - return is_array($this->_dataValues[0]); - } - return null; - } + /** + * Identify if the Data Series is a multi-level or a simple series + * + * @return boolean + */ + public function isMultiLevelSeries() { + if (count($this->_dataValues) > 0) { + return is_array($this->_dataValues[0]); + } + return null; + } - /** - * Return the level count of a multi-level Data Series - * - * @return boolean - */ - public function multiLevelCount() { - $levelCount = 0; - foreach($this->_dataValues as $dataValueSet) { - $levelCount = max($levelCount,count($dataValueSet)); - } - return $levelCount; - } + /** + * Return the level count of a multi-level Data Series + * + * @return boolean + */ + public function multiLevelCount() { + $levelCount = 0; + foreach($this->_dataValues as $dataValueSet) { + $levelCount = max($levelCount,count($dataValueSet)); + } + return $levelCount; + } - /** - * Get Series Data Values - * - * @return array of mixed - */ - public function getDataValues() { - return $this->_dataValues; - } + /** + * Get Series Data Values + * + * @return array of mixed + */ + public function getDataValues() { + return $this->_dataValues; + } - /** - * Get the first Series Data value - * - * @return mixed - */ - public function getDataValue() { - $count = count($this->_dataValues); - if ($count == 0) { - return null; - } elseif ($count == 1) { - return $this->_dataValues[0]; - } - return $this->_dataValues; - } + /** + * Get the first Series Data value + * + * @return mixed + */ + public function getDataValue() { + $count = count($this->_dataValues); + if ($count == 0) { + return null; + } elseif ($count == 1) { + return $this->_dataValues[0]; + } + return $this->_dataValues; + } - /** - * Set Series Data Values - * - * @param array $dataValues - * @param boolean $refreshDataSource - * TRUE - refresh the value of _dataSource based on the values of $dataValues - * FALSE - don't change the value of _dataSource - * @return PHPExcel_Chart_DataSeriesValues - */ - public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) { - $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues); - $this->_pointCount = count($dataValues); + /** + * Set Series Data Values + * + * @param array $dataValues + * @param boolean $refreshDataSource + * TRUE - refresh the value of _dataSource based on the values of $dataValues + * FALSE - don't change the value of _dataSource + * @return PHPExcel_Chart_DataSeriesValues + */ + public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) { + $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues); + $this->_pointCount = count($dataValues); - if ($refreshDataSource) { - // TO DO - } + if ($refreshDataSource) { + // TO DO + } - return $this; - } + return $this; + } - private function _stripNulls($var) { - return $var !== NULL; - } + private function _stripNulls($var) { + return $var !== NULL; + } - public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) { + public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) { if ($this->_dataSource !== NULL) { - $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent()); - $newDataValues = PHPExcel_Calculation::_unwrapResult( - $calcEngine->_calculateFormulaValue( - '='.$this->_dataSource, - NULL, - $worksheet->getCell('A1') - ) - ); - if ($flatten) { - $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); - foreach($this->_dataValues as &$dataValue) { - if ((!empty($dataValue)) && ($dataValue[0] == '#')) { - $dataValue = 0.0; - } - } - unset($dataValue); - } else { - $cellRange = explode('!',$this->_dataSource); - if (count($cellRange) > 1) { - list(,$cellRange) = $cellRange; - } + $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent()); + $newDataValues = PHPExcel_Calculation::_unwrapResult( + $calcEngine->_calculateFormulaValue( + '='.$this->_dataSource, + NULL, + $worksheet->getCell('A1') + ) + ); + if ($flatten) { + $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); + foreach($this->_dataValues as &$dataValue) { + if ((!empty($dataValue)) && ($dataValue[0] == '#')) { + $dataValue = 0.0; + } + } + unset($dataValue); + } else { + $cellRange = explode('!',$this->_dataSource); + if (count($cellRange) > 1) { + list(,$cellRange) = $cellRange; + } - $dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange)); - if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { - $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); - } else { - $newArray = array_values(array_shift($newDataValues)); - foreach($newArray as $i => $newDataSet) { - $newArray[$i] = array($newDataSet); - } + $dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange)); + if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { + $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); + } else { + $newArray = array_values(array_shift($newDataValues)); + foreach($newArray as $i => $newDataSet) { + $newArray[$i] = array($newDataSet); + } - foreach($newDataValues as $newDataSet) { - $i = 0; - foreach($newDataSet as $newDataVal) { - array_unshift($newArray[$i++],$newDataVal); - } - } - $this->_dataValues = $newArray; - } - } - $this->_pointCount = count($this->_dataValues); - } + foreach($newDataValues as $newDataSet) { + $i = 0; + foreach($newDataSet as $newDataVal) { + array_unshift($newArray[$i++],$newDataVal); + } + } + $this->_dataValues = $newArray; + } + } + $this->_pointCount = count($this->_dataValues); + } - } + } } diff --git a/Classes/PHPExcel/Chart/Exception.php b/Classes/PHPExcel/Chart/Exception.php index 4b5514fc..e20dfa59 100644 --- a/Classes/PHPExcel/Chart/Exception.php +++ b/Classes/PHPExcel/Chart/Exception.php @@ -1,6 +1,7 @@ line = $line; - $e->file = $file; - throw $e; - } +class PHPExcel_Chart_Exception extends PHPExcel_Exception +{ + /** + * Error handler callback + * + * @param mixed $code + * @param mixed $string + * @param mixed $file + * @param mixed $line + * @param mixed $context + */ + public static function errorHandlerCallback($code, $string, $file, $line, $context) + { + $e = new self($string, $code); + $e->line = $line; + $e->file = $file; + throw $e; + } } diff --git a/Classes/PHPExcel/Chart/Layout.php b/Classes/PHPExcel/Chart/Layout.php index cb55b2d0..d524e224 100644 --- a/Classes/PHPExcel/Chart/Layout.php +++ b/Classes/PHPExcel/Chart/Layout.php @@ -18,428 +18,428 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PHPExcel - * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @category PHPExcel + * @package PHPExcel_Chart + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ /** * PHPExcel_Chart_Layout * - * @category PHPExcel - * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel_Chart + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_Layout { - /** - * layoutTarget - * - * @var string - */ - private $_layoutTarget = NULL; + /** + * layoutTarget + * + * @var string + */ + private $_layoutTarget = NULL; - /** - * X Mode - * - * @var string - */ - private $_xMode = NULL; + /** + * X Mode + * + * @var string + */ + private $_xMode = NULL; - /** - * Y Mode - * - * @var string - */ - private $_yMode = NULL; + /** + * Y Mode + * + * @var string + */ + private $_yMode = NULL; - /** - * X-Position - * - * @var float - */ - private $_xPos = NULL; + /** + * X-Position + * + * @var float + */ + private $_xPos = NULL; - /** - * Y-Position - * - * @var float - */ - private $_yPos = NULL; + /** + * Y-Position + * + * @var float + */ + private $_yPos = NULL; - /** - * width - * - * @var float - */ - private $_width = NULL; + /** + * width + * + * @var float + */ + private $_width = NULL; - /** - * height - * - * @var float - */ - private $_height = NULL; + /** + * height + * + * @var float + */ + private $_height = NULL; - /** - * show legend key - * Specifies that legend keys should be shown in data labels - * - * @var boolean - */ - private $_showLegendKey = NULL; + /** + * show legend key + * Specifies that legend keys should be shown in data labels + * + * @var boolean + */ + private $_showLegendKey = NULL; - /** - * show value - * Specifies that the value should be shown in a data label. - * - * @var boolean - */ - private $_showVal = NULL; + /** + * show value + * Specifies that the value should be shown in a data label. + * + * @var boolean + */ + private $_showVal = NULL; - /** - * show category name - * Specifies that the category name should be shown in the data label. - * - * @var boolean - */ - private $_showCatName = NULL; + /** + * show category name + * Specifies that the category name should be shown in the data label. + * + * @var boolean + */ + private $_showCatName = NULL; - /** - * show data series name - * Specifies that the series name should be shown in the data label. - * - * @var boolean - */ - private $_showSerName = NULL; + /** + * show data series name + * Specifies that the series name should be shown in the data label. + * + * @var boolean + */ + private $_showSerName = NULL; - /** - * show percentage - * Specifies that the percentage should be shown in the data label. - * - * @var boolean - */ - private $_showPercent = NULL; + /** + * show percentage + * Specifies that the percentage should be shown in the data label. + * + * @var boolean + */ + private $_showPercent = NULL; - /** - * show bubble size - * - * @var boolean - */ - private $_showBubbleSize = NULL; + /** + * show bubble size + * + * @var boolean + */ + private $_showBubbleSize = NULL; - /** - * show leader lines - * Specifies that leader lines should be shown for the data label. - * - * @var boolean - */ - private $_showLeaderLines = NULL; + /** + * show leader lines + * Specifies that leader lines should be shown for the data label. + * + * @var boolean + */ + private $_showLeaderLines = NULL; - /** - * Create a new PHPExcel_Chart_Layout - */ - public function __construct($layout=array()) - { - if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; } - if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; } - if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; } - if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; } - if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; } - if (isset($layout['w'])) { $this->_width = (float) $layout['w']; } - if (isset($layout['h'])) { $this->_height = (float) $layout['h']; } - } + /** + * Create a new PHPExcel_Chart_Layout + */ + public function __construct($layout=array()) + { + if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; } + if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; } + if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; } + if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; } + if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; } + if (isset($layout['w'])) { $this->_width = (float) $layout['w']; } + if (isset($layout['h'])) { $this->_height = (float) $layout['h']; } + } - /** - * Get Layout Target - * - * @return string - */ - public function getLayoutTarget() { - return $this->_layoutTarget; - } + /** + * Get Layout Target + * + * @return string + */ + public function getLayoutTarget() { + return $this->_layoutTarget; + } - /** - * Set Layout Target - * - * @param Layout Target $value + /** + * Set Layout Target + * + * @param Layout Target $value * @return PHPExcel_Chart_Layout - */ - public function setLayoutTarget($value) { - $this->_layoutTarget = $value; + */ + public function setLayoutTarget($value) { + $this->_layoutTarget = $value; return $this; - } + } - /** - * Get X-Mode - * - * @return string - */ - public function getXMode() { - return $this->_xMode; - } + /** + * Get X-Mode + * + * @return string + */ + public function getXMode() { + return $this->_xMode; + } - /** - * Set X-Mode - * - * @param X-Mode $value + /** + * Set X-Mode + * + * @param X-Mode $value * @return PHPExcel_Chart_Layout - */ - public function setXMode($value) { - $this->_xMode = $value; + */ + public function setXMode($value) { + $this->_xMode = $value; return $this; - } + } - /** - * Get Y-Mode - * - * @return string - */ - public function getYMode() { - return $this->_yMode; - } + /** + * Get Y-Mode + * + * @return string + */ + public function getYMode() { + return $this->_yMode; + } - /** - * Set Y-Mode - * - * @param Y-Mode $value + /** + * Set Y-Mode + * + * @param Y-Mode $value * @return PHPExcel_Chart_Layout - */ - public function setYMode($value) { - $this->_yMode = $value; + */ + public function setYMode($value) { + $this->_yMode = $value; return $this; - } + } - /** - * Get X-Position - * - * @return number - */ - public function getXPosition() { - return $this->_xPos; - } + /** + * Get X-Position + * + * @return number + */ + public function getXPosition() { + return $this->_xPos; + } - /** - * Set X-Position - * - * @param X-Position $value + /** + * Set X-Position + * + * @param X-Position $value * @return PHPExcel_Chart_Layout - */ - public function setXPosition($value) { - $this->_xPos = $value; + */ + public function setXPosition($value) { + $this->_xPos = $value; return $this; - } + } - /** - * Get Y-Position - * - * @return number - */ - public function getYPosition() { - return $this->_yPos; - } + /** + * Get Y-Position + * + * @return number + */ + public function getYPosition() { + return $this->_yPos; + } - /** - * Set Y-Position - * - * @param Y-Position $value + /** + * Set Y-Position + * + * @param Y-Position $value * @return PHPExcel_Chart_Layout - */ - public function setYPosition($value) { - $this->_yPos = $value; + */ + public function setYPosition($value) { + $this->_yPos = $value; return $this; - } + } - /** - * Get Width - * - * @return number - */ - public function getWidth() { - return $this->_width; - } + /** + * Get Width + * + * @return number + */ + public function getWidth() { + return $this->_width; + } - /** - * Set Width - * - * @param Width $value + /** + * Set Width + * + * @param Width $value * @return PHPExcel_Chart_Layout - */ - public function setWidth($value) { - $this->_width = $value; + */ + public function setWidth($value) { + $this->_width = $value; return $this; - } + } - /** - * Get Height - * - * @return number - */ - public function getHeight() { - return $this->_height; - } + /** + * Get Height + * + * @return number + */ + public function getHeight() { + return $this->_height; + } - /** - * Set Height - * - * @param Height $value + /** + * Set Height + * + * @param Height $value * @return PHPExcel_Chart_Layout - */ - public function setHeight($value) { - $this->_height = $value; + */ + public function setHeight($value) { + $this->_height = $value; return $this; - } + } - /** - * Get show legend key - * - * @return boolean - */ - public function getShowLegendKey() { - return $this->_showLegendKey; - } + /** + * Get show legend key + * + * @return boolean + */ + public function getShowLegendKey() { + return $this->_showLegendKey; + } - /** - * Set show legend key - * Specifies that legend keys should be shown in data labels. - * - * @param boolean $value Show legend key + /** + * Set show legend key + * Specifies that legend keys should be shown in data labels. + * + * @param boolean $value Show legend key * @return PHPExcel_Chart_Layout - */ - public function setShowLegendKey($value) { - $this->_showLegendKey = $value; + */ + public function setShowLegendKey($value) { + $this->_showLegendKey = $value; return $this; - } + } - /** - * Get show value - * - * @return boolean - */ - public function getShowVal() { - return $this->_showVal; - } + /** + * Get show value + * + * @return boolean + */ + public function getShowVal() { + return $this->_showVal; + } - /** - * Set show val - * Specifies that the value should be shown in data labels. - * - * @param boolean $value Show val + /** + * Set show val + * Specifies that the value should be shown in data labels. + * + * @param boolean $value Show val * @return PHPExcel_Chart_Layout - */ - public function setShowVal($value) { - $this->_showVal = $value; + */ + public function setShowVal($value) { + $this->_showVal = $value; return $this; - } + } - /** - * Get show category name - * - * @return boolean - */ - public function getShowCatName() { - return $this->_showCatName; - } + /** + * Get show category name + * + * @return boolean + */ + public function getShowCatName() { + return $this->_showCatName; + } - /** - * Set show cat name - * Specifies that the category name should be shown in data labels. - * - * @param boolean $value Show cat name + /** + * Set show cat name + * Specifies that the category name should be shown in data labels. + * + * @param boolean $value Show cat name * @return PHPExcel_Chart_Layout - */ - public function setShowCatName($value) { - $this->_showCatName = $value; + */ + public function setShowCatName($value) { + $this->_showCatName = $value; return $this; - } + } - /** - * Get show data series name - * - * @return boolean - */ - public function getShowSerName() { - return $this->_showSerName; - } + /** + * Get show data series name + * + * @return boolean + */ + public function getShowSerName() { + return $this->_showSerName; + } - /** - * Set show ser name - * Specifies that the series name should be shown in data labels. - * - * @param boolean $value Show series name + /** + * Set show ser name + * Specifies that the series name should be shown in data labels. + * + * @param boolean $value Show series name * @return PHPExcel_Chart_Layout - */ - public function setShowSerName($value) { - $this->_showSerName = $value; + */ + public function setShowSerName($value) { + $this->_showSerName = $value; return $this; - } + } - /** - * Get show percentage - * - * @return boolean - */ - public function getShowPercent() { - return $this->_showPercent; - } + /** + * Get show percentage + * + * @return boolean + */ + public function getShowPercent() { + return $this->_showPercent; + } - /** - * Set show percentage - * Specifies that the percentage should be shown in data labels. - * - * @param boolean $value Show percentage + /** + * Set show percentage + * Specifies that the percentage should be shown in data labels. + * + * @param boolean $value Show percentage * @return PHPExcel_Chart_Layout - */ - public function setShowPercent($value) { - $this->_showPercent = $value; + */ + public function setShowPercent($value) { + $this->_showPercent = $value; return $this; - } + } - /** - * Get show bubble size - * - * @return boolean - */ - public function getShowBubbleSize() { - return $this->_showBubbleSize; - } + /** + * Get show bubble size + * + * @return boolean + */ + public function getShowBubbleSize() { + return $this->_showBubbleSize; + } - /** - * Set show bubble size - * Specifies that the bubble size should be shown in data labels. - * - * @param boolean $value Show bubble size + /** + * Set show bubble size + * Specifies that the bubble size should be shown in data labels. + * + * @param boolean $value Show bubble size * @return PHPExcel_Chart_Layout - */ - public function setShowBubbleSize($value) { - $this->_showBubbleSize = $value; + */ + public function setShowBubbleSize($value) { + $this->_showBubbleSize = $value; return $this; - } + } - /** - * Get show leader lines - * - * @return boolean - */ - public function getShowLeaderLines() { - return $this->_showLeaderLines; - } + /** + * Get show leader lines + * + * @return boolean + */ + public function getShowLeaderLines() { + return $this->_showLeaderLines; + } - /** - * Set show leader lines - * Specifies that leader lines should be shown in data labels. - * - * @param boolean $value Show leader lines + /** + * Set show leader lines + * Specifies that leader lines should be shown in data labels. + * + * @param boolean $value Show leader lines * @return PHPExcel_Chart_Layout - */ - public function setShowLeaderLines($value) { - $this->_showLeaderLines = $value; + */ + public function setShowLeaderLines($value) { + $this->_showLeaderLines = $value; return $this; - } + } } diff --git a/Classes/PHPExcel/Chart/Legend.php b/Classes/PHPExcel/Chart/Legend.php index 5a61e601..c44003bd 100644 --- a/Classes/PHPExcel/Chart/Legend.php +++ b/Classes/PHPExcel/Chart/Legend.php @@ -1,6 +1,7 @@ self::POSITION_BOTTOM, - self::xlLegendPositionCorner => self::POSITION_TOPRIGHT, - self::xlLegendPositionCustom => '??', - self::xlLegendPositionLeft => self::POSITION_LEFT, - self::xlLegendPositionRight => self::POSITION_RIGHT, - self::xlLegendPositionTop => self::POSITION_TOP - ); + private static $_positionXLref = array( + self::xlLegendPositionBottom => self::POSITION_BOTTOM, + self::xlLegendPositionCorner => self::POSITION_TOPRIGHT, + self::xlLegendPositionCustom => '??', + self::xlLegendPositionLeft => self::POSITION_LEFT, + self::xlLegendPositionRight => self::POSITION_RIGHT, + self::xlLegendPositionTop => self::POSITION_TOP + ); - /** - * Legend position - * - * @var string - */ - private $_position = self::POSITION_RIGHT; + /** + * Legend position + * + * @var string + */ + private $_position = self::POSITION_RIGHT; - /** - * Allow overlay of other elements? - * - * @var boolean - */ - private $_overlay = TRUE; + /** + * Allow overlay of other elements? + * + * @var boolean + */ + private $_overlay = TRUE; - /** - * Legend Layout - * - * @var PHPExcel_Chart_Layout - */ - private $_layout = NULL; + /** + * Legend Layout + * + * @var PHPExcel_Chart_Layout + */ + private $_layout = NULL; - /** - * Create a new PHPExcel_Chart_Legend - */ - public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE) - { - $this->setPosition($position); - $this->_layout = $layout; - $this->setOverlay($overlay); - } + /** + * Create a new PHPExcel_Chart_Legend + */ + public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE) + { + $this->setPosition($position); + $this->_layout = $layout; + $this->setOverlay($overlay); + } - /** - * Get legend position as an excel string value - * - * @return string - */ - public function getPosition() { - return $this->_position; - } + /** + * Get legend position as an excel string value + * + * @return string + */ + public function getPosition() { + return $this->_position; + } - /** - * Get legend position using an excel string value - * - * @param string $position - */ - public function setPosition($position = self::POSITION_RIGHT) { - if (!in_array($position,self::$_positionXLref)) { - return false; - } + /** + * Get legend position using an excel string value + * + * @param string $position + */ + public function setPosition($position = self::POSITION_RIGHT) { + if (!in_array($position,self::$_positionXLref)) { + return false; + } - $this->_position = $position; - return true; - } + $this->_position = $position; + return true; + } - /** - * Get legend position as an Excel internal numeric value - * - * @return number - */ - public function getPositionXL() { - return array_search($this->_position,self::$_positionXLref); - } + /** + * Get legend position as an Excel internal numeric value + * + * @return number + */ + public function getPositionXL() { + return array_search($this->_position,self::$_positionXLref); + } - /** - * Set legend position using an Excel internal numeric value - * - * @param number $positionXL - */ - public function setPositionXL($positionXL = self::xlLegendPositionRight) { - if (!array_key_exists($positionXL,self::$_positionXLref)) { - return false; - } + /** + * Set legend position using an Excel internal numeric value + * + * @param number $positionXL + */ + public function setPositionXL($positionXL = self::xlLegendPositionRight) { + if (!array_key_exists($positionXL,self::$_positionXLref)) { + return false; + } - $this->_position = self::$_positionXLref[$positionXL]; - return true; - } + $this->_position = self::$_positionXLref[$positionXL]; + return true; + } - /** - * Get allow overlay of other elements? - * - * @return boolean - */ - public function getOverlay() { - return $this->_overlay; - } + /** + * Get allow overlay of other elements? + * + * @return boolean + */ + public function getOverlay() { + return $this->_overlay; + } - /** - * Set allow overlay of other elements? - * - * @param boolean $overlay - * @return boolean - */ - public function setOverlay($overlay = FALSE) { - if (!is_bool($overlay)) { - return false; - } + /** + * Set allow overlay of other elements? + * + * @param boolean $overlay + * @return boolean + */ + public function setOverlay($overlay = FALSE) { + if (!is_bool($overlay)) { + return false; + } - $this->_overlay = $overlay; - return true; - } + $this->_overlay = $overlay; + return true; + } - /** - * Get Layout - * - * @return PHPExcel_Chart_Layout - */ - public function getLayout() { - return $this->_layout; - } + /** + * Get Layout + * + * @return PHPExcel_Chart_Layout + */ + public function getLayout() { + return $this->_layout; + } } diff --git a/Classes/PHPExcel/Chart/PlotArea.php b/Classes/PHPExcel/Chart/PlotArea.php index a055ae64..657fe981 100644 --- a/Classes/PHPExcel/Chart/PlotArea.php +++ b/Classes/PHPExcel/Chart/PlotArea.php @@ -1,6 +1,7 @@ _layout = $layout; - $this->_plotSeries = $plotSeries; - } + /** + * Create a new PHPExcel_Chart_PlotArea + */ + public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array()) + { + $this->_layout = $layout; + $this->_plotSeries = $plotSeries; + } - /** - * Get Layout - * - * @return PHPExcel_Chart_Layout - */ - public function getLayout() { - return $this->_layout; - } + /** + * Get Layout + * + * @return PHPExcel_Chart_Layout + */ + public function getLayout() { + return $this->_layout; + } - /** - * Get Number of Plot Groups - * - * @return array of PHPExcel_Chart_DataSeries - */ - public function getPlotGroupCount() { - return count($this->_plotSeries); - } + /** + * Get Number of Plot Groups + * + * @return array of PHPExcel_Chart_DataSeries + */ + public function getPlotGroupCount() { + return count($this->_plotSeries); + } - /** - * Get Number of Plot Series - * - * @return integer - */ - public function getPlotSeriesCount() { - $seriesCount = 0; - foreach($this->_plotSeries as $plot) { - $seriesCount += $plot->getPlotSeriesCount(); - } - return $seriesCount; - } + /** + * Get Number of Plot Series + * + * @return integer + */ + public function getPlotSeriesCount() { + $seriesCount = 0; + foreach($this->_plotSeries as $plot) { + $seriesCount += $plot->getPlotSeriesCount(); + } + return $seriesCount; + } - /** - * Get Plot Series - * - * @return array of PHPExcel_Chart_DataSeries - */ - public function getPlotGroup() { - return $this->_plotSeries; - } + /** + * Get Plot Series + * + * @return array of PHPExcel_Chart_DataSeries + */ + public function getPlotGroup() { + return $this->_plotSeries; + } - /** - * Get Plot Series by Index - * - * @return PHPExcel_Chart_DataSeries - */ - public function getPlotGroupByIndex($index) { - return $this->_plotSeries[$index]; - } + /** + * Get Plot Series by Index + * + * @return PHPExcel_Chart_DataSeries + */ + public function getPlotGroupByIndex($index) { + return $this->_plotSeries[$index]; + } - /** - * Set Plot Series - * - * @param [PHPExcel_Chart_DataSeries] + /** + * Set Plot Series + * + * @param [PHPExcel_Chart_DataSeries] * @return PHPExcel_Chart_PlotArea - */ - public function setPlotSeries($plotSeries = array()) { - $this->_plotSeries = $plotSeries; + */ + public function setPlotSeries($plotSeries = array()) { + $this->_plotSeries = $plotSeries; return $this; - } + } - public function refresh(PHPExcel_Worksheet $worksheet) { - foreach($this->_plotSeries as $plotSeries) { - $plotSeries->refresh($worksheet); - } - } + public function refresh(PHPExcel_Worksheet $worksheet) { + foreach($this->_plotSeries as $plotSeries) { + $plotSeries->refresh($worksheet); + } + } } diff --git a/Classes/PHPExcel/Chart/Renderer/jpgraph.php b/Classes/PHPExcel/Chart/Renderer/jpgraph.php index ec1fb252..5994db37 100644 --- a/Classes/PHPExcel/Chart/Renderer/jpgraph.php +++ b/Classes/PHPExcel/Chart/Renderer/jpgraph.php @@ -19,11 +19,11 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PHPExcel - * @package PHPExcel_Chart_Renderer - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @category PHPExcel + * @package PHPExcel_Chart_Renderer + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ @@ -33,823 +33,823 @@ require_once(PHPExcel_Settings::getChartRendererPath().'/jpgraph.php'); /** * PHPExcel_Chart_Renderer_jpgraph * - * @category PHPExcel - * @package PHPExcel_Chart_Renderer - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel_Chart_Renderer + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_Renderer_jpgraph { - private static $_width = 640; + private static $_width = 640; - private static $_height = 480; + private static $_height = 480; - private static $_colourSet = array( 'mediumpurple1', 'palegreen3', 'gold1', 'cadetblue1', - 'darkmagenta', 'coral', 'dodgerblue3', 'eggplant', - 'mediumblue', 'magenta', 'sandybrown', 'cyan', - 'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen', - 'goldenrod2' - ); + private static $_colourSet = array( 'mediumpurple1', 'palegreen3', 'gold1', 'cadetblue1', + 'darkmagenta', 'coral', 'dodgerblue3', 'eggplant', + 'mediumblue', 'magenta', 'sandybrown', 'cyan', + 'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen', + 'goldenrod2' + ); - private static $_markSet = array( 'diamond' => MARK_DIAMOND, - 'square' => MARK_SQUARE, - 'triangle' => MARK_UTRIANGLE, - 'x' => MARK_X, - 'star' => MARK_STAR, - 'dot' => MARK_FILLEDCIRCLE, - 'dash' => MARK_DTRIANGLE, - 'circle' => MARK_CIRCLE, - 'plus' => MARK_CROSS - ); + private static $_markSet = array( 'diamond' => MARK_DIAMOND, + 'square' => MARK_SQUARE, + 'triangle' => MARK_UTRIANGLE, + 'x' => MARK_X, + 'star' => MARK_STAR, + 'dot' => MARK_FILLEDCIRCLE, + 'dash' => MARK_DTRIANGLE, + 'circle' => MARK_CIRCLE, + 'plus' => MARK_CROSS + ); - private $_chart = null; + private $_chart = null; - private $_graph = null; + private $_graph = null; - private static $_plotColour = 0; + private static $_plotColour = 0; - private static $_plotMark = 0; + private static $_plotMark = 0; - private function _formatPointMarker($seriesPlot,$markerID) { - $plotMarkKeys = array_keys(self::$_markSet); - if (is_null($markerID)) { - // Use default plot marker (next marker in the series) - self::$_plotMark %= count(self::$_markSet); - $seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]); - } elseif ($markerID !== 'none') { - // Use specified plot marker (if it exists) - if (isset(self::$_markSet[$markerID])) { - $seriesPlot->mark->SetType(self::$_markSet[$markerID]); - } else { - // If the specified plot marker doesn't exist, use default plot marker (next marker in the series) - self::$_plotMark %= count(self::$_markSet); - $seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]); - } - } else { - // Hide plot marker - $seriesPlot->mark->Hide(); - } - $seriesPlot->mark->SetColor(self::$_colourSet[self::$_plotColour]); - $seriesPlot->mark->SetFillColor(self::$_colourSet[self::$_plotColour]); - $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]); + private function _formatPointMarker($seriesPlot,$markerID) { + $plotMarkKeys = array_keys(self::$_markSet); + if (is_null($markerID)) { + // Use default plot marker (next marker in the series) + self::$_plotMark %= count(self::$_markSet); + $seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]); + } elseif ($markerID !== 'none') { + // Use specified plot marker (if it exists) + if (isset(self::$_markSet[$markerID])) { + $seriesPlot->mark->SetType(self::$_markSet[$markerID]); + } else { + // If the specified plot marker doesn't exist, use default plot marker (next marker in the series) + self::$_plotMark %= count(self::$_markSet); + $seriesPlot->mark->SetType(self::$_markSet[$plotMarkKeys[self::$_plotMark++]]); + } + } else { + // Hide plot marker + $seriesPlot->mark->Hide(); + } + $seriesPlot->mark->SetColor(self::$_colourSet[self::$_plotColour]); + $seriesPlot->mark->SetFillColor(self::$_colourSet[self::$_plotColour]); + $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]); - return $seriesPlot; - } // function _formatPointMarker() + return $seriesPlot; + } // function _formatPointMarker() - private function _formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '') { - $datasetLabelFormatCode = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode(); - if (!is_null($datasetLabelFormatCode)) { - // Retrieve any label formatting code - $datasetLabelFormatCode = stripslashes($datasetLabelFormatCode); - } + private function _formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation = '') { + $datasetLabelFormatCode = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode(); + if (!is_null($datasetLabelFormatCode)) { + // Retrieve any label formatting code + $datasetLabelFormatCode = stripslashes($datasetLabelFormatCode); + } - $testCurrentIndex = 0; - foreach($datasetLabels as $i => $datasetLabel) { - if (is_array($datasetLabel)) { - if ($rotation == 'bar') { - $datasetLabels[$i] = implode(" ",$datasetLabel); - } else { - $datasetLabel = array_reverse($datasetLabel); - $datasetLabels[$i] = implode("\n",$datasetLabel); - } - } else { - // Format labels according to any formatting code - if (!is_null($datasetLabelFormatCode)) { - $datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode); - } - } - ++$testCurrentIndex; - } + $testCurrentIndex = 0; + foreach($datasetLabels as $i => $datasetLabel) { + if (is_array($datasetLabel)) { + if ($rotation == 'bar') { + $datasetLabels[$i] = implode(" ",$datasetLabel); + } else { + $datasetLabel = array_reverse($datasetLabel); + $datasetLabels[$i] = implode("\n",$datasetLabel); + } + } else { + // Format labels according to any formatting code + if (!is_null($datasetLabelFormatCode)) { + $datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode); + } + } + ++$testCurrentIndex; + } - return $datasetLabels; - } // function _formatDataSetLabels() + return $datasetLabels; + } // function _formatDataSetLabels() - private function _percentageSumCalculation($groupID,$seriesCount) { - // Adjust our values to a percentage value across all series in the group - for($i = 0; $i < $seriesCount; ++$i) { - if ($i == 0) { - $sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); - } else { - $nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); - foreach($nextValues as $k => $value) { - if (isset($sumValues[$k])) { - $sumValues[$k] += $value; - } else { - $sumValues[$k] = $value; - } - } - } - } + private function _percentageSumCalculation($groupID,$seriesCount) { + // Adjust our values to a percentage value across all series in the group + for($i = 0; $i < $seriesCount; ++$i) { + if ($i == 0) { + $sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); + } else { + $nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); + foreach($nextValues as $k => $value) { + if (isset($sumValues[$k])) { + $sumValues[$k] += $value; + } else { + $sumValues[$k] = $value; + } + } + } + } - return $sumValues; - } // function _percentageSumCalculation() + return $sumValues; + } // function _percentageSumCalculation() - private function _percentageAdjustValues($dataValues,$sumValues) { - foreach($dataValues as $k => $dataValue) { - $dataValues[$k] = $dataValue / $sumValues[$k] * 100; - } + private function _percentageAdjustValues($dataValues,$sumValues) { + foreach($dataValues as $k => $dataValue) { + $dataValues[$k] = $dataValue / $sumValues[$k] * 100; + } - return $dataValues; - } // function _percentageAdjustValues() + return $dataValues; + } // function _percentageAdjustValues() - private function _getCaption($captionElement) { - // Read any caption - $caption = (!is_null($captionElement)) ? $captionElement->getCaption() : NULL; - // Test if we have a title caption to display - if (!is_null($caption)) { - // If we do, it could be a plain string or an array - if (is_array($caption)) { - // Implode an array to a plain string - $caption = implode('',$caption); - } - } - return $caption; - } // function _getCaption() + private function _getCaption($captionElement) { + // Read any caption + $caption = (!is_null($captionElement)) ? $captionElement->getCaption() : NULL; + // Test if we have a title caption to display + if (!is_null($caption)) { + // If we do, it could be a plain string or an array + if (is_array($caption)) { + // Implode an array to a plain string + $caption = implode('',$caption); + } + } + return $caption; + } // function _getCaption() - private function _renderTitle() { - $title = $this->_getCaption($this->_chart->getTitle()); - if (!is_null($title)) { - $this->_graph->title->Set($title); - } - } // function _renderTitle() + private function _renderTitle() { + $title = $this->_getCaption($this->_chart->getTitle()); + if (!is_null($title)) { + $this->_graph->title->Set($title); + } + } // function _renderTitle() - private function _renderLegend() { - $legend = $this->_chart->getLegend(); - if (!is_null($legend)) { - $legendPosition = $legend->getPosition(); - $legendOverlay = $legend->getOverlay(); - switch ($legendPosition) { - case 'r' : - $this->_graph->legend->SetPos(0.01,0.5,'right','center'); // right - $this->_graph->legend->SetColumns(1); - break; - case 'l' : - $this->_graph->legend->SetPos(0.01,0.5,'left','center'); // left - $this->_graph->legend->SetColumns(1); - break; - case 't' : - $this->_graph->legend->SetPos(0.5,0.01,'center','top'); // top - break; - case 'b' : - $this->_graph->legend->SetPos(0.5,0.99,'center','bottom'); // bottom - break; - default : - $this->_graph->legend->SetPos(0.01,0.01,'right','top'); // top-right - $this->_graph->legend->SetColumns(1); - break; - } - } else { - $this->_graph->legend->Hide(); - } - } // function _renderLegend() + private function _renderLegend() { + $legend = $this->_chart->getLegend(); + if (!is_null($legend)) { + $legendPosition = $legend->getPosition(); + $legendOverlay = $legend->getOverlay(); + switch ($legendPosition) { + case 'r' : + $this->_graph->legend->SetPos(0.01,0.5,'right','center'); // right + $this->_graph->legend->SetColumns(1); + break; + case 'l' : + $this->_graph->legend->SetPos(0.01,0.5,'left','center'); // left + $this->_graph->legend->SetColumns(1); + break; + case 't' : + $this->_graph->legend->SetPos(0.5,0.01,'center','top'); // top + break; + case 'b' : + $this->_graph->legend->SetPos(0.5,0.99,'center','bottom'); // bottom + break; + default : + $this->_graph->legend->SetPos(0.01,0.01,'right','top'); // top-right + $this->_graph->legend->SetColumns(1); + break; + } + } else { + $this->_graph->legend->Hide(); + } + } // function _renderLegend() - private function _renderCartesianPlotArea($type='textlin') { - $this->_graph = new Graph(self::$_width,self::$_height); - $this->_graph->SetScale($type); + private function _renderCartesianPlotArea($type='textlin') { + $this->_graph = new Graph(self::$_width,self::$_height); + $this->_graph->SetScale($type); - $this->_renderTitle(); + $this->_renderTitle(); - // Rotate for bar rather than column chart - $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection(); - $reverse = ($rotation == 'bar') ? true : false; + // Rotate for bar rather than column chart + $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection(); + $reverse = ($rotation == 'bar') ? true : false; - $xAxisLabel = $this->_chart->getXAxisLabel(); - if (!is_null($xAxisLabel)) { - $title = $this->_getCaption($xAxisLabel); - if (!is_null($title)) { - $this->_graph->xaxis->SetTitle($title,'center'); - $this->_graph->xaxis->title->SetMargin(35); - if ($reverse) { - $this->_graph->xaxis->title->SetAngle(90); - $this->_graph->xaxis->title->SetMargin(90); - } - } - } + $xAxisLabel = $this->_chart->getXAxisLabel(); + if (!is_null($xAxisLabel)) { + $title = $this->_getCaption($xAxisLabel); + if (!is_null($title)) { + $this->_graph->xaxis->SetTitle($title,'center'); + $this->_graph->xaxis->title->SetMargin(35); + if ($reverse) { + $this->_graph->xaxis->title->SetAngle(90); + $this->_graph->xaxis->title->SetMargin(90); + } + } + } - $yAxisLabel = $this->_chart->getYAxisLabel(); - if (!is_null($yAxisLabel)) { - $title = $this->_getCaption($yAxisLabel); - if (!is_null($title)) { - $this->_graph->yaxis->SetTitle($title,'center'); - if ($reverse) { - $this->_graph->yaxis->title->SetAngle(0); - $this->_graph->yaxis->title->SetMargin(-55); - } - } - } - } // function _renderCartesianPlotArea() + $yAxisLabel = $this->_chart->getYAxisLabel(); + if (!is_null($yAxisLabel)) { + $title = $this->_getCaption($yAxisLabel); + if (!is_null($title)) { + $this->_graph->yaxis->SetTitle($title,'center'); + if ($reverse) { + $this->_graph->yaxis->title->SetAngle(0); + $this->_graph->yaxis->title->SetMargin(-55); + } + } + } + } // function _renderCartesianPlotArea() - private function _renderPiePlotArea($doughnut = False) { - $this->_graph = new PieGraph(self::$_width,self::$_height); + private function _renderPiePlotArea($doughnut = False) { + $this->_graph = new PieGraph(self::$_width,self::$_height); - $this->_renderTitle(); - } // function _renderPiePlotArea() + $this->_renderTitle(); + } // function _renderPiePlotArea() - private function _renderRadarPlotArea() { - $this->_graph = new RadarGraph(self::$_width,self::$_height); - $this->_graph->SetScale('lin'); + private function _renderRadarPlotArea() { + $this->_graph = new RadarGraph(self::$_width,self::$_height); + $this->_graph->SetScale('lin'); - $this->_renderTitle(); - } // function _renderRadarPlotArea() + $this->_renderTitle(); + } // function _renderRadarPlotArea() - private function _renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') { - $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); + private function _renderPlotLine($groupID, $filled = false, $combination = false, $dimensions = '2d') { + $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); - if ($labelCount > 0) { - $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); - $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); - $this->_graph->xaxis->SetTickLabels($datasetLabels); - } + if ($labelCount > 0) { + $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); + $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); + $this->_graph->xaxis->SetTickLabels($datasetLabels); + } - $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); - $seriesPlots = array(); - if ($grouping == 'percentStacked') { - $sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); - } + $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); + $seriesPlots = array(); + if ($grouping == 'percentStacked') { + $sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); + } - // Loop through each data series in turn - for($i = 0; $i < $seriesCount; ++$i) { - $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); - $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); + // Loop through each data series in turn + for($i = 0; $i < $seriesCount; ++$i) { + $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); + $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); - if ($grouping == 'percentStacked') { - $dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); - } + if ($grouping == 'percentStacked') { + $dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); + } - // Fill in any missing values in the $dataValues array - $testCurrentIndex = 0; - foreach($dataValues as $k => $dataValue) { - while($k != $testCurrentIndex) { - $dataValues[$testCurrentIndex] = null; - ++$testCurrentIndex; - } - ++$testCurrentIndex; - } + // Fill in any missing values in the $dataValues array + $testCurrentIndex = 0; + foreach($dataValues as $k => $dataValue) { + while($k != $testCurrentIndex) { + $dataValues[$testCurrentIndex] = null; + ++$testCurrentIndex; + } + ++$testCurrentIndex; + } - $seriesPlot = new LinePlot($dataValues); - if ($combination) { - $seriesPlot->SetBarCenter(); - } + $seriesPlot = new LinePlot($dataValues); + if ($combination) { + $seriesPlot->SetBarCenter(); + } - if ($filled) { - $seriesPlot->SetFilled(true); - $seriesPlot->SetColor('black'); - $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]); - } else { - // Set the appropriate plot marker - $this->_formatPointMarker($seriesPlot,$marker); - } - $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); - $seriesPlot->SetLegend($dataLabel); + if ($filled) { + $seriesPlot->SetFilled(true); + $seriesPlot->SetColor('black'); + $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]); + } else { + // Set the appropriate plot marker + $this->_formatPointMarker($seriesPlot,$marker); + } + $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); + $seriesPlot->SetLegend($dataLabel); - $seriesPlots[] = $seriesPlot; - } + $seriesPlots[] = $seriesPlot; + } - if ($grouping == 'standard') { - $groupPlot = $seriesPlots; - } else { - $groupPlot = new AccLinePlot($seriesPlots); - } - $this->_graph->Add($groupPlot); - } // function _renderPlotLine() + if ($grouping == 'standard') { + $groupPlot = $seriesPlots; + } else { + $groupPlot = new AccLinePlot($seriesPlots); + } + $this->_graph->Add($groupPlot); + } // function _renderPlotLine() - private function _renderPlotBar($groupID, $dimensions = '2d') { - $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection(); - // Rotate for bar rather than column chart - if (($groupID == 0) && ($rotation == 'bar')) { - $this->_graph->Set90AndMargin(); - } - $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); + private function _renderPlotBar($groupID, $dimensions = '2d') { + $rotation = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection(); + // Rotate for bar rather than column chart + if (($groupID == 0) && ($rotation == 'bar')) { + $this->_graph->Set90AndMargin(); + } + $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); - if ($labelCount > 0) { - $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); - $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation); - // Rotate for bar rather than column chart - if ($rotation == 'bar') { - $datasetLabels = array_reverse($datasetLabels); - $this->_graph->yaxis->SetPos('max'); - $this->_graph->yaxis->SetLabelAlign('center','top'); - $this->_graph->yaxis->SetLabelSide(SIDE_RIGHT); - } - $this->_graph->xaxis->SetTickLabels($datasetLabels); - } + if ($labelCount > 0) { + $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); + $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount, $rotation); + // Rotate for bar rather than column chart + if ($rotation == 'bar') { + $datasetLabels = array_reverse($datasetLabels); + $this->_graph->yaxis->SetPos('max'); + $this->_graph->yaxis->SetLabelAlign('center','top'); + $this->_graph->yaxis->SetLabelSide(SIDE_RIGHT); + } + $this->_graph->xaxis->SetTickLabels($datasetLabels); + } - $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); - $seriesPlots = array(); - if ($grouping == 'percentStacked') { - $sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); - } + $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); + $seriesPlots = array(); + if ($grouping == 'percentStacked') { + $sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); + } - // Loop through each data series in turn - for($j = 0; $j < $seriesCount; ++$j) { - $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); - if ($grouping == 'percentStacked') { - $dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); - } + // Loop through each data series in turn + for($j = 0; $j < $seriesCount; ++$j) { + $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); + if ($grouping == 'percentStacked') { + $dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); + } - // Fill in any missing values in the $dataValues array - $testCurrentIndex = 0; - foreach($dataValues as $k => $dataValue) { - while($k != $testCurrentIndex) { - $dataValues[$testCurrentIndex] = null; - ++$testCurrentIndex; - } - ++$testCurrentIndex; - } + // Fill in any missing values in the $dataValues array + $testCurrentIndex = 0; + foreach($dataValues as $k => $dataValue) { + while($k != $testCurrentIndex) { + $dataValues[$testCurrentIndex] = null; + ++$testCurrentIndex; + } + ++$testCurrentIndex; + } - // Reverse the $dataValues order for bar rather than column chart - if ($rotation == 'bar') { - $dataValues = array_reverse($dataValues); - } - $seriesPlot = new BarPlot($dataValues); - $seriesPlot->SetColor('black'); - $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]); - if ($dimensions == '3d') { - $seriesPlot->SetShadow(); - } - if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) { - $dataLabel = ''; - } else { - $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue(); - } - $seriesPlot->SetLegend($dataLabel); + // Reverse the $dataValues order for bar rather than column chart + if ($rotation == 'bar') { + $dataValues = array_reverse($dataValues); + } + $seriesPlot = new BarPlot($dataValues); + $seriesPlot->SetColor('black'); + $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]); + if ($dimensions == '3d') { + $seriesPlot->SetShadow(); + } + if (!$this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)) { + $dataLabel = ''; + } else { + $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($j)->getDataValue(); + } + $seriesPlot->SetLegend($dataLabel); - $seriesPlots[] = $seriesPlot; - } - // Reverse the plot order for bar rather than column chart - if (($rotation == 'bar') && (!($grouping == 'percentStacked'))) { - $seriesPlots = array_reverse($seriesPlots); - } + $seriesPlots[] = $seriesPlot; + } + // Reverse the plot order for bar rather than column chart + if (($rotation == 'bar') && (!($grouping == 'percentStacked'))) { + $seriesPlots = array_reverse($seriesPlots); + } - if ($grouping == 'clustered') { - $groupPlot = new GroupBarPlot($seriesPlots); - } elseif ($grouping == 'standard') { - $groupPlot = new GroupBarPlot($seriesPlots); - } else { - $groupPlot = new AccBarPlot($seriesPlots); - if ($dimensions == '3d') { - $groupPlot->SetShadow(); - } - } + if ($grouping == 'clustered') { + $groupPlot = new GroupBarPlot($seriesPlots); + } elseif ($grouping == 'standard') { + $groupPlot = new GroupBarPlot($seriesPlots); + } else { + $groupPlot = new AccBarPlot($seriesPlots); + if ($dimensions == '3d') { + $groupPlot->SetShadow(); + } + } - $this->_graph->Add($groupPlot); - } // function _renderPlotBar() + $this->_graph->Add($groupPlot); + } // function _renderPlotBar() - private function _renderPlotScatter($groupID,$bubble) { - $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); - $scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); + private function _renderPlotScatter($groupID,$bubble) { + $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); + $scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); - $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); - $seriesPlots = array(); + $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); + $seriesPlots = array(); - // Loop through each data series in turn - for($i = 0; $i < $seriesCount; ++$i) { - $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); - $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); + // Loop through each data series in turn + for($i = 0; $i < $seriesCount; ++$i) { + $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); + $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); - foreach($dataValuesY as $k => $dataValueY) { - $dataValuesY[$k] = $k; - } + foreach($dataValuesY as $k => $dataValueY) { + $dataValuesY[$k] = $k; + } - $seriesPlot = new ScatterPlot($dataValuesX,$dataValuesY); - if ($scatterStyle == 'lineMarker') { - $seriesPlot->SetLinkPoints(); - $seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]); - } elseif ($scatterStyle == 'smoothMarker') { - $spline = new Spline($dataValuesY,$dataValuesX); - list($splineDataY,$splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20); - $lplot = new LinePlot($splineDataX,$splineDataY); - $lplot->SetColor(self::$_colourSet[self::$_plotColour]); + $seriesPlot = new ScatterPlot($dataValuesX,$dataValuesY); + if ($scatterStyle == 'lineMarker') { + $seriesPlot->SetLinkPoints(); + $seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]); + } elseif ($scatterStyle == 'smoothMarker') { + $spline = new Spline($dataValuesY,$dataValuesX); + list($splineDataY,$splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20); + $lplot = new LinePlot($splineDataX,$splineDataY); + $lplot->SetColor(self::$_colourSet[self::$_plotColour]); - $this->_graph->Add($lplot); - } + $this->_graph->Add($lplot); + } - if ($bubble) { - $this->_formatPointMarker($seriesPlot,'dot'); - $seriesPlot->mark->SetColor('black'); - $seriesPlot->mark->SetSize($bubbleSize); - } else { - $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); - $this->_formatPointMarker($seriesPlot,$marker); - } - $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); - $seriesPlot->SetLegend($dataLabel); + if ($bubble) { + $this->_formatPointMarker($seriesPlot,'dot'); + $seriesPlot->mark->SetColor('black'); + $seriesPlot->mark->SetSize($bubbleSize); + } else { + $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); + $this->_formatPointMarker($seriesPlot,$marker); + } + $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); + $seriesPlot->SetLegend($dataLabel); - $this->_graph->Add($seriesPlot); - } - } // function _renderPlotScatter() + $this->_graph->Add($seriesPlot); + } + } // function _renderPlotScatter() - private function _renderPlotRadar($groupID) { - $radarStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); + private function _renderPlotRadar($groupID) { + $radarStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); - $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); - $seriesPlots = array(); + $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); + $seriesPlots = array(); - // Loop through each data series in turn - for($i = 0; $i < $seriesCount; ++$i) { - $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); - $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); - $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); + // Loop through each data series in turn + for($i = 0; $i < $seriesCount; ++$i) { + $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); + $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); + $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); - $dataValues = array(); - foreach($dataValuesY as $k => $dataValueY) { - $dataValues[$k] = implode(' ',array_reverse($dataValueY)); - } - $tmp = array_shift($dataValues); - $dataValues[] = $tmp; - $tmp = array_shift($dataValuesX); - $dataValuesX[] = $tmp; + $dataValues = array(); + foreach($dataValuesY as $k => $dataValueY) { + $dataValues[$k] = implode(' ',array_reverse($dataValueY)); + } + $tmp = array_shift($dataValues); + $dataValues[] = $tmp; + $tmp = array_shift($dataValuesX); + $dataValuesX[] = $tmp; - $this->_graph->SetTitles(array_reverse($dataValues)); + $this->_graph->SetTitles(array_reverse($dataValues)); - $seriesPlot = new RadarPlot(array_reverse($dataValuesX)); + $seriesPlot = new RadarPlot(array_reverse($dataValuesX)); - $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); - $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]); - if ($radarStyle == 'filled') { - $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]); - } - $this->_formatPointMarker($seriesPlot,$marker); - $seriesPlot->SetLegend($dataLabel); + $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); + $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]); + if ($radarStyle == 'filled') { + $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]); + } + $this->_formatPointMarker($seriesPlot,$marker); + $seriesPlot->SetLegend($dataLabel); - $this->_graph->Add($seriesPlot); - } - } // function _renderPlotRadar() + $this->_graph->Add($seriesPlot); + } + } // function _renderPlotRadar() - private function _renderPlotContour($groupID) { - $contourStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); + private function _renderPlotContour($groupID) { + $contourStyle = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); - $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); - $seriesPlots = array(); + $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); + $seriesPlots = array(); - $dataValues = array(); - // Loop through each data series in turn - for($i = 0; $i < $seriesCount; ++$i) { - $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); - $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); + $dataValues = array(); + // Loop through each data series in turn + for($i = 0; $i < $seriesCount; ++$i) { + $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); + $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); - $dataValues[$i] = $dataValuesX; - } - $seriesPlot = new ContourPlot($dataValues); + $dataValues[$i] = $dataValuesX; + } + $seriesPlot = new ContourPlot($dataValues); - $this->_graph->Add($seriesPlot); - } // function _renderPlotContour() + $this->_graph->Add($seriesPlot); + } // function _renderPlotContour() - private function _renderPlotStock($groupID) { - $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); - $plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); + private function _renderPlotStock($groupID) { + $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); + $plotOrder = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); - $dataValues = array(); - // Loop through each data series in turn and build the plot arrays - foreach($plotOrder as $i => $v) { - $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues(); - foreach($dataValuesX as $j => $dataValueX) { - $dataValues[$plotOrder[$i]][$j] = $dataValueX; - } - } - if(empty($dataValues)) { - return; - } + $dataValues = array(); + // Loop through each data series in turn and build the plot arrays + foreach($plotOrder as $i => $v) { + $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues(); + foreach($dataValuesX as $j => $dataValueX) { + $dataValues[$plotOrder[$i]][$j] = $dataValueX; + } + } + if(empty($dataValues)) { + return; + } - $dataValuesPlot = array(); + $dataValuesPlot = array(); // Flatten the plot arrays to a single dimensional array to work with jpgraph - for($j = 0; $j < count($dataValues[0]); $j++) { - for($i = 0; $i < $seriesCount; $i++) { - $dataValuesPlot[] = $dataValues[$i][$j]; - } - } + for($j = 0; $j < count($dataValues[0]); $j++) { + for($i = 0; $i < $seriesCount; $i++) { + $dataValuesPlot[] = $dataValues[$i][$j]; + } + } // Set the x-axis labels $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); - if ($labelCount > 0) { - $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); - $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); - $this->_graph->xaxis->SetTickLabels($datasetLabels); - } + if ($labelCount > 0) { + $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); + $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); + $this->_graph->xaxis->SetTickLabels($datasetLabels); + } - $seriesPlot = new StockPlot($dataValuesPlot); - $seriesPlot->SetWidth(20); + $seriesPlot = new StockPlot($dataValuesPlot); + $seriesPlot->SetWidth(20); - $this->_graph->Add($seriesPlot); - } // function _renderPlotStock() + $this->_graph->Add($seriesPlot); + } // function _renderPlotStock() - private function _renderAreaChart($groupCount, $dimensions = '2d') { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); + private function _renderAreaChart($groupCount, $dimensions = '2d') { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); - $this->_renderCartesianPlotArea(); + $this->_renderCartesianPlotArea(); - for($i = 0; $i < $groupCount; ++$i) { - $this->_renderPlotLine($i,True,False,$dimensions); - } - } // function _renderAreaChart() + for($i = 0; $i < $groupCount; ++$i) { + $this->_renderPlotLine($i,True,False,$dimensions); + } + } // function _renderAreaChart() - private function _renderLineChart($groupCount, $dimensions = '2d') { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); + private function _renderLineChart($groupCount, $dimensions = '2d') { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); - $this->_renderCartesianPlotArea(); + $this->_renderCartesianPlotArea(); - for($i = 0; $i < $groupCount; ++$i) { - $this->_renderPlotLine($i,False,False,$dimensions); - } - } // function _renderLineChart() + for($i = 0; $i < $groupCount; ++$i) { + $this->_renderPlotLine($i,False,False,$dimensions); + } + } // function _renderLineChart() - private function _renderBarChart($groupCount, $dimensions = '2d') { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); + private function _renderBarChart($groupCount, $dimensions = '2d') { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); - $this->_renderCartesianPlotArea(); + $this->_renderCartesianPlotArea(); - for($i = 0; $i < $groupCount; ++$i) { - $this->_renderPlotBar($i,$dimensions); - } - } // function _renderBarChart() + for($i = 0; $i < $groupCount; ++$i) { + $this->_renderPlotBar($i,$dimensions); + } + } // function _renderBarChart() - private function _renderScatterChart($groupCount) { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); + private function _renderScatterChart($groupCount) { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); - $this->_renderCartesianPlotArea('linlin'); + $this->_renderCartesianPlotArea('linlin'); - for($i = 0; $i < $groupCount; ++$i) { - $this->_renderPlotScatter($i,false); - } - } // function _renderScatterChart() + for($i = 0; $i < $groupCount; ++$i) { + $this->_renderPlotScatter($i,false); + } + } // function _renderScatterChart() - private function _renderBubbleChart($groupCount) { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); + private function _renderBubbleChart($groupCount) { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); - $this->_renderCartesianPlotArea('linlin'); + $this->_renderCartesianPlotArea('linlin'); - for($i = 0; $i < $groupCount; ++$i) { - $this->_renderPlotScatter($i,true); - } - } // function _renderBubbleChart() + for($i = 0; $i < $groupCount; ++$i) { + $this->_renderPlotScatter($i,true); + } + } // function _renderBubbleChart() - private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie.php'); - if ($dimensions == '3d') { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie3d.php'); - } + private function _renderPieChart($groupCount, $dimensions = '2d', $doughnut = False, $multiplePlots = False) { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie.php'); + if ($dimensions == '3d') { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_pie3d.php'); + } - $this->_renderPiePlotArea($doughnut); + $this->_renderPiePlotArea($doughnut); - $iLimit = ($multiplePlots) ? $groupCount : 1; - for($groupID = 0; $groupID < $iLimit; ++$groupID) { - $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); - $exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); - if ($groupID == 0) { - $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); - if ($labelCount > 0) { - $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); - $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); - } - } + $iLimit = ($multiplePlots) ? $groupCount : 1; + for($groupID = 0; $groupID < $iLimit; ++$groupID) { + $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); + $exploded = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); + if ($groupID == 0) { + $labelCount = count($this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex(0)->getPointCount()); + if ($labelCount > 0) { + $datasetLabels = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getDataValues(); + $datasetLabels = $this->_formatDataSetLabels($groupID, $datasetLabels, $labelCount); + } + } - $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); - $seriesPlots = array(); - // For pie charts, we only display the first series: doughnut charts generally display all series - $jLimit = ($multiplePlots) ? $seriesCount : 1; - // Loop through each data series in turn - for($j = 0; $j < $jLimit; ++$j) { - $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); + $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); + $seriesPlots = array(); + // For pie charts, we only display the first series: doughnut charts generally display all series + $jLimit = ($multiplePlots) ? $seriesCount : 1; + // Loop through each data series in turn + for($j = 0; $j < $jLimit; ++$j) { + $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); - // Fill in any missing values in the $dataValues array - $testCurrentIndex = 0; - foreach($dataValues as $k => $dataValue) { - while($k != $testCurrentIndex) { - $dataValues[$testCurrentIndex] = null; - ++$testCurrentIndex; - } - ++$testCurrentIndex; - } + // Fill in any missing values in the $dataValues array + $testCurrentIndex = 0; + foreach($dataValues as $k => $dataValue) { + while($k != $testCurrentIndex) { + $dataValues[$testCurrentIndex] = null; + ++$testCurrentIndex; + } + ++$testCurrentIndex; + } - if ($dimensions == '3d') { - $seriesPlot = new PiePlot3D($dataValues); - } else { - if ($doughnut) { - $seriesPlot = new PiePlotC($dataValues); - } else { - $seriesPlot = new PiePlot($dataValues); - } - } + if ($dimensions == '3d') { + $seriesPlot = new PiePlot3D($dataValues); + } else { + if ($doughnut) { + $seriesPlot = new PiePlotC($dataValues); + } else { + $seriesPlot = new PiePlot($dataValues); + } + } - if ($multiplePlots) { - $seriesPlot->SetSize(($jLimit-$j) / ($jLimit * 4)); - } + if ($multiplePlots) { + $seriesPlot->SetSize(($jLimit-$j) / ($jLimit * 4)); + } - if ($doughnut) { - $seriesPlot->SetMidColor('white'); - } + if ($doughnut) { + $seriesPlot->SetMidColor('white'); + } - $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]); - if (count($datasetLabels) > 0) - $seriesPlot->SetLabels(array_fill(0,count($datasetLabels),'')); - if ($dimensions != '3d') { - $seriesPlot->SetGuideLines(false); - } - if ($j == 0) { - if ($exploded) { - $seriesPlot->ExplodeAll(); - } - $seriesPlot->SetLegends($datasetLabels); - } + $seriesPlot->SetColor(self::$_colourSet[self::$_plotColour++]); + if (count($datasetLabels) > 0) + $seriesPlot->SetLabels(array_fill(0,count($datasetLabels),'')); + if ($dimensions != '3d') { + $seriesPlot->SetGuideLines(false); + } + if ($j == 0) { + if ($exploded) { + $seriesPlot->ExplodeAll(); + } + $seriesPlot->SetLegends($datasetLabels); + } - $this->_graph->Add($seriesPlot); - } - } - } // function _renderPieChart() + $this->_graph->Add($seriesPlot); + } + } + } // function _renderPieChart() - private function _renderRadarChart($groupCount) { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_radar.php'); + private function _renderRadarChart($groupCount) { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_radar.php'); - $this->_renderRadarPlotArea(); + $this->_renderRadarPlotArea(); - for($groupID = 0; $groupID < $groupCount; ++$groupID) { - $this->_renderPlotRadar($groupID); - } - } // function _renderRadarChart() + for($groupID = 0; $groupID < $groupCount; ++$groupID) { + $this->_renderPlotRadar($groupID); + } + } // function _renderRadarChart() - private function _renderStockChart($groupCount) { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_stock.php'); + private function _renderStockChart($groupCount) { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_stock.php'); - $this->_renderCartesianPlotArea('intint'); + $this->_renderCartesianPlotArea('intint'); - for($groupID = 0; $groupID < $groupCount; ++$groupID) { - $this->_renderPlotStock($groupID); - } - } // function _renderStockChart() + for($groupID = 0; $groupID < $groupCount; ++$groupID) { + $this->_renderPlotStock($groupID); + } + } // function _renderStockChart() - private function _renderContourChart($groupCount,$dimensions) { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php'); + private function _renderContourChart($groupCount,$dimensions) { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php'); - $this->_renderCartesianPlotArea('intint'); + $this->_renderCartesianPlotArea('intint'); - for($i = 0; $i < $groupCount; ++$i) { - $this->_renderPlotContour($i); - } - } // function _renderContourChart() + for($i = 0; $i < $groupCount; ++$i) { + $this->_renderPlotContour($i); + } + } // function _renderContourChart() - private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) { - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); - require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); + private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) { + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_regstat.php'); + require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); - $this->_renderCartesianPlotArea(); + $this->_renderCartesianPlotArea(); - for($i = 0; $i < $groupCount; ++$i) { - $dimensions = null; - $chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); - switch ($chartType) { - case 'area3DChart' : - $dimensions = '3d'; - case 'areaChart' : - $this->_renderPlotLine($i,True,True,$dimensions); - break; - case 'bar3DChart' : - $dimensions = '3d'; - case 'barChart' : - $this->_renderPlotBar($i,$dimensions); - break; - case 'line3DChart' : - $dimensions = '3d'; - case 'lineChart' : - $this->_renderPlotLine($i,False,True,$dimensions); - break; - case 'scatterChart' : - $this->_renderPlotScatter($i,false); - break; - case 'bubbleChart' : - $this->_renderPlotScatter($i,true); - break; - default : - $this->_graph = null; - return false; - } - } + for($i = 0; $i < $groupCount; ++$i) { + $dimensions = null; + $chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); + switch ($chartType) { + case 'area3DChart' : + $dimensions = '3d'; + case 'areaChart' : + $this->_renderPlotLine($i,True,True,$dimensions); + break; + case 'bar3DChart' : + $dimensions = '3d'; + case 'barChart' : + $this->_renderPlotBar($i,$dimensions); + break; + case 'line3DChart' : + $dimensions = '3d'; + case 'lineChart' : + $this->_renderPlotLine($i,False,True,$dimensions); + break; + case 'scatterChart' : + $this->_renderPlotScatter($i,false); + break; + case 'bubbleChart' : + $this->_renderPlotScatter($i,true); + break; + default : + $this->_graph = null; + return false; + } + } - $this->_renderLegend(); + $this->_renderLegend(); - $this->_graph->Stroke($outputDestination); - return true; - } // function _renderCombinationChart() + $this->_graph->Stroke($outputDestination); + return true; + } // function _renderCombinationChart() - public function render($outputDestination) { + public function render($outputDestination) { self::$_plotColour = 0; - $groupCount = $this->_chart->getPlotArea()->getPlotGroupCount(); + $groupCount = $this->_chart->getPlotArea()->getPlotGroupCount(); - $dimensions = null; - if ($groupCount == 1) { - $chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType(); - } else { - $chartTypes = array(); - for($i = 0; $i < $groupCount; ++$i) { - $chartTypes[] = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); - } - $chartTypes = array_unique($chartTypes); - if (count($chartTypes) == 1) { - $chartType = array_pop($chartTypes); - } elseif (count($chartTypes) == 0) { - echo 'Chart is not yet implemented
'; - return false; - } else { - return $this->_renderCombinationChart($groupCount,$dimensions,$outputDestination); - } - } + $dimensions = null; + if ($groupCount == 1) { + $chartType = $this->_chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType(); + } else { + $chartTypes = array(); + for($i = 0; $i < $groupCount; ++$i) { + $chartTypes[] = $this->_chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType(); + } + $chartTypes = array_unique($chartTypes); + if (count($chartTypes) == 1) { + $chartType = array_pop($chartTypes); + } elseif (count($chartTypes) == 0) { + echo 'Chart is not yet implemented
'; + return false; + } else { + return $this->_renderCombinationChart($groupCount,$dimensions,$outputDestination); + } + } - switch ($chartType) { - case 'area3DChart' : - $dimensions = '3d'; - case 'areaChart' : - $this->_renderAreaChart($groupCount,$dimensions); - break; - case 'bar3DChart' : - $dimensions = '3d'; - case 'barChart' : - $this->_renderBarChart($groupCount,$dimensions); - break; - case 'line3DChart' : - $dimensions = '3d'; - case 'lineChart' : - $this->_renderLineChart($groupCount,$dimensions); - break; - case 'pie3DChart' : - $dimensions = '3d'; - case 'pieChart' : - $this->_renderPieChart($groupCount,$dimensions,False,False); - break; - case 'doughnut3DChart' : - $dimensions = '3d'; - case 'doughnutChart' : - $this->_renderPieChart($groupCount,$dimensions,True,True); - break; - case 'scatterChart' : - $this->_renderScatterChart($groupCount); - break; - case 'bubbleChart' : - $this->_renderBubbleChart($groupCount); - break; - case 'radarChart' : - $this->_renderRadarChart($groupCount); - break; - case 'surface3DChart' : - $dimensions = '3d'; - case 'surfaceChart' : - $this->_renderContourChart($groupCount,$dimensions); - break; - case 'stockChart' : - $this->_renderStockChart($groupCount,$dimensions); - break; - default : - echo $chartType.' is not yet implemented
'; - return false; - } - $this->_renderLegend(); + switch ($chartType) { + case 'area3DChart' : + $dimensions = '3d'; + case 'areaChart' : + $this->_renderAreaChart($groupCount,$dimensions); + break; + case 'bar3DChart' : + $dimensions = '3d'; + case 'barChart' : + $this->_renderBarChart($groupCount,$dimensions); + break; + case 'line3DChart' : + $dimensions = '3d'; + case 'lineChart' : + $this->_renderLineChart($groupCount,$dimensions); + break; + case 'pie3DChart' : + $dimensions = '3d'; + case 'pieChart' : + $this->_renderPieChart($groupCount,$dimensions,False,False); + break; + case 'doughnut3DChart' : + $dimensions = '3d'; + case 'doughnutChart' : + $this->_renderPieChart($groupCount,$dimensions,True,True); + break; + case 'scatterChart' : + $this->_renderScatterChart($groupCount); + break; + case 'bubbleChart' : + $this->_renderBubbleChart($groupCount); + break; + case 'radarChart' : + $this->_renderRadarChart($groupCount); + break; + case 'surface3DChart' : + $dimensions = '3d'; + case 'surfaceChart' : + $this->_renderContourChart($groupCount,$dimensions); + break; + case 'stockChart' : + $this->_renderStockChart($groupCount,$dimensions); + break; + default : + echo $chartType.' is not yet implemented
'; + return false; + } + $this->_renderLegend(); - $this->_graph->Stroke($outputDestination); - return true; - } // function render() + $this->_graph->Stroke($outputDestination); + return true; + } // function render() - /** - * Create a new PHPExcel_Chart_Renderer_jpgraph - */ - public function __construct(PHPExcel_Chart $chart) - { - $this->_graph = null; - $this->_chart = $chart; - } // function __construct() + /** + * Create a new PHPExcel_Chart_Renderer_jpgraph + */ + public function __construct(PHPExcel_Chart $chart) + { + $this->_graph = null; + $this->_chart = $chart; + } // function __construct() -} // PHPExcel_Chart_Renderer_jpgraph +} // PHPExcel_Chart_Renderer_jpgraph diff --git a/Classes/PHPExcel/Chart/Title.php b/Classes/PHPExcel/Chart/Title.php index 1a222326..c68a0b91 100644 --- a/Classes/PHPExcel/Chart/Title.php +++ b/Classes/PHPExcel/Chart/Title.php @@ -18,75 +18,75 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * @category PHPExcel - * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL - * @version ##VERSION##, ##DATE## + * @category PHPExcel + * @package PHPExcel_Chart + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL + * @version ##VERSION##, ##DATE## */ /** * PHPExcel_Chart_Title * - * @category PHPExcel - * @package PHPExcel_Chart - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel_Chart + * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Chart_Title { - /** - * Title Caption - * - * @var string - */ - private $_caption = null; + /** + * Title Caption + * + * @var string + */ + private $_caption = null; - /** - * Title Layout - * - * @var PHPExcel_Chart_Layout - */ - private $_layout = null; + /** + * Title Layout + * + * @var PHPExcel_Chart_Layout + */ + private $_layout = null; - /** - * Create a new PHPExcel_Chart_Title - */ - public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null) - { - $this->_caption = $caption; - $this->_layout = $layout; - } + /** + * Create a new PHPExcel_Chart_Title + */ + public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null) + { + $this->_caption = $caption; + $this->_layout = $layout; + } - /** - * Get caption - * - * @return string - */ - public function getCaption() { - return $this->_caption; - } + /** + * Get caption + * + * @return string + */ + public function getCaption() { + return $this->_caption; + } - /** - * Set caption - * - * @param string $caption + /** + * Set caption + * + * @param string $caption * @return PHPExcel_Chart_Title - */ - public function setCaption($caption = null) { - $this->_caption = $caption; + */ + public function setCaption($caption = null) { + $this->_caption = $caption; return $this; - } + } - /** - * Get Layout - * - * @return PHPExcel_Chart_Layout - */ - public function getLayout() { - return $this->_layout; - } + /** + * Get Layout + * + * @return PHPExcel_Chart_Layout + */ + public function getLayout() { + return $this->_layout; + } } diff --git a/Classes/PHPExcel/Writer/HTML.php b/Classes/PHPExcel/Writer/HTML.php index 42329b0e..99a68630 100644 --- a/Classes/PHPExcel/Writer/HTML.php +++ b/Classes/PHPExcel/Writer/HTML.php @@ -53,7 +53,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @var boolean */ - private $_embedImages = FALSE; + private $_embedImages = false; /** * Use inline CSS? @@ -130,7 +130,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @param PHPExcel $phpExcel PHPExcel object */ - public function __construct(PHPExcel $phpExcel) { + public function __construct(PHPExcel $phpExcel) + { $this->_phpExcel = $phpExcel; $this->_defaultFont = $this->_phpExcel->getDefaultStyle()->getFont(); } @@ -141,12 +142,13 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param string $pFilename * @throws PHPExcel_Writer_Exception */ - public function save($pFilename = null) { + public function save($pFilename = null) + { // garbage collect $this->_phpExcel->garbageCollect(); $saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); - PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(FALSE); + PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->setWriteDebugLog(false); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType(); PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); @@ -186,13 +188,18 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param string $vAlign Vertical alignment * @return string */ - private function _mapVAlign($vAlign) { + private function _mapVAlign($vAlign) + { switch ($vAlign) { - case PHPExcel_Style_Alignment::VERTICAL_BOTTOM: return 'bottom'; - case PHPExcel_Style_Alignment::VERTICAL_TOP: return 'top'; + case PHPExcel_Style_Alignment::VERTICAL_BOTTOM: + return 'bottom'; + case PHPExcel_Style_Alignment::VERTICAL_TOP: + return 'top'; case PHPExcel_Style_Alignment::VERTICAL_CENTER: - case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY: return 'middle'; - default: return 'baseline'; + case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY: + return 'middle'; + default: + return 'baseline'; } } @@ -202,15 +209,22 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param string $hAlign Horizontal alignment * @return string|false */ - private function _mapHAlign($hAlign) { + private function _mapHAlign($hAlign) + { switch ($hAlign) { - case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL: return false; - case PHPExcel_Style_Alignment::HORIZONTAL_LEFT: return 'left'; - case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT: return 'right'; + case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL: + return false; + case PHPExcel_Style_Alignment::HORIZONTAL_LEFT: + return 'left'; + case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT: + return 'right'; case PHPExcel_Style_Alignment::HORIZONTAL_CENTER: - case PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS: return 'center'; - case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY: return 'justify'; - default: return false; + case PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS: + return 'center'; + case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY: + return 'justify'; + default: + return false; } } @@ -220,23 +234,40 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param int $borderStyle Sheet index * @return string */ - private function _mapBorderStyle($borderStyle) { + private function _mapBorderStyle($borderStyle) + { switch ($borderStyle) { - case PHPExcel_Style_Border::BORDER_NONE: return 'none'; - case PHPExcel_Style_Border::BORDER_DASHDOT: return '1px dashed'; - case PHPExcel_Style_Border::BORDER_DASHDOTDOT: return '1px dotted'; - case PHPExcel_Style_Border::BORDER_DASHED: return '1px dashed'; - case PHPExcel_Style_Border::BORDER_DOTTED: return '1px dotted'; - case PHPExcel_Style_Border::BORDER_DOUBLE: return '3px double'; - case PHPExcel_Style_Border::BORDER_HAIR: return '1px solid'; - case PHPExcel_Style_Border::BORDER_MEDIUM: return '2px solid'; - case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT: return '2px dashed'; - case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT: return '2px dotted'; - case PHPExcel_Style_Border::BORDER_MEDIUMDASHED: return '2px dashed'; - case PHPExcel_Style_Border::BORDER_SLANTDASHDOT: return '2px dashed'; - case PHPExcel_Style_Border::BORDER_THICK: return '3px solid'; - case PHPExcel_Style_Border::BORDER_THIN: return '1px solid'; - default: return '1px solid'; // map others to thin + case PHPExcel_Style_Border::BORDER_NONE: + return 'none'; + case PHPExcel_Style_Border::BORDER_DASHDOT: + return '1px dashed'; + case PHPExcel_Style_Border::BORDER_DASHDOTDOT: + return '1px dotted'; + case PHPExcel_Style_Border::BORDER_DASHED: + return '1px dashed'; + case PHPExcel_Style_Border::BORDER_DOTTED: + return '1px dotted'; + case PHPExcel_Style_Border::BORDER_DOUBLE: + return '3px double'; + case PHPExcel_Style_Border::BORDER_HAIR: + return '1px solid'; + case PHPExcel_Style_Border::BORDER_MEDIUM: + return '2px solid'; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT: + return '2px dashed'; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT: + return '2px dotted'; + case PHPExcel_Style_Border::BORDER_MEDIUMDASHED: + return '2px dashed'; + case PHPExcel_Style_Border::BORDER_SLANTDASHDOT: + return '2px dashed'; + case PHPExcel_Style_Border::BORDER_THICK: + return '3px solid'; + case PHPExcel_Style_Border::BORDER_THIN: + return '1px solid'; + default: + // map others to thin + return '1px solid'; } } @@ -245,7 +276,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @return int */ - public function getSheetIndex() { + public function getSheetIndex() + { return $this->_sheetIndex; } @@ -255,7 +287,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param int $pValue Sheet index * @return PHPExcel_Writer_HTML */ - public function setSheetIndex($pValue = 0) { + public function setSheetIndex($pValue = 0) + { $this->_sheetIndex = $pValue; return $this; } @@ -265,7 +298,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @return boolean */ - public function getGenerateSheetNavigationBlock() { + public function getGenerateSheetNavigationBlock() + { return $this->_generateSheetNavigationBlock; } @@ -275,7 +309,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param boolean $pValue Flag indicating whether the sheet navigation block should be generated or not * @return PHPExcel_Writer_HTML */ - public function setGenerateSheetNavigationBlock($pValue = true) { + public function setGenerateSheetNavigationBlock($pValue = true) + { $this->_generateSheetNavigationBlock = (bool) $pValue; return $this; } @@ -283,7 +318,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ /** * Write all sheets (resets sheetIndex to NULL) */ - public function writeAllSheets() { + public function writeAllSheets() + { $this->_sheetIndex = null; return $this; } @@ -295,7 +331,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - public function generateHTMLHeader($pIncludeStyles = false) { + public function generateHTMLHeader($pIncludeStyles = false) + { // PHPExcel object known? if (is_null($this->_phpExcel)) { throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); @@ -308,25 +345,33 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $html .= '' . PHP_EOL; $html .= ' ' . PHP_EOL; $html .= ' ' . PHP_EOL; - if ($properties->getTitle() > '') + if ($properties->getTitle() > '') { $html .= ' ' . htmlspecialchars($properties->getTitle()) . '' . PHP_EOL; - - if ($properties->getCreator() > '') + } + if ($properties->getCreator() > '') { $html .= ' ' . PHP_EOL; - if ($properties->getTitle() > '') + } + if ($properties->getTitle() > '') { $html .= ' ' . PHP_EOL; - if ($properties->getDescription() > '') + } + if ($properties->getDescription() > '') { $html .= ' ' . PHP_EOL; - if ($properties->getSubject() > '') + } + if ($properties->getSubject() > '') { $html .= ' ' . PHP_EOL; - if ($properties->getKeywords() > '') + } + if ($properties->getKeywords() > '') { $html .= ' ' . PHP_EOL; - if ($properties->getCategory() > '') + } + if ($properties->getCategory() > '') { $html .= ' ' . PHP_EOL; - if ($properties->getCompany() > '') + } + if ($properties->getCompany() > '') { $html .= ' ' . PHP_EOL; - if ($properties->getManager() > '') + } + if ($properties->getManager() > '') { $html .= ' ' . PHP_EOL; + } if ($pIncludeStyles) { $html .= $this->generateStyles(true); @@ -336,7 +381,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $html .= '' . PHP_EOL; $html .= ' ' . PHP_EOL; - // Return return $html; } @@ -346,7 +390,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - public function generateSheetData() { + public function generateSheetData() + { // PHPExcel object known? if (is_null($this->_phpExcel)) { throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); @@ -401,7 +446,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // Loop through cells $row = $rowMin-1; - while($row++ < $rowMax) { + while ($row++ < $rowMax) { // ? if ($row == $theadStart) { $html .= ' ' . PHP_EOL; @@ -415,12 +460,12 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ } // Write row if there are HTML table cells in it - if ( !isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row]) ) { + if (!isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row])) { // Start a new rowData $rowData = array(); // Loop through columns $column = $dimension[0][0] - 1; - while($column++ < $dimension[1][0]) { + while ($column++ < $dimension[1][0]) { // Cell exists? if ($sheet->cellExistsByColumnAndRow($column, $row)) { $rowData[$column] = PHPExcel_Cell::stringFromColumnIndex($column) . $row; @@ -455,7 +500,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ ++$sheetId; } - // Return return $html; } @@ -501,7 +545,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ return $html; } - private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row) { + private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row) + { $rowMax = $row; $colMax = 'A'; if ($this->_includeCharts) { @@ -559,7 +604,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) { + private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) + { // Construct HTML $html = ''; @@ -590,8 +636,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $imageData = $filename; } else { $imageDetails = getimagesize($filename); - if ($fp = fopen($filename,"rb", 0)) { - $picture = fread($fp,filesize($filename)); + if ($fp = fopen($filename, "rb", 0)) { + $picture = fread($fp, filesize($filename)); fclose($fp); // base64 encode the binary data, then break it // into chunks according to RFC 2045 semantics @@ -603,16 +649,15 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ } $html .= '
'; - $html .= 'getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: ' . + $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="' . $imageData . '" border="0" />'; $html .= '
'; } } } - // Return return $html; } @@ -624,7 +669,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - private function _writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates) { + private function _writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates) + { // Construct HTML $html = ''; @@ -640,8 +686,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $html .= PHP_EOL; $imageDetails = getimagesize($chartFileName); - if ($fp = fopen($chartFileName,"rb", 0)) { - $picture = fread($fp,filesize($chartFileName)); + if ($fp = fopen($chartFileName, "rb", 0)) { + $picture = fread($fp, filesize($chartFileName)); fclose($fp); // base64 encode the binary data, then break it // into chunks according to RFC 2045 semantics @@ -669,7 +715,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - public function generateStyles($generateSurroundingHTML = true) { + public function generateStyles($generateSurroundingHTML = true) + { // PHPExcel object known? if (is_null($this->_phpExcel)) { throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); @@ -710,7 +757,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return array * @throws PHPExcel_Writer_Exception */ - public function buildCSS($generateSurroundingHTML = true) { + public function buildCSS($generateSurroundingHTML = true) + { // PHPExcel object known? if (is_null($this->_phpExcel)) { throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); @@ -768,8 +816,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // Calculate cell style hashes foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) { - $css['td.style' . $index] = $this->_createCSSStyle( $style ); - $css['th.style' . $index] = $this->_createCSSStyle( $style ); + $css['td.style' . $index] = $this->_createCSSStyle($style); + $css['th.style' . $index] = $this->_createCSSStyle($style); } // Fetch sheets @@ -792,7 +840,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // col elements, initialize $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1; $column = -1; - while($column++ < $highestColumnIndex) { + while ($column++ < $highestColumnIndex) { $this->_columnWidths[$sheetIndex][$column] = 42; // approximation $css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt'; } @@ -864,16 +912,17 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param PHPExcel_Style $pStyle PHPExcel_Style * @return array */ - private function _createCSSStyle(PHPExcel_Style $pStyle) { + private function _createCSSStyle(PHPExcel_Style $pStyle) + { // Construct CSS $css = ''; // Create CSS $css = array_merge( - $this->_createCSSStyleAlignment($pStyle->getAlignment()) - , $this->_createCSSStyleBorders($pStyle->getBorders()) - , $this->_createCSSStyleFont($pStyle->getFont()) - , $this->_createCSSStyleFill($pStyle->getFill()) + $this->_createCSSStyleAlignment($pStyle->getAlignment()), + $this->_createCSSStyleBorders($pStyle->getBorders()), + $this->_createCSSStyleFont($pStyle->getFont()), + $this->_createCSSStyleFill($pStyle->getFill()) ); // Return @@ -886,7 +935,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param PHPExcel_Style_Alignment $pStyle PHPExcel_Style_Alignment * @return array */ - private function _createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle) { + private function _createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle) + { // Construct CSS $css = array(); @@ -894,11 +944,11 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $css['vertical-align'] = $this->_mapVAlign($pStyle->getVertical()); if ($textAlign = $this->_mapHAlign($pStyle->getHorizontal())) { $css['text-align'] = $textAlign; - if(in_array($textAlign,array('left','right'))) + if (in_array($textAlign,array('left','right'))) { $css['padding-'.$textAlign] = (string)((int)$pStyle->getIndent() * 9).'px'; + } } - // Return return $css; } @@ -908,7 +958,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font * @return array */ - private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle) { + private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle) + { // Construct CSS $css = array(); @@ -918,20 +969,19 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ } if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE && $pStyle->getStrikethrough()) { $css['text-decoration'] = 'underline line-through'; - } else if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE) { + } elseif ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE) { $css['text-decoration'] = 'underline'; - } else if ($pStyle->getStrikethrough()) { + } elseif ($pStyle->getStrikethrough()) { $css['text-decoration'] = 'line-through'; } if ($pStyle->getItalic()) { $css['font-style'] = 'italic'; } - $css['color'] = '#' . $pStyle->getColor()->getRGB(); - $css['font-family'] = '\'' . $pStyle->getName() . '\''; - $css['font-size'] = $pStyle->getSize() . 'pt'; + $css['color'] = '#' . $pStyle->getColor()->getRGB(); + $css['font-family'] = '\'' . $pStyle->getName() . '\''; + $css['font-size'] = $pStyle->getSize() . 'pt'; - // Return return $css; } @@ -941,17 +991,17 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param PHPExcel_Style_Borders $pStyle PHPExcel_Style_Borders * @return array */ - private function _createCSSStyleBorders(PHPExcel_Style_Borders $pStyle) { + private function _createCSSStyleBorders(PHPExcel_Style_Borders $pStyle) + { // Construct CSS $css = array(); // Create CSS - $css['border-bottom'] = $this->_createCSSStyleBorder($pStyle->getBottom()); - $css['border-top'] = $this->_createCSSStyleBorder($pStyle->getTop()); - $css['border-left'] = $this->_createCSSStyleBorder($pStyle->getLeft()); - $css['border-right'] = $this->_createCSSStyleBorder($pStyle->getRight()); + $css['border-bottom'] = $this->_createCSSStyleBorder($pStyle->getBottom()); + $css['border-top'] = $this->_createCSSStyleBorder($pStyle->getTop()); + $css['border-left'] = $this->_createCSSStyleBorder($pStyle->getLeft()); + $css['border-right'] = $this->_createCSSStyleBorder($pStyle->getRight()); - // Return return $css; } @@ -961,14 +1011,14 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param PHPExcel_Style_Border $pStyle PHPExcel_Style_Border * @return string */ - private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle) { + private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle) + { // Create CSS // $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB(); // Create CSS - add !important to non-none border styles for merged cells - $borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle()); - $css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important'); + $borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle()); + $css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important'); - // Return return $css; } @@ -978,7 +1028,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param PHPExcel_Style_Fill $pStyle PHPExcel_Style_Fill * @return array */ - private function _createCSSStyleFill(PHPExcel_Style_Fill $pStyle) { + private function _createCSSStyleFill(PHPExcel_Style_Fill $pStyle) + { // Construct HTML $css = array(); @@ -987,20 +1038,19 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ 'white' : '#' . $pStyle->getStartColor()->getRGB(); $css['background-color'] = $value; - // Return return $css; } /** * Generate HTML footer */ - public function generateHTMLFooter() { + public function generateHTMLFooter() + { // Construct HTML $html = ''; $html .= ' ' . PHP_EOL; $html .= '' . PHP_EOL; - // Return return $html; } @@ -1011,7 +1061,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - private function _generateTableHeader($pSheet) { + private function _generateTableHeader($pSheet) + { $sheetIndex = $pSheet->getParent()->getIndex($pSheet); // Construct HTML @@ -1035,7 +1086,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ // Write elements $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1; $i = -1; - while($i++ < $highestColumnIndex) { + while ($i++ < $highestColumnIndex) { if (!$this->_isPdf) { if (!$this->_useInlineCss) { $html .= ' ' . PHP_EOL; @@ -1047,7 +1098,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ } } - // Return return $html; } @@ -1056,12 +1106,10 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @throws PHPExcel_Writer_Exception */ - private function _generateTableFooter() { - // Construct HTML - $html = ''; - $html .= ' ' . PHP_EOL; + private function _generateTableFooter() + { + $html = ' ' . PHP_EOL; - // Return return $html; } @@ -1074,7 +1122,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @return string * @throws PHPExcel_Writer_Exception */ - private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0, $cellType = 'td') { + private function _generateRow(PHPExcel_Worksheet $pSheet, $pValues = null, $pRow = 0, $cellType = 'td') + { if (is_array($pValues)) { // Construct HTML $html = ''; @@ -1152,7 +1201,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ if ($element->getFont()->getSuperScript()) { $cellData .= ''; - } else if ($element->getFont()->getSubScript()) { + } elseif ($element->getFont()->getSubScript()) { $cellData .= ''; } } @@ -1164,7 +1213,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ if ($element instanceof PHPExcel_RichText_Run) { if ($element->getFont()->getSuperScript()) { $cellData .= ''; - } else if ($element->getFont()->getSubScript()) { + } elseif ($element->getFont()->getSubScript()) { $cellData .= ''; } @@ -1175,20 +1224,20 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ if ($this->_preCalculateFormulas) { $cellData = PHPExcel_Style_NumberFormat::toFormattedString( $cell->getCalculatedValue(), - $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(), + $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(), array($this, 'formatColor') ); } else { $cellData = PHPExcel_Style_NumberFormat::toFormattedString( $cell->getValue(), - $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(), + $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(), array($this, 'formatColor') ); } $cellData = htmlspecialchars($cellData); - if ($pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getFont()->getSuperScript()) { + if ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperScript()) { $cellData = ''.$cellData.''; - } elseif ($pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getFont()->getSubScript()) { + } elseif ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSubScript()) { $cellData = ''.$cellData.''; } } @@ -1231,8 +1280,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ } // Should the cell be written or is it swallowed by a rowspan or colspan? - $writeCell = ! ( isset($this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]) - && $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum] ); + $writeCell = !(isset($this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]) + && $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]); // Colspan and Rowspan $colspan = 1; @@ -1263,7 +1312,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $width = 0; $i = $colNum - 1; $e = $colNum + $colSpan - 1; - while($i++ < $e) { + while ($i++ < $e) { if (isset($this->_columnWidths[$sheetIndex][$i])) { $width += $this->_columnWidths[$sheetIndex][$i]; } @@ -1286,7 +1335,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ if ($rowSpan > 1) { $html .= ' rowspan="' . $rowSpan . '"'; } - $html .= '>'; + $html .= '>'; // Image? $html .= $this->_writeImageInCell($pSheet, $coordinate); @@ -1339,7 +1388,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @return string */ - public function getImagesRoot() { + public function getImagesRoot() + { return $this->_imagesRoot; } @@ -1349,7 +1399,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param string $pValue * @return PHPExcel_Writer_HTML */ - public function setImagesRoot($pValue = '.') { + public function setImagesRoot($pValue = '.') + { $this->_imagesRoot = $pValue; return $this; } @@ -1359,7 +1410,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @return boolean */ - public function getEmbedImages() { + public function getEmbedImages() + { return $this->_embedImages; } @@ -1369,7 +1421,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param boolean $pValue * @return PHPExcel_Writer_HTML */ - public function setEmbedImages($pValue = '.') { + public function setEmbedImages($pValue = '.') + { $this->_embedImages = $pValue; return $this; } @@ -1379,7 +1432,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * * @return boolean */ - public function getUseInlineCss() { + public function getUseInlineCss() + { return $this->_useInlineCss; } @@ -1389,7 +1443,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ * @param boolean $pValue * @return PHPExcel_Writer_HTML */ - public function setUseInlineCss($pValue = false) { + public function setUseInlineCss($pValue = false) + { $this->_useInlineCss = $pValue; return $this; } @@ -1515,7 +1570,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ $this->_spansAreCalculated = true; } - private function _setMargins(PHPExcel_Worksheet $pSheet) { + private function _setMargins(PHPExcel_Worksheet $pSheet) + { $htmlPage = '@page { '; $htmlBody = 'body { '; @@ -1537,5 +1593,4 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_ return "\n"; } - }