More PSR-2 changes

This commit is contained in:
MarkBaker 2015-05-12 08:00:59 +01:00
parent c70e289dac
commit 0d855d0627
15 changed files with 2313 additions and 2237 deletions

View File

@ -40,7 +40,7 @@ class PHPExcel_Cell
* *
* @var PHPExcel_Cell_IValueBinder * @var PHPExcel_Cell_IValueBinder
*/ */
private static $_valueBinder = NULL; private static $_valueBinder;
/** /**
* Value of the cell * Value of the cell
@ -59,7 +59,7 @@ class PHPExcel_Cell
* *
* @var mixed * @var mixed
*/ */
private $_calculatedValue = NULL; private $_calculatedValue;
/** /**
* Type of the cell data * Type of the cell data
@ -94,17 +94,20 @@ class PHPExcel_Cell
* *
* @return void * @return void
**/ **/
public function notifyCacheController() { public function notifyCacheController()
{
$this->_parent->updateCacheData($this); $this->_parent->updateCacheData($this);
return $this; return $this;
} }
public function detach() { public function detach()
$this->_parent = NULL; {
$this->_parent = null;
} }
public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent) { public function attach(PHPExcel_CachedObjectStorage_CacheBase $parent)
{
$this->_parent = $parent; $this->_parent = $parent;
} }
@ -117,7 +120,7 @@ class PHPExcel_Cell
* @param PHPExcel_Worksheet $pSheet * @param PHPExcel_Worksheet $pSheet
* @throws PHPExcel_Exception * @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 // Initialise cell value
$this->_value = $pValue; $this->_value = $pValue;
@ -126,9 +129,10 @@ class PHPExcel_Cell
$this->_parent = $pSheet->getCellCacheController(); $this->_parent = $pSheet->getCellCacheController();
// Set datatype? // Set datatype?
if ($pDataType !== NULL) { if ($pDataType !== null) {
if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) if ($pDataType == PHPExcel_Cell_DataType::TYPE_STRING2) {
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING; $pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
}
$this->_dataType = $pDataType; $this->_dataType = $pDataType;
} elseif (!self::getValueBinder()->bindValue($this, $pValue)) { } elseif (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell."); throw new PHPExcel_Exception("Value could not be bound to cell.");
@ -183,10 +187,10 @@ class PHPExcel_Cell
public function getFormattedValue() public function getFormattedValue()
{ {
return (string) PHPExcel_Style_NumberFormat::toFormattedString( return (string) PHPExcel_Style_NumberFormat::toFormattedString(
$this->getCalculatedValue(), $this->getCalculatedValue(),
$this->getStyle() $this->getStyle()
->getNumberFormat()->getFormatCode() ->getNumberFormat()->getFormatCode()
); );
} }
/** /**
@ -198,7 +202,7 @@ class PHPExcel_Cell
* @return PHPExcel_Cell * @return PHPExcel_Cell
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function setValue($pValue = NULL) public function setValue($pValue = null)
{ {
if (!self::getValueBinder()->bindValue($this, $pValue)) { if (!self::getValueBinder()->bindValue($this, $pValue)) {
throw new PHPExcel_Exception("Value could not be bound to cell."); throw new PHPExcel_Exception("Value could not be bound to cell.");
@ -214,7 +218,7 @@ class PHPExcel_Cell
* @return PHPExcel_Cell * @return PHPExcel_Cell
* @throws PHPExcel_Exception * @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 // set the value according to data type
switch ($pDataType) { switch ($pDataType) {
@ -224,17 +228,19 @@ class PHPExcel_Cell
case PHPExcel_Cell_DataType::TYPE_STRING2: case PHPExcel_Cell_DataType::TYPE_STRING2:
$pDataType = PHPExcel_Cell_DataType::TYPE_STRING; $pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
case PHPExcel_Cell_DataType::TYPE_STRING: case PHPExcel_Cell_DataType::TYPE_STRING:
// Synonym for string
case PHPExcel_Cell_DataType::TYPE_INLINE: case PHPExcel_Cell_DataType::TYPE_INLINE:
// Rich text
$this->_value = PHPExcel_Cell_DataType::checkString($pValue); $this->_value = PHPExcel_Cell_DataType::checkString($pValue);
break; break;
case PHPExcel_Cell_DataType::TYPE_NUMERIC: case PHPExcel_Cell_DataType::TYPE_NUMERIC:
$this->_value = (float)$pValue; $this->_value = (float) $pValue;
break; break;
case PHPExcel_Cell_DataType::TYPE_FORMULA: case PHPExcel_Cell_DataType::TYPE_FORMULA:
$this->_value = (string)$pValue; $this->_value = (string) $pValue;
break; break;
case PHPExcel_Cell_DataType::TYPE_BOOL: case PHPExcel_Cell_DataType::TYPE_BOOL:
$this->_value = (bool)$pValue; $this->_value = (bool) $pValue;
break; break;
case PHPExcel_Cell_DataType::TYPE_ERROR: case PHPExcel_Cell_DataType::TYPE_ERROR:
$this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue); $this->_value = PHPExcel_Cell_DataType::checkErrorCode($pValue);
@ -259,7 +265,7 @@ class PHPExcel_Cell
* @return mixed * @return mixed
* @throws PHPExcel_Exception * @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; //echo 'Cell '.$this->getCoordinate().' value is a '.$this->_dataType.' with a value of '.$this->getValue().PHP_EOL;
if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) { if ($this->_dataType == PHPExcel_Cell_DataType::TYPE_FORMULA) {
@ -267,7 +273,7 @@ class PHPExcel_Cell
//echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL; //echo 'Cell value for '.$this->getCoordinate().' is a formula: Calculating value'.PHP_EOL;
$result = PHPExcel_Calculation::getInstance( $result = PHPExcel_Calculation::getInstance(
$this->getWorksheet()->getParent() $this->getWorksheet()->getParent()
)->calculateCellValue($this,$resetLog); )->calculateCellValue($this, $resetLog);
//echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL; //echo $this->getCoordinate().' calculation result is '.$result.PHP_EOL;
// We don't yet handle array returns // We don't yet handle array returns
if (is_array($result)) { if (is_array($result)) {
@ -275,8 +281,8 @@ class PHPExcel_Cell
$result = array_pop($result); $result = array_pop($result);
} }
} }
} catch ( PHPExcel_Exception $ex ) { } catch (PHPExcel_Exception $ex) {
if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== NULL)) { if (($ex->getMessage() === 'Unable to access External Workbook') && ($this->_calculatedValue !== null)) {
//echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL; //echo 'Returning fallback value of '.$this->_calculatedValue.' for cell '.$this->getCoordinate().PHP_EOL;
return $this->_calculatedValue; // Fallback for calculations referencing external files. return $this->_calculatedValue; // Fallback for calculations referencing external files.
} }
@ -293,7 +299,7 @@ class PHPExcel_Cell
} }
//echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL; //echo 'Returning calculated value of '.$result.' for cell '.$this->getCoordinate().PHP_EOL;
return $result; return $result;
} elseif($this->_value instanceof PHPExcel_RichText) { } elseif ($this->_value instanceof PHPExcel_RichText) {
// echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'<br />'; // echo 'Cell value for '.$this->getCoordinate().' is rich text: Returning data value of '.$this->_value.'<br />';
return $this->_value->getPlainText(); return $this->_value->getPlainText();
} }
@ -307,9 +313,9 @@ class PHPExcel_Cell
* @param mixed $pValue Value * @param mixed $pValue Value
* @return PHPExcel_Cell * @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; $this->_calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue;
} }
@ -349,9 +355,9 @@ class PHPExcel_Cell
*/ */
public function setDataType($pDataType = PHPExcel_Cell_DataType::TYPE_STRING) 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; $pDataType = PHPExcel_Cell_DataType::TYPE_STRING;
}
$this->_dataType = $pDataType; $this->_dataType = $pDataType;
return $this->notifyCacheController(); return $this->notifyCacheController();
@ -404,7 +410,7 @@ class PHPExcel_Cell
* @return PHPExcel_Cell * @return PHPExcel_Cell
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = NULL) public function setDataValidation(PHPExcel_Cell_DataValidation $pDataValidation = null)
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet'); throw new PHPExcel_Exception('Cannot set data validation for cell that is not bound to a worksheet');
@ -452,7 +458,7 @@ class PHPExcel_Cell
* @return PHPExcel_Cell * @return PHPExcel_Cell
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = NULL) public function setHyperlink(PHPExcel_Cell_Hyperlink $pHyperlink = null)
{ {
if (!isset($this->_parent)) { if (!isset($this->_parent)) {
throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); throw new PHPExcel_Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
@ -468,7 +474,8 @@ class PHPExcel_Cell
* *
* @return PHPExcel_CachedObjectStorage_CacheBase * @return PHPExcel_CachedObjectStorage_CacheBase
*/ */
public function getParent() { public function getParent()
{
return $this->_parent; return $this->_parent;
} }
@ -477,7 +484,8 @@ class PHPExcel_Cell
* *
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function getWorksheet() { public function getWorksheet()
{
return $this->_parent->getParent(); return $this->_parent->getParent();
} }
@ -486,7 +494,8 @@ class PHPExcel_Cell
* *
* @return boolean * @return boolean
*/ */
public function isInMergeRange() { public function isInMergeRange()
{
return (boolean) $this->getMergeRange(); return (boolean) $this->getMergeRange();
} }
@ -495,7 +504,8 @@ class PHPExcel_Cell
* *
* @return boolean * @return boolean
*/ */
public function isMergeRangeValueCell() { public function isMergeRangeValueCell()
{
if ($mergeRange = $this->getMergeRange()) { if ($mergeRange = $this->getMergeRange()) {
$mergeRange = PHPExcel_Cell::splitRange($mergeRange); $mergeRange = PHPExcel_Cell::splitRange($mergeRange);
list($startCell) = $mergeRange[0]; list($startCell) = $mergeRange[0];
@ -511,8 +521,9 @@ class PHPExcel_Cell
* *
* @return string * @return string
*/ */
public function getMergeRange() { public function getMergeRange()
foreach($this->getWorksheet()->getMergeCells() as $mergeRange) { {
foreach ($this->getWorksheet()->getMergeCells() as $mergeRange) {
if ($this->isInRange($mergeRange)) { if ($this->isInRange($mergeRange)) {
return $mergeRange; return $mergeRange;
} }
@ -536,7 +547,8 @@ class PHPExcel_Cell
* @param PHPExcel_Worksheet $parent * @param PHPExcel_Worksheet $parent
* @return PHPExcel_Cell * @return PHPExcel_Cell
*/ */
public function rebindParent(PHPExcel_Worksheet $parent) { public function rebindParent(PHPExcel_Worksheet $parent)
{
$this->_parent = $parent->getCellCacheController(); $this->_parent = $parent->getCellCacheController();
return $this->notifyCacheController(); return $this->notifyCacheController();
@ -550,11 +562,11 @@ class PHPExcel_Cell
*/ */
public function isInRange($pRange = 'A1:A1') public function isInRange($pRange = 'A1:A1')
{ {
list($rangeStart,$rangeEnd) = self::rangeBoundaries($pRange); list($rangeStart, $rangeEnd) = self::rangeBoundaries($pRange);
// Translate properties // Translate properties
$myColumn = self::columnIndexFromString($this->getColumn()); $myColumn = self::columnIndexFromString($this->getColumn());
$myRow = $this->getRow(); $myRow = $this->getRow();
// Verify if cell is in range // Verify if cell is in range
return (($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) && 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)) { if (preg_match("/^([$]?[A-Z]{1,3})([$]?\d{1,7})$/", $pCoordinateString, $matches)) {
return array($matches[1],$matches[2]); 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'); throw new PHPExcel_Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') { } elseif ($pCoordinateString == '') {
throw new PHPExcel_Exception('Cell coordinate can not be zero-length string'); 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') 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 // Split out any worksheet name from the reference
$worksheet = ''; $worksheet = '';
$cellAddress = explode('!',$pCoordinateString); $cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) { if (count($cellAddress) > 1) {
list($worksheet,$pCoordinateString) = $cellAddress; list($worksheet, $pCoordinateString) = $cellAddress;
}
if ($worksheet > '') {
$worksheet .= '!';
} }
if ($worksheet > '') $worksheet .= '!';
// Create absolute coordinate // Create absolute coordinate
if (ctype_digit($pCoordinateString)) { if (ctype_digit($pCoordinateString)) {
@ -622,19 +636,21 @@ class PHPExcel_Cell
*/ */
public static function absoluteCoordinate($pCoordinateString = 'A1') 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 // Split out any worksheet name from the coordinate
$worksheet = ''; $worksheet = '';
$cellAddress = explode('!',$pCoordinateString); $cellAddress = explode('!', $pCoordinateString);
if (count($cellAddress) > 1) { if (count($cellAddress) > 1) {
list($worksheet,$pCoordinateString) = $cellAddress; list($worksheet, $pCoordinateString) = $cellAddress;
}
if ($worksheet > '') {
$worksheet .= '!';
} }
if ($worksheet > '') $worksheet .= '!';
// Create absolute coordinate // Create absolute coordinate
list($column, $row) = self::coordinateFromString($pCoordinateString); list($column, $row) = self::coordinateFromString($pCoordinateString);
$column = ltrim($column,'$'); $column = ltrim($column, '$');
$row = ltrim($row,'$'); $row = ltrim($row, '$');
return $worksheet . '$' . $column . '$' . $row; return $worksheet . '$' . $column . '$' . $row;
} }
@ -652,7 +668,7 @@ class PHPExcel_Cell
public static function splitRange($pRange = 'A1:A1') public static function splitRange($pRange = 'A1:A1')
{ {
// Ensure $pRange is a valid range // Ensure $pRange is a valid range
if(empty($pRange)) { if (empty($pRange)) {
$pRange = self::DEFAULT_RANGE; $pRange = self::DEFAULT_RANGE;
} }
@ -699,7 +715,7 @@ class PHPExcel_Cell
public static function rangeBoundaries($pRange = 'A1:A1') public static function rangeBoundaries($pRange = 'A1:A1')
{ {
// Ensure $pRange is a valid range // Ensure $pRange is a valid range
if(empty($pRange)) { if (empty($pRange)) {
$pRange = self::DEFAULT_RANGE; $pRange = self::DEFAULT_RANGE;
} }
@ -707,7 +723,7 @@ class PHPExcel_Cell
$pRange = strtoupper($pRange); $pRange = strtoupper($pRange);
// Extract range // Extract range
if (strpos($pRange, ':') === FALSE) { if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange; $rangeA = $rangeB = $pRange;
} else { } else {
list($rangeA, $rangeB) = explode(':', $pRange); list($rangeA, $rangeB) = explode(':', $pRange);
@ -733,7 +749,7 @@ class PHPExcel_Cell
public static function rangeDimension($pRange = 'A1:A1') public static function rangeDimension($pRange = 'A1:A1')
{ {
// Calculate range outer borders // 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) ); 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') public static function getRangeBoundaries($pRange = 'A1:A1')
{ {
// Ensure $pRange is a valid range // Ensure $pRange is a valid range
if(empty($pRange)) { if (empty($pRange)) {
$pRange = self::DEFAULT_RANGE; $pRange = self::DEFAULT_RANGE;
} }
@ -756,7 +772,7 @@ class PHPExcel_Cell
$pRange = strtoupper($pRange); $pRange = strtoupper($pRange);
// Extract range // Extract range
if (strpos($pRange, ':') === FALSE) { if (strpos($pRange, ':') === false) {
$rangeA = $rangeB = $pRange; $rangeA = $rangeB = $pRange;
} else { } else {
list($rangeA, $rangeB) = explode(':', $pRange); list($rangeA, $rangeB) = explode(':', $pRange);
@ -778,9 +794,9 @@ class PHPExcel_Cell
// though it's additional memory overhead // though it's additional memory overhead
static $_indexCache = array(); static $_indexCache = array();
if (isset($_indexCache[$pString])) if (isset($_indexCache[$pString])) {
return $_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() // 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 // 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 // memory overhead either
@ -797,10 +813,10 @@ class PHPExcel_Cell
if (!isset($pString{1})) { if (!isset($pString{1})) {
$_indexCache[$pString] = $_columnLookup[$pString]; $_indexCache[$pString] = $_columnLookup[$pString];
return $_indexCache[$pString]; return $_indexCache[$pString];
} elseif(!isset($pString{2})) { } elseif (!isset($pString{2})) {
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}]; $_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
return $_indexCache[$pString]; return $_indexCache[$pString];
} elseif(!isset($pString{3})) { } elseif (!isset($pString{3})) {
$_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}]; $_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
return $_indexCache[$pString]; 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) * @param string $pRange Range (e.g. A1 or A1:C10 or A1:E10 A20:E25)
* @return array Array containing single cell references * @return array Array containing single cell references
*/ */
public static function extractAllCellReferencesInRange($pRange = 'A1') { public static function extractAllCellReferencesInRange($pRange = 'A1')
{
// Returnvalue // Returnvalue
$returnValue = array(); $returnValue = array();
@ -851,14 +868,14 @@ class PHPExcel_Cell
$cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange))); $cellBlocks = explode(' ', str_replace('$', '', strtoupper($pRange)));
foreach ($cellBlocks as $cellBlock) { foreach ($cellBlocks as $cellBlock) {
// Single cell? // Single cell?
if (strpos($cellBlock,':') === FALSE && strpos($cellBlock,',') === FALSE) { if (strpos($cellBlock,':') === false && strpos($cellBlock,',') === false) {
$returnValue[] = $cellBlock; $returnValue[] = $cellBlock;
continue; continue;
} }
// Range... // Range...
$ranges = self::splitRange($cellBlock); $ranges = self::splitRange($cellBlock);
foreach($ranges as $range) { foreach ($ranges as $range) {
// Single cell? // Single cell?
if (!isset($range[1])) { if (!isset($range[1])) {
$returnValue[] = $range[0]; $returnValue[] = $range[0];
@ -867,13 +884,13 @@ class PHPExcel_Cell
// Range... // Range...
list($rangeStart, $rangeEnd) = $range; list($rangeStart, $rangeEnd) = $range;
sscanf($rangeStart,'%[A-Z]%d', $startCol, $startRow); sscanf($rangeStart, '%[A-Z]%d', $startCol, $startRow);
sscanf($rangeEnd,'%[A-Z]%d', $endCol, $endRow); sscanf($rangeEnd, '%[A-Z]%d', $endCol, $endRow);
$endCol++; ++$endCol;
// Current data // Current data
$currentCol = $startCol; $currentCol = $startCol;
$currentRow = $startRow; $currentRow = $startRow;
// Loop cells // Loop cells
while ($currentCol != $endCol) { while ($currentCol != $endCol) {
@ -890,8 +907,8 @@ class PHPExcel_Cell
// Sort the result by column and row // Sort the result by column and row
$sortKeys = array(); $sortKeys = array();
foreach (array_unique($returnValue) as $coord) { foreach (array_unique($returnValue) as $coord) {
sscanf($coord,'%[A-Z]%d', $column, $row); sscanf($coord, '%[A-Z]%d', $column, $row);
$sortKeys[sprintf('%3s%09d',$column,$row)] = $coord; $sortKeys[sprintf('%3s%09d', $column, $row)] = $coord;
} }
ksort($sortKeys); ksort($sortKeys);
@ -924,8 +941,9 @@ class PHPExcel_Cell
* *
* @return PHPExcel_Cell_IValueBinder * @return PHPExcel_Cell_IValueBinder
*/ */
public static function getValueBinder() { public static function getValueBinder()
if (self::$_valueBinder === NULL) { {
if (self::$_valueBinder === null) {
self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder(); self::$_valueBinder = new PHPExcel_Cell_DefaultValueBinder();
} }
@ -938,8 +956,9 @@ class PHPExcel_Cell
* @param PHPExcel_Cell_IValueBinder $binder * @param PHPExcel_Cell_IValueBinder $binder
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = NULL) { public static function setValueBinder(PHPExcel_Cell_IValueBinder $binder = null)
if ($binder === NULL) { {
if ($binder === null) {
throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly."); throw new PHPExcel_Exception("A PHPExcel_Cell_IValueBinder is required for PHPExcel to function correctly.");
} }
@ -949,7 +968,8 @@ class PHPExcel_Cell
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if ((is_object($value)) && ($key != '_parent')) { if ((is_object($value)) && ($key != '_parent')) {
@ -1009,6 +1029,4 @@ class PHPExcel_Cell
{ {
return (string) $this->getValue(); return (string) $this->getValue();
} }
} }

View File

@ -59,7 +59,7 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if ($value == PHPExcel_Calculation::getTRUE()) { if ($value == PHPExcel_Calculation::getTRUE()) {
$cell->setValueExplicit(true, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit(true, PHPExcel_Cell_DataType::TYPE_BOOL);
return true; return true;
} elseif($value == PHPExcel_Calculation::getFALSE()) { } elseif ($value == PHPExcel_Calculation::getFALSE()) {
$cell->setValueExplicit(false, PHPExcel_Cell_DataType::TYPE_BOOL); $cell->setValueExplicit(false, PHPExcel_Cell_DataType::TYPE_BOOL);
return true; 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)) { if (preg_match('/^([+-]?)\s*([0-9]+)\s?\/\s*([0-9]+)$/', $value, $matches)) {
// Convert value to number // Convert value to number
$value = $matches[2] / $matches[3]; $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); $cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode( '??/??' ); ->getNumberFormat()->setFormatCode('??/??');
return true; return true;
} elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) { } elseif (preg_match('/^([+-]?)([0-9]*) +([0-9]*)\s?\/\s*([0-9]*)$/', $value, $matches)) {
// Convert value to number // Convert value to number
$value = $matches[2] + ($matches[3] / $matches[4]); $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); $cell->setValueExplicit((float) $value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode( '# ??/??' ); ->getNumberFormat()->setFormatCode('# ??/??');
return true; return true;
} }
@ -95,9 +99,9 @@ class PHPExcel_Cell_AdvancedValueBinder extends PHPExcel_Cell_DefaultValueBinder
if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) { if (preg_match('/^\-?[0-9]*\.?[0-9]*\s?\%$/', $value)) {
// Convert value to number // Convert value to number
$value = (float) str_replace('%', '', $value) / 100; $value = (float) str_replace('%', '', $value) / 100;
$cell->setValueExplicit( $value, PHPExcel_Cell_DataType::TYPE_NUMERIC); $cell->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_NUMERIC);
// Set style // Set style
$cell->getWorksheet()->getStyle( $cell->getCoordinate() ) $cell->getWorksheet()->getStyle($cell->getCoordinate())
->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00); ->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_PERCENTAGE_00);
return true; return true;
} }

View File

@ -112,5 +112,4 @@ class PHPExcel_Cell_DataType
return $pValue; return $pValue;
} }
} }

View File

@ -57,91 +57,91 @@ class PHPExcel_Cell_DataValidation
* *
* @var string * @var string
*/ */
private $_formula1; private $formula1;
/** /**
* Formula 2 * Formula 2
* *
* @var string * @var string
*/ */
private $_formula2; private $formula2;
/** /**
* Type * Type
* *
* @var string * @var string
*/ */
private $_type = PHPExcel_Cell_DataValidation::TYPE_NONE; private $type = PHPExcel_Cell_DataValidation::TYPE_NONE;
/** /**
* Error style * Error style
* *
* @var string * @var string
*/ */
private $_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; private $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
/** /**
* Operator * Operator
* *
* @var string * @var string
*/ */
private $_operator; private $operator;
/** /**
* Allow Blank * Allow Blank
* *
* @var boolean * @var boolean
*/ */
private $_allowBlank; private $allowBlank;
/** /**
* Show DropDown * Show DropDown
* *
* @var boolean * @var boolean
*/ */
private $_showDropDown; private $showDropDown;
/** /**
* Show InputMessage * Show InputMessage
* *
* @var boolean * @var boolean
*/ */
private $_showInputMessage; private $showInputMessage;
/** /**
* Show ErrorMessage * Show ErrorMessage
* *
* @var boolean * @var boolean
*/ */
private $_showErrorMessage; private $showErrorMessage;
/** /**
* Error title * Error title
* *
* @var string * @var string
*/ */
private $_errorTitle; private $errorTitle;
/** /**
* Error * Error
* *
* @var string * @var string
*/ */
private $_error; private $error;
/** /**
* Prompt title * Prompt title
* *
* @var string * @var string
*/ */
private $_promptTitle; private $promptTitle;
/** /**
* Prompt * Prompt
* *
* @var string * @var string
*/ */
private $_prompt; private $prompt;
/** /**
* Create a new PHPExcel_Cell_DataValidation * Create a new PHPExcel_Cell_DataValidation
@ -149,19 +149,19 @@ class PHPExcel_Cell_DataValidation
public function __construct() public function __construct()
{ {
// Initialise member variables // Initialise member variables
$this->_formula1 = ''; $this->formula1 = '';
$this->_formula2 = ''; $this->formula2 = '';
$this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE; $this->type = PHPExcel_Cell_DataValidation::TYPE_NONE;
$this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP; $this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
$this->_operator = ''; $this->operator = '';
$this->_allowBlank = FALSE; $this->allowBlank = false;
$this->_showDropDown = FALSE; $this->showDropDown = false;
$this->_showInputMessage = FALSE; $this->showInputMessage = false;
$this->_showErrorMessage = FALSE; $this->showErrorMessage = false;
$this->_errorTitle = ''; $this->errorTitle = '';
$this->_error = ''; $this->error = '';
$this->_promptTitle = ''; $this->promptTitle = '';
$this->_prompt = ''; $this->prompt = '';
} }
/** /**
@ -169,8 +169,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getFormula1() { public function getFormula1()
return $this->_formula1; {
return $this->formula1;
} }
/** /**
@ -179,8 +180,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setFormula1($value = '') { public function setFormula1($value = '')
$this->_formula1 = $value; {
$this->formula1 = $value;
return $this; return $this;
} }
@ -190,7 +192,7 @@ class PHPExcel_Cell_DataValidation
* @return string * @return string
*/ */
public function getFormula2() { public function getFormula2() {
return $this->_formula2; return $this->formula2;
} }
/** /**
@ -199,8 +201,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setFormula2($value = '') { public function setFormula2($value = '')
$this->_formula2 = $value; {
$this->formula2 = $value;
return $this; return $this;
} }
@ -209,8 +212,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getType() { public function getType()
return $this->_type; {
return $this->type;
} }
/** /**
@ -219,8 +223,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE) { public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE)
$this->_type = $value; {
$this->type = $value;
return $this; return $this;
} }
@ -229,8 +234,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getErrorStyle() { public function getErrorStyle()
return $this->_errorStyle; {
return $this->errorStyle;
} }
/** /**
@ -239,8 +245,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP) { public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP)
$this->_errorStyle = $value; {
$this->errorStyle = $value;
return $this; return $this;
} }
@ -249,8 +256,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getOperator() { public function getOperator()
return $this->_operator; {
return $this->operator;
} }
/** /**
@ -259,8 +267,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setOperator($value = '') { public function setOperator($value = '')
$this->_operator = $value; {
$this->operator = $value;
return $this; return $this;
} }
@ -269,8 +278,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return boolean * @return boolean
*/ */
public function getAllowBlank() { public function getAllowBlank()
return $this->_allowBlank; {
return $this->allowBlank;
} }
/** /**
@ -279,8 +289,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setAllowBlank($value = false) { public function setAllowBlank($value = false)
$this->_allowBlank = $value; {
$this->allowBlank = $value;
return $this; return $this;
} }
@ -289,8 +300,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return boolean * @return boolean
*/ */
public function getShowDropDown() { public function getShowDropDown()
return $this->_showDropDown; {
return $this->showDropDown;
} }
/** /**
@ -299,8 +311,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setShowDropDown($value = false) { public function setShowDropDown($value = false)
$this->_showDropDown = $value; {
$this->showDropDown = $value;
return $this; return $this;
} }
@ -309,8 +322,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return boolean * @return boolean
*/ */
public function getShowInputMessage() { public function getShowInputMessage()
return $this->_showInputMessage; {
return $this->showInputMessage;
} }
/** /**
@ -319,8 +333,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setShowInputMessage($value = false) { public function setShowInputMessage($value = false)
$this->_showInputMessage = $value; {
$this->showInputMessage = $value;
return $this; return $this;
} }
@ -329,8 +344,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return boolean * @return boolean
*/ */
public function getShowErrorMessage() { public function getShowErrorMessage()
return $this->_showErrorMessage; {
return $this->showErrorMessage;
} }
/** /**
@ -339,8 +355,9 @@ class PHPExcel_Cell_DataValidation
* @param boolean $value * @param boolean $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setShowErrorMessage($value = false) { public function setShowErrorMessage($value = false)
$this->_showErrorMessage = $value; {
$this->showErrorMessage = $value;
return $this; return $this;
} }
@ -349,8 +366,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getErrorTitle() { public function getErrorTitle()
return $this->_errorTitle; {
return $this->errorTitle;
} }
/** /**
@ -359,8 +377,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setErrorTitle($value = '') { public function setErrorTitle($value = '')
$this->_errorTitle = $value; {
$this->errorTitle = $value;
return $this; return $this;
} }
@ -369,8 +388,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getError() { public function getError()
return $this->_error; {
return $this->error;
} }
/** /**
@ -379,8 +399,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setError($value = '') { public function setError($value = '')
$this->_error = $value; {
$this->error = $value;
return $this; return $this;
} }
@ -389,8 +410,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getPromptTitle() { public function getPromptTitle()
return $this->_promptTitle; {
return $this->promptTitle;
} }
/** /**
@ -399,8 +421,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setPromptTitle($value = '') { public function setPromptTitle($value = '')
$this->_promptTitle = $value; {
$this->promptTitle = $value;
return $this; return $this;
} }
@ -409,8 +432,9 @@ class PHPExcel_Cell_DataValidation
* *
* @return string * @return string
*/ */
public function getPrompt() { public function getPrompt()
return $this->_prompt; {
return $this->prompt;
} }
/** /**
@ -419,8 +443,9 @@ class PHPExcel_Cell_DataValidation
* @param string $value * @param string $value
* @return PHPExcel_Cell_DataValidation * @return PHPExcel_Cell_DataValidation
*/ */
public function setPrompt($value = '') { public function setPrompt($value = '')
$this->_prompt = $value; {
$this->prompt = $value;
return $this; return $this;
} }
@ -429,29 +454,31 @@ class PHPExcel_Cell_DataValidation
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
return md5( return md5(
$this->_formula1 $this->formula1 .
. $this->_formula2 $this->formula2 .
. $this->_type = PHPExcel_Cell_DataValidation::TYPE_NONE $this->type = PHPExcel_Cell_DataValidation::TYPE_NONE .
. $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP $this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP .
. $this->_operator $this->operator .
. ($this->_allowBlank ? 't' : 'f') ($this->allowBlank ? 't' : 'f') .
. ($this->_showDropDown ? 't' : 'f') ($this->showDropDown ? 't' : 'f') .
. ($this->_showInputMessage ? 't' : 'f') ($this->showInputMessage ? 't' : 'f') .
. ($this->_showErrorMessage ? 't' : 'f') ($this->showErrorMessage ? 't' : 'f') .
. $this->_errorTitle $this->errorTitle .
. $this->_error $this->error .
. $this->_promptTitle $this->promptTitle .
. $this->_prompt $this->prompt .
. __CLASS__ __CLASS__
); );
} }
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
$vars = get_object_vars($this); $vars = get_object_vars($this);
foreach ($vars as $key => $value) { foreach ($vars as $key => $value) {
if (is_object($value)) { if (is_object($value)) {

View File

@ -87,9 +87,9 @@ class PHPExcel_Cell_DefaultValueBinder implements PHPExcel_Cell_IValueBinder
return PHPExcel_Cell_DataType::TYPE_NUMERIC; return PHPExcel_Cell_DataType::TYPE_NUMERIC;
} elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) { } elseif (preg_match('/^[\+\-]?([0-9]+\\.?[0-9]*|[0-9]*\\.?[0-9]+)([Ee][\-\+]?[0-2]?\d{1,3})?$/', $pValue)) {
$tValue = ltrim($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; 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_STRING;
} }
return PHPExcel_Cell_DataType::TYPE_NUMERIC; return PHPExcel_Cell_DataType::TYPE_NUMERIC;

View File

@ -7,8 +7,8 @@
* Time: 12:11 PM * Time: 12:11 PM
*/ */
class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties { class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties
{
/** /**
* Axis Number * Axis Number
* *
@ -25,16 +25,16 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* @var array of mixed * @var array of mixed
*/ */
private $_axis_options = array( private $_axis_options = array(
'minimum' => NULL, 'minimum' => null,
'maximum' => NULL, 'maximum' => null,
'major_unit' => NULL, 'major_unit' => null,
'minor_unit' => NULL, 'minor_unit' => null,
'orientation' => self::ORIENTATION_NORMAL, 'orientation' => self::ORIENTATION_NORMAL,
'minor_tick_mark' => self::TICK_MARK_NONE, 'minor_tick_mark' => self::TICK_MARK_NONE,
'major_tick_mark' => self::TICK_MARK_NONE, 'major_tick_mark' => self::TICK_MARK_NONE,
'axis_labels' => self::AXIS_LABELS_NEXT_TO, 'axis_labels' => self::AXIS_LABELS_NEXT_TO,
'horizontal_crosses' => self::HORIZONTAL_CROSSES_AUTOZERO, '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( private $_fill_properties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB, 'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL, 'value' => null,
'alpha' => 0 'alpha' => 0
); );
@ -55,7 +55,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
*/ */
private $_line_properties = array( private $_line_properties = array(
'type' => self::EXCEL_COLOR_TYPE_ARGB, 'type' => self::EXCEL_COLOR_TYPE_ARGB,
'value' => NULL, 'value' => null,
'alpha' => 0 'alpha' => 0
); );
@ -89,22 +89,22 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
*/ */
private $_shadow_properties = array( private $_shadow_properties = array(
'presets' => self::SHADOW_PRESETS_NOSHADOW, 'presets' => self::SHADOW_PRESETS_NOSHADOW,
'effect' => NULL, 'effect' => null,
'color' => array( 'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD, 'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black', 'value' => 'black',
'alpha' => 40, 'alpha' => 40,
), ),
'size' => array( 'size' => array(
'sx' => NULL, 'sx' => null,
'sy' => NULL, 'sy' => null,
'kx' => NULL 'kx' => null
), ),
'blur' => NULL, 'blur' => null,
'direction' => NULL, 'direction' => null,
'distance' => NULL, 'distance' => null,
'algn' => NULL, 'algn' => null,
'rotWithShape' => NULL 'rotWithShape' => null
); );
/** /**
@ -113,7 +113,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* @var array of mixed * @var array of mixed
*/ */
private $_glow_properties = array( private $_glow_properties = array(
'size' => NULL, 'size' => null,
'color' => array( 'color' => array(
'type' => self::EXCEL_COLOR_TYPE_STANDARD, 'type' => self::EXCEL_COLOR_TYPE_STANDARD,
'value' => 'black', 'value' => 'black',
@ -127,7 +127,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* @var array of mixed * @var array of mixed
*/ */
private $_soft_edges = array( private $_soft_edges = array(
'size' => NULL 'size' => null
); );
/** /**
@ -135,7 +135,8 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* *
* @return string * @return string
*/ */
public function setAxisNumberProperties($format_code) { public function setAxisNumberProperties($format_code)
{
$this->_axis_number['format'] = (string) $format_code; $this->_axis_number['format'] = (string) $format_code;
$this->_axis_number['source_linked'] = 0; $this->_axis_number['source_linked'] = 0;
} }
@ -145,7 +146,8 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* *
* @return string * @return string
*/ */
public function getAxisNumberFormat() { public function getAxisNumberFormat()
{
return $this->_axis_number['format']; return $this->_axis_number['format'];
} }
@ -154,7 +156,8 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* *
* @return string * @return string
*/ */
public function getAxisNumberSourceLinked() { public function getAxisNumberSourceLinked()
{
return (string) $this->_axis_number['source_linked']; return (string) $this->_axis_number['source_linked'];
} }
@ -173,22 +176,22 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* @param string $minor_unit * @param string $minor_unit
* *
*/ */
public function setAxisOptionsProperties($axis_labels, $horizontal_crosses_value = NULL, $horizontal_crosses = 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, $axis_orientation = null, $major_tmt = null, $minor_tmt = null, $minimum = null, $maximum = null, $major_unit = null,
$minor_unit = NULL) $minor_unit = null)
{ {
$this->_axis_options['axis_labels'] = (string) $axis_labels; $this->_axis_options['axis_labels'] = (string) $axis_labels;
($horizontal_crosses_value !== NULL) ($horizontal_crosses_value !== null)
? $this->_axis_options['horizontal_crosses_value'] = (string) $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; ($horizontal_crosses !== null) ? $this->_axis_options['horizontal_crosses'] = (string) $horizontal_crosses : null;
($axis_orientation !== NULL) ? $this->_axis_options['orientation'] = (string) $axis_orientation : 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; ($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;
($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; ($minimum !== null) ? $this->_axis_options['minimum'] = (string) $minimum : null;
($maximum !== NULL) ? $this->_axis_options['maximum'] = (string) $maximum : NULL; ($maximum !== null) ? $this->_axis_options['maximum'] = (string) $maximum : null;
($major_unit !== NULL) ? $this->_axis_options['major_unit'] = (string) $major_unit : 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; ($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, public function setLineStyleProperties($line_width = null, $compound_type = null,
$dash_type = NULL, $cap_type = NULL, $join_type = NULL, $head_arrow_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) { $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) (!is_null($line_width)) ? $this->_line_style_properties['width'] = $this->getExcelPointsWidth((float) $line_width)
: NULL; : null;
(!is_null($compound_type)) ? $this->_line_style_properties['compound'] = (string) $compound_type : 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($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($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($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 (!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 (!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 (!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 (!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 $this
->_setShadowPresetsProperties((int) $sh_presets) ->_setShadowPresetsProperties((int) $sh_presets)
->_setShadowColor( ->_setShadowColor(
@ -378,18 +381,18 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* @return PHPExcel_Chart_Axis * @return PHPExcel_Chart_Axis
*/ */
private function _setShadowProperiesMapValues(array $properties_map, &$reference = NULL) { private function _setShadowProperiesMapValues(array $properties_map, &$reference = null) {
$base_reference = $reference; $base_reference = $reference;
foreach ($properties_map as $property_key => $property_val) { foreach ($properties_map as $property_key => $property_val) {
if (is_array($property_val)) { if (is_array($property_val)) {
if ($reference === NULL) { if ($reference === null) {
$reference = & $this->_shadow_properties[$property_key]; $reference = & $this->_shadow_properties[$property_key];
} else { } else {
$reference = & $reference[$property_key]; $reference = & $reference[$property_key];
} }
$this->_setShadowProperiesMapValues($property_val, $reference); $this->_setShadowProperiesMapValues($property_val, $reference);
} else { } else {
if ($base_reference === NULL) { if ($base_reference === null) {
$this->_shadow_properties[$property_key] = $property_val; $this->_shadow_properties[$property_key] = $property_val;
} else { } else {
$reference[$property_key] = $property_val; $reference[$property_key] = $property_val;
@ -425,7 +428,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
*/ */
private function _setShadowBlur($blur) { private function _setShadowBlur($blur) {
if ($blur !== NULL) { if ($blur !== null) {
$this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur); $this->_shadow_properties['blur'] = (string) $this->getExcelPointsWidth($blur);
} }
@ -441,7 +444,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
*/ */
private function _setShadowAngle($angle) { private function _setShadowAngle($angle) {
if ($angle !== NULL) { if ($angle !== null) {
$this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle); $this->_shadow_properties['direction'] = (string) $this->getExcelPointsAngle($angle);
} }
@ -457,7 +460,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
*/ */
private function _setShadowDistance($distance) { private function _setShadowDistance($distance) {
if ($distance !== NULL) { if ($distance !== null) {
$this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance); $this->_shadow_properties['distance'] = (string) $this->getExcelPointsWidth($distance);
} }
@ -486,7 +489,7 @@ class PHPExcel_Chart_Axis extends PHPExcel_Chart_Properties {
* @param string $color_type * @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 $this
->_setGlowSize($size) ->_setGlowSize($size)
->_setGlowColor( ->_setGlowColor(

View File

@ -18,353 +18,352 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** /**
* PHPExcel_Chart_DataSeries * PHPExcel_Chart_DataSeries
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_DataSeries 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 GROUPING_CLUSTERED = 'clustered';
const TYPE_BARCHART_3D = 'bar3DChart'; const GROUPING_STACKED = 'stacked';
const TYPE_LINECHART = 'lineChart'; const GROUPING_PERCENT_STACKED = 'percentStacked';
const TYPE_LINECHART_3D = 'line3DChart'; const GROUPING_STANDARD = 'standard';
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 DIRECTION_BAR = 'bar';
const GROUPING_STACKED = 'stacked'; const DIRECTION_HORIZONTAL = self::DIRECTION_BAR;
const GROUPING_PERCENT_STACKED = 'percentStacked'; const DIRECTION_COL = 'col';
const GROUPING_STANDARD = 'standard'; const DIRECTION_COLUMN = self::DIRECTION_COL;
const DIRECTION_VERTICAL = self::DIRECTION_COL;
const DIRECTION_BAR = 'bar'; const STYLE_LINEMARKER = 'lineMarker';
const DIRECTION_HORIZONTAL = self::DIRECTION_BAR; const STYLE_SMOOTHMARKER = 'smoothMarker';
const DIRECTION_COL = 'col'; const STYLE_MARKER = 'marker';
const DIRECTION_COLUMN = self::DIRECTION_COL; const STYLE_FILLED = 'filled';
const DIRECTION_VERTICAL = self::DIRECTION_COL;
const STYLE_LINEMARKER = 'lineMarker';
const STYLE_SMOOTHMARKER = 'smoothMarker';
const STYLE_MARKER = 'marker';
const STYLE_FILLED = 'filled';
/** /**
* Series Plot Type * Series Plot Type
* *
* @var string * @var string
*/ */
private $_plotType = null; private $_plotType = null;
/** /**
* Plot Grouping Type * Plot Grouping Type
* *
* @var boolean * @var boolean
*/ */
private $_plotGrouping = null; private $_plotGrouping = null;
/** /**
* Plot Direction * Plot Direction
* *
* @var boolean * @var boolean
*/ */
private $_plotDirection = null; private $_plotDirection = null;
/** /**
* Plot Style * Plot Style
* *
* @var string * @var string
*/ */
private $_plotStyle = null; private $_plotStyle = null;
/** /**
* Order of plots in Series * Order of plots in Series
* *
* @var array of integer * @var array of integer
*/ */
private $_plotOrder = array(); private $_plotOrder = array();
/** /**
* Plot Label * Plot Label
* *
* @var array of PHPExcel_Chart_DataSeriesValues * @var array of PHPExcel_Chart_DataSeriesValues
*/ */
private $_plotLabel = array(); private $_plotLabel = array();
/** /**
* Plot Category * Plot Category
* *
* @var array of PHPExcel_Chart_DataSeriesValues * @var array of PHPExcel_Chart_DataSeriesValues
*/ */
private $_plotCategory = array(); private $_plotCategory = array();
/** /**
* Smooth Line * Smooth Line
* *
* @var string * @var string
*/ */
private $_smoothLine = null; private $_smoothLine = null;
/** /**
* Plot Values * Plot Values
* *
* @var array of PHPExcel_Chart_DataSeriesValues * @var array of PHPExcel_Chart_DataSeriesValues
*/ */
private $_plotValues = array(); private $_plotValues = array();
/** /**
* Create a new PHPExcel_Chart_DataSeries * 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) 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->_plotType = $plotType;
$this->_plotGrouping = $plotGrouping; $this->_plotGrouping = $plotGrouping;
$this->_plotOrder = $plotOrder; $this->_plotOrder = $plotOrder;
$keys = array_keys($plotValues); $keys = array_keys($plotValues);
$this->_plotValues = $plotValues; $this->_plotValues = $plotValues;
if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) { if ((count($plotLabel) == 0) || (is_null($plotLabel[$keys[0]]))) {
$plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); $plotLabel[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
} }
$this->_plotLabel = $plotLabel; $this->_plotLabel = $plotLabel;
if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) { if ((count($plotCategory) == 0) || (is_null($plotCategory[$keys[0]]))) {
$plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues(); $plotCategory[$keys[0]] = new PHPExcel_Chart_DataSeriesValues();
} }
$this->_plotCategory = $plotCategory; $this->_plotCategory = $plotCategory;
$this->_smoothLine = $smoothLine; $this->_smoothLine = $smoothLine;
$this->_plotStyle = $plotStyle; $this->_plotStyle = $plotStyle;
if (is_null($plotDirection)) { if (is_null($plotDirection)) {
$plotDirection = self::DIRECTION_COL; $plotDirection = self::DIRECTION_COL;
} }
$this->_plotDirection = $plotDirection; $this->_plotDirection = $plotDirection;
} }
/** /**
* Get Plot Type * Get Plot Type
* *
* @return string * @return string
*/ */
public function getPlotType() { public function getPlotType() {
return $this->_plotType; return $this->_plotType;
} }
/** /**
* Set Plot Type * Set Plot Type
* *
* @param string $plotType * @param string $plotType
* @return PHPExcel_Chart_DataSeries * @return PHPExcel_Chart_DataSeries
*/ */
public function setPlotType($plotType = '') { public function setPlotType($plotType = '') {
$this->_plotType = $plotType; $this->_plotType = $plotType;
return $this; return $this;
} }
/** /**
* Get Plot Grouping Type * Get Plot Grouping Type
* *
* @return string * @return string
*/ */
public function getPlotGrouping() { public function getPlotGrouping() {
return $this->_plotGrouping; return $this->_plotGrouping;
} }
/** /**
* Set Plot Grouping Type * Set Plot Grouping Type
* *
* @param string $groupingType * @param string $groupingType
* @return PHPExcel_Chart_DataSeries * @return PHPExcel_Chart_DataSeries
*/ */
public function setPlotGrouping($groupingType = null) { public function setPlotGrouping($groupingType = null) {
$this->_plotGrouping = $groupingType; $this->_plotGrouping = $groupingType;
return $this; return $this;
} }
/** /**
* Get Plot Direction * Get Plot Direction
* *
* @return string * @return string
*/ */
public function getPlotDirection() { public function getPlotDirection() {
return $this->_plotDirection; return $this->_plotDirection;
} }
/** /**
* Set Plot Direction * Set Plot Direction
* *
* @param string $plotDirection * @param string $plotDirection
* @return PHPExcel_Chart_DataSeries * @return PHPExcel_Chart_DataSeries
*/ */
public function setPlotDirection($plotDirection = null) { public function setPlotDirection($plotDirection = null) {
$this->_plotDirection = $plotDirection; $this->_plotDirection = $plotDirection;
return $this; return $this;
} }
/** /**
* Get Plot Order * Get Plot Order
* *
* @return string * @return string
*/ */
public function getPlotOrder() { public function getPlotOrder() {
return $this->_plotOrder; return $this->_plotOrder;
} }
/** /**
* Get Plot Labels * Get Plot Labels
* *
* @return array of PHPExcel_Chart_DataSeriesValues * @return array of PHPExcel_Chart_DataSeriesValues
*/ */
public function getPlotLabels() { public function getPlotLabels() {
return $this->_plotLabel; return $this->_plotLabel;
} }
/** /**
* Get Plot Label by Index * Get Plot Label by Index
* *
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function getPlotLabelByIndex($index) { public function getPlotLabelByIndex($index) {
$keys = array_keys($this->_plotLabel); $keys = array_keys($this->_plotLabel);
if (in_array($index,$keys)) { if (in_array($index,$keys)) {
return $this->_plotLabel[$index]; return $this->_plotLabel[$index];
} elseif(isset($keys[$index])) { } elseif(isset($keys[$index])) {
return $this->_plotLabel[$keys[$index]]; return $this->_plotLabel[$keys[$index]];
} }
return false; return false;
} }
/** /**
* Get Plot Categories * Get Plot Categories
* *
* @return array of PHPExcel_Chart_DataSeriesValues * @return array of PHPExcel_Chart_DataSeriesValues
*/ */
public function getPlotCategories() { public function getPlotCategories() {
return $this->_plotCategory; return $this->_plotCategory;
} }
/** /**
* Get Plot Category by Index * Get Plot Category by Index
* *
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function getPlotCategoryByIndex($index) { public function getPlotCategoryByIndex($index) {
$keys = array_keys($this->_plotCategory); $keys = array_keys($this->_plotCategory);
if (in_array($index,$keys)) { if (in_array($index,$keys)) {
return $this->_plotCategory[$index]; return $this->_plotCategory[$index];
} elseif(isset($keys[$index])) { } elseif(isset($keys[$index])) {
return $this->_plotCategory[$keys[$index]]; return $this->_plotCategory[$keys[$index]];
} }
return false; return false;
} }
/** /**
* Get Plot Style * Get Plot Style
* *
* @return string * @return string
*/ */
public function getPlotStyle() { public function getPlotStyle() {
return $this->_plotStyle; return $this->_plotStyle;
} }
/** /**
* Set Plot Style * Set Plot Style
* *
* @param string $plotStyle * @param string $plotStyle
* @return PHPExcel_Chart_DataSeries * @return PHPExcel_Chart_DataSeries
*/ */
public function setPlotStyle($plotStyle = null) { public function setPlotStyle($plotStyle = null) {
$this->_plotStyle = $plotStyle; $this->_plotStyle = $plotStyle;
return $this; return $this;
} }
/** /**
* Get Plot Values * Get Plot Values
* *
* @return array of PHPExcel_Chart_DataSeriesValues * @return array of PHPExcel_Chart_DataSeriesValues
*/ */
public function getPlotValues() { public function getPlotValues() {
return $this->_plotValues; return $this->_plotValues;
} }
/** /**
* Get Plot Values by Index * Get Plot Values by Index
* *
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function getPlotValuesByIndex($index) { public function getPlotValuesByIndex($index) {
$keys = array_keys($this->_plotValues); $keys = array_keys($this->_plotValues);
if (in_array($index,$keys)) { if (in_array($index,$keys)) {
return $this->_plotValues[$index]; return $this->_plotValues[$index];
} elseif(isset($keys[$index])) { } elseif(isset($keys[$index])) {
return $this->_plotValues[$keys[$index]]; return $this->_plotValues[$keys[$index]];
} }
return false; return false;
} }
/** /**
* Get Number of Plot Series * Get Number of Plot Series
* *
* @return integer * @return integer
*/ */
public function getPlotSeriesCount() { public function getPlotSeriesCount() {
return count($this->_plotValues); return count($this->_plotValues);
} }
/** /**
* Get Smooth Line * Get Smooth Line
* *
* @return boolean * @return boolean
*/ */
public function getSmoothLine() { public function getSmoothLine() {
return $this->_smoothLine; return $this->_smoothLine;
} }
/** /**
* Set Smooth Line * Set Smooth Line
* *
* @param boolean $smoothLine * @param boolean $smoothLine
* @return PHPExcel_Chart_DataSeries * @return PHPExcel_Chart_DataSeries
*/ */
public function setSmoothLine($smoothLine = TRUE) { public function setSmoothLine($smoothLine = TRUE) {
$this->_smoothLine = $smoothLine; $this->_smoothLine = $smoothLine;
return $this; return $this;
} }
public function refresh(PHPExcel_Worksheet $worksheet) { public function refresh(PHPExcel_Worksheet $worksheet) {
foreach($this->_plotValues as $plotValues) { foreach($this->_plotValues as $plotValues) {
if ($plotValues !== NULL) if ($plotValues !== NULL)
$plotValues->refresh($worksheet, TRUE); $plotValues->refresh($worksheet, TRUE);
} }
foreach($this->_plotLabel as $plotValues) { foreach($this->_plotLabel as $plotValues) {
if ($plotValues !== NULL) if ($plotValues !== NULL)
$plotValues->refresh($worksheet, TRUE); $plotValues->refresh($worksheet, TRUE);
} }
foreach($this->_plotCategory as $plotValues) { foreach($this->_plotCategory as $plotValues) {
if ($plotValues !== NULL) if ($plotValues !== NULL)
$plotValues->refresh($worksheet, FALSE); $plotValues->refresh($worksheet, FALSE);
} }
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Chart_DataSeriesValues
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -18,310 +19,301 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_DataSeriesValues
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_DataSeriesValues class PHPExcel_Chart_DataSeriesValues
{ {
const DATASERIES_TYPE_STRING = 'String'; const DATASERIES_TYPE_STRING = 'String';
const DATASERIES_TYPE_NUMBER = 'Number'; const DATASERIES_TYPE_NUMBER = 'Number';
private static $_dataTypeValues = array( private static $_dataTypeValues = array(
self::DATASERIES_TYPE_STRING, self::DATASERIES_TYPE_STRING,
self::DATASERIES_TYPE_NUMBER, self::DATASERIES_TYPE_NUMBER,
); );
/** /**
* Series Data Type * Series Data Type
* *
* @var string * @var string
*/ */
private $_dataType = null; private $_dataType = null;
/** /**
* Series Data Source * Series Data Source
* *
* @var string * @var string
*/ */
private $_dataSource = null; private $_dataSource = null;
/** /**
* Format Code * Format Code
* *
* @var string * @var string
*/ */
private $_formatCode = null; private $_formatCode = null;
/** /**
* Series Point Marker * Series Point Marker
* *
* @var string * @var string
*/ */
private $_marker = null; private $_marker = null;
/** /**
* Point Count (The number of datapoints in the dataseries) * Point Count (The number of datapoints in the dataseries)
* *
* @var integer * @var integer
*/ */
private $_pointCount = 0; private $_pointCount = 0;
/** /**
* Data Values * Data Values
* *
* @var array of mixed * @var array of mixed
*/ */
private $_dataValues = array(); private $_dataValues = array();
/** /**
* Create a new PHPExcel_Chart_DataSeriesValues object * 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) public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null)
{ {
$this->setDataType($dataType); $this->setDataType($dataType);
$this->_dataSource = $dataSource; $this->_dataSource = $dataSource;
$this->_formatCode = $formatCode; $this->_formatCode = $formatCode;
$this->_pointCount = $pointCount; $this->_pointCount = $pointCount;
$this->_dataValues = $dataValues; $this->_dataValues = $dataValues;
$this->_marker = $marker; $this->_marker = $marker;
} }
/** /**
* Get Series Data Type * Get Series Data Type
* *
* @return string * @return string
*/ */
public function getDataType() { public function getDataType() {
return $this->_dataType; return $this->_dataType;
} }
/** /**
* Set Series Data Type * Set Series Data Type
* *
* @param string $dataType Datatype of this data series * @param string $dataType Datatype of this data series
* Typical values are: * Typical values are:
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_STRING
* Normally used for axis point values * Normally used for axis point values
* PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER * PHPExcel_Chart_DataSeriesValues::DATASERIES_TYPE_NUMBER
* Normally used for chart data values * Normally used for chart data values
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) { public function setDataType($dataType = self::DATASERIES_TYPE_NUMBER) {
if (!in_array($dataType, self::$_dataTypeValues)) { if (!in_array($dataType, self::$_dataTypeValues)) {
throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values'); throw new PHPExcel_Chart_Exception('Invalid datatype for chart data series values');
} }
$this->_dataType = $dataType; $this->_dataType = $dataType;
return $this; return $this;
} }
/** /**
* Get Series Data Source (formula) * Get Series Data Source (formula)
* *
* @return string * @return string
*/ */
public function getDataSource() { public function getDataSource() {
return $this->_dataSource; return $this->_dataSource;
} }
/** /**
* Set Series Data Source (formula) * Set Series Data Source (formula)
* *
* @param string $dataSource * @param string $dataSource
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setDataSource($dataSource = null, $refreshDataValues = true) { public function setDataSource($dataSource = null, $refreshDataValues = true) {
$this->_dataSource = $dataSource; $this->_dataSource = $dataSource;
if ($refreshDataValues) { if ($refreshDataValues) {
// TO DO // TO DO
} }
return $this; return $this;
} }
/** /**
* Get Point Marker * Get Point Marker
* *
* @return string * @return string
*/ */
public function getPointMarker() { public function getPointMarker() {
return $this->_marker; return $this->_marker;
} }
/** /**
* Set Point Marker * Set Point Marker
* *
* @param string $marker * @param string $marker
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setPointMarker($marker = null) { public function setPointMarker($marker = null) {
$this->_marker = $marker; $this->_marker = $marker;
return $this; return $this;
} }
/** /**
* Get Series Format Code * Get Series Format Code
* *
* @return string * @return string
*/ */
public function getFormatCode() { public function getFormatCode() {
return $this->_formatCode; return $this->_formatCode;
} }
/** /**
* Set Series Format Code * Set Series Format Code
* *
* @param string $formatCode * @param string $formatCode
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setFormatCode($formatCode = null) { public function setFormatCode($formatCode = null) {
$this->_formatCode = $formatCode; $this->_formatCode = $formatCode;
return $this; return $this;
} }
/** /**
* Get Series Point Count * Get Series Point Count
* *
* @return integer * @return integer
*/ */
public function getPointCount() { public function getPointCount() {
return $this->_pointCount; return $this->_pointCount;
} }
/** /**
* Identify if the Data Series is a multi-level or a simple series * Identify if the Data Series is a multi-level or a simple series
* *
* @return boolean * @return boolean
*/ */
public function isMultiLevelSeries() { public function isMultiLevelSeries() {
if (count($this->_dataValues) > 0) { if (count($this->_dataValues) > 0) {
return is_array($this->_dataValues[0]); return is_array($this->_dataValues[0]);
} }
return null; return null;
} }
/** /**
* Return the level count of a multi-level Data Series * Return the level count of a multi-level Data Series
* *
* @return boolean * @return boolean
*/ */
public function multiLevelCount() { public function multiLevelCount() {
$levelCount = 0; $levelCount = 0;
foreach($this->_dataValues as $dataValueSet) { foreach($this->_dataValues as $dataValueSet) {
$levelCount = max($levelCount,count($dataValueSet)); $levelCount = max($levelCount,count($dataValueSet));
} }
return $levelCount; return $levelCount;
} }
/** /**
* Get Series Data Values * Get Series Data Values
* *
* @return array of mixed * @return array of mixed
*/ */
public function getDataValues() { public function getDataValues() {
return $this->_dataValues; return $this->_dataValues;
} }
/** /**
* Get the first Series Data value * Get the first Series Data value
* *
* @return mixed * @return mixed
*/ */
public function getDataValue() { public function getDataValue() {
$count = count($this->_dataValues); $count = count($this->_dataValues);
if ($count == 0) { if ($count == 0) {
return null; return null;
} elseif ($count == 1) { } elseif ($count == 1) {
return $this->_dataValues[0]; return $this->_dataValues[0];
} }
return $this->_dataValues; return $this->_dataValues;
} }
/** /**
* Set Series Data Values * Set Series Data Values
* *
* @param array $dataValues * @param array $dataValues
* @param boolean $refreshDataSource * @param boolean $refreshDataSource
* TRUE - refresh the value of _dataSource based on the values of $dataValues * TRUE - refresh the value of _dataSource based on the values of $dataValues
* FALSE - don't change the value of _dataSource * FALSE - don't change the value of _dataSource
* @return PHPExcel_Chart_DataSeriesValues * @return PHPExcel_Chart_DataSeriesValues
*/ */
public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) { public function setDataValues($dataValues = array(), $refreshDataSource = TRUE) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues); $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($dataValues);
$this->_pointCount = count($dataValues); $this->_pointCount = count($dataValues);
if ($refreshDataSource) { if ($refreshDataSource) {
// TO DO // TO DO
} }
return $this; return $this;
} }
private function _stripNulls($var) { private function _stripNulls($var) {
return $var !== NULL; return $var !== NULL;
} }
public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) { public function refresh(PHPExcel_Worksheet $worksheet, $flatten = TRUE) {
if ($this->_dataSource !== NULL) { if ($this->_dataSource !== NULL) {
$calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent()); $calcEngine = PHPExcel_Calculation::getInstance($worksheet->getParent());
$newDataValues = PHPExcel_Calculation::_unwrapResult( $newDataValues = PHPExcel_Calculation::_unwrapResult(
$calcEngine->_calculateFormulaValue( $calcEngine->_calculateFormulaValue(
'='.$this->_dataSource, '='.$this->_dataSource,
NULL, NULL,
$worksheet->getCell('A1') $worksheet->getCell('A1')
) )
); );
if ($flatten) { if ($flatten) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
foreach($this->_dataValues as &$dataValue) { foreach($this->_dataValues as &$dataValue) {
if ((!empty($dataValue)) && ($dataValue[0] == '#')) { if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
$dataValue = 0.0; $dataValue = 0.0;
} }
} }
unset($dataValue); unset($dataValue);
} else { } else {
$cellRange = explode('!',$this->_dataSource); $cellRange = explode('!',$this->_dataSource);
if (count($cellRange) > 1) { if (count($cellRange) > 1) {
list(,$cellRange) = $cellRange; list(,$cellRange) = $cellRange;
} }
$dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange)); $dimensions = PHPExcel_Cell::rangeDimension(str_replace('$','',$cellRange));
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
$this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues); $this->_dataValues = PHPExcel_Calculation_Functions::flattenArray($newDataValues);
} else { } else {
$newArray = array_values(array_shift($newDataValues)); $newArray = array_values(array_shift($newDataValues));
foreach($newArray as $i => $newDataSet) { foreach($newArray as $i => $newDataSet) {
$newArray[$i] = array($newDataSet); $newArray[$i] = array($newDataSet);
} }
foreach($newDataValues as $newDataSet) { foreach($newDataValues as $newDataSet) {
$i = 0; $i = 0;
foreach($newDataSet as $newDataVal) { foreach($newDataSet as $newDataVal) {
array_unshift($newArray[$i++],$newDataVal); array_unshift($newArray[$i++],$newDataVal);
} }
} }
$this->_dataValues = $newArray; $this->_dataValues = $newArray;
} }
} }
$this->_pointCount = count($this->_dataValues); $this->_pointCount = count($this->_dataValues);
} }
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Chart_Exception
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -21,32 +22,25 @@
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
class PHPExcel_Chart_Exception extends PHPExcel_Exception
{
/** /**
* PHPExcel_Chart_Exception * Error handler callback
* *
* @category PHPExcel * @param mixed $code
* @package PHPExcel_Chart * @param mixed $string
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @param mixed $file
*/ * @param mixed $line
class PHPExcel_Chart_Exception extends PHPExcel_Exception { * @param mixed $context
/** */
* Error handler callback public static function errorHandlerCallback($code, $string, $file, $line, $context)
* {
* @param mixed $code $e = new self($string, $code);
* @param mixed $string $e->line = $line;
* @param mixed $file $e->file = $file;
* @param mixed $line throw $e;
* @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;
}
} }

View File

@ -18,428 +18,428 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** /**
* PHPExcel_Chart_Layout * PHPExcel_Chart_Layout
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Layout class PHPExcel_Chart_Layout
{ {
/** /**
* layoutTarget * layoutTarget
* *
* @var string * @var string
*/ */
private $_layoutTarget = NULL; private $_layoutTarget = NULL;
/** /**
* X Mode * X Mode
* *
* @var string * @var string
*/ */
private $_xMode = NULL; private $_xMode = NULL;
/** /**
* Y Mode * Y Mode
* *
* @var string * @var string
*/ */
private $_yMode = NULL; private $_yMode = NULL;
/** /**
* X-Position * X-Position
* *
* @var float * @var float
*/ */
private $_xPos = NULL; private $_xPos = NULL;
/** /**
* Y-Position * Y-Position
* *
* @var float * @var float
*/ */
private $_yPos = NULL; private $_yPos = NULL;
/** /**
* width * width
* *
* @var float * @var float
*/ */
private $_width = NULL; private $_width = NULL;
/** /**
* height * height
* *
* @var float * @var float
*/ */
private $_height = NULL; private $_height = NULL;
/** /**
* show legend key * show legend key
* Specifies that legend keys should be shown in data labels * Specifies that legend keys should be shown in data labels
* *
* @var boolean * @var boolean
*/ */
private $_showLegendKey = NULL; private $_showLegendKey = NULL;
/** /**
* show value * show value
* Specifies that the value should be shown in a data label. * Specifies that the value should be shown in a data label.
* *
* @var boolean * @var boolean
*/ */
private $_showVal = NULL; private $_showVal = NULL;
/** /**
* show category name * show category name
* Specifies that the category name should be shown in the data label. * Specifies that the category name should be shown in the data label.
* *
* @var boolean * @var boolean
*/ */
private $_showCatName = NULL; private $_showCatName = NULL;
/** /**
* show data series name * show data series name
* Specifies that the series name should be shown in the data label. * Specifies that the series name should be shown in the data label.
* *
* @var boolean * @var boolean
*/ */
private $_showSerName = NULL; private $_showSerName = NULL;
/** /**
* show percentage * show percentage
* Specifies that the percentage should be shown in the data label. * Specifies that the percentage should be shown in the data label.
* *
* @var boolean * @var boolean
*/ */
private $_showPercent = NULL; private $_showPercent = NULL;
/** /**
* show bubble size * show bubble size
* *
* @var boolean * @var boolean
*/ */
private $_showBubbleSize = NULL; private $_showBubbleSize = NULL;
/** /**
* show leader lines * show leader lines
* Specifies that leader lines should be shown for the data label. * Specifies that leader lines should be shown for the data label.
* *
* @var boolean * @var boolean
*/ */
private $_showLeaderLines = NULL; private $_showLeaderLines = NULL;
/** /**
* Create a new PHPExcel_Chart_Layout * Create a new PHPExcel_Chart_Layout
*/ */
public function __construct($layout=array()) public function __construct($layout=array())
{ {
if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; } if (isset($layout['layoutTarget'])) { $this->_layoutTarget = $layout['layoutTarget']; }
if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; } if (isset($layout['xMode'])) { $this->_xMode = $layout['xMode']; }
if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; } if (isset($layout['yMode'])) { $this->_yMode = $layout['yMode']; }
if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; } if (isset($layout['x'])) { $this->_xPos = (float) $layout['x']; }
if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; } if (isset($layout['y'])) { $this->_yPos = (float) $layout['y']; }
if (isset($layout['w'])) { $this->_width = (float) $layout['w']; } if (isset($layout['w'])) { $this->_width = (float) $layout['w']; }
if (isset($layout['h'])) { $this->_height = (float) $layout['h']; } if (isset($layout['h'])) { $this->_height = (float) $layout['h']; }
} }
/** /**
* Get Layout Target * Get Layout Target
* *
* @return string * @return string
*/ */
public function getLayoutTarget() { public function getLayoutTarget() {
return $this->_layoutTarget; return $this->_layoutTarget;
} }
/** /**
* Set Layout Target * Set Layout Target
* *
* @param Layout Target $value * @param Layout Target $value
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setLayoutTarget($value) { public function setLayoutTarget($value) {
$this->_layoutTarget = $value; $this->_layoutTarget = $value;
return $this; return $this;
} }
/** /**
* Get X-Mode * Get X-Mode
* *
* @return string * @return string
*/ */
public function getXMode() { public function getXMode() {
return $this->_xMode; return $this->_xMode;
} }
/** /**
* Set X-Mode * Set X-Mode
* *
* @param X-Mode $value * @param X-Mode $value
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setXMode($value) { public function setXMode($value) {
$this->_xMode = $value; $this->_xMode = $value;
return $this; return $this;
} }
/** /**
* Get Y-Mode * Get Y-Mode
* *
* @return string * @return string
*/ */
public function getYMode() { public function getYMode() {
return $this->_yMode; return $this->_yMode;
} }
/** /**
* Set Y-Mode * Set Y-Mode
* *
* @param Y-Mode $value * @param Y-Mode $value
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setYMode($value) { public function setYMode($value) {
$this->_yMode = $value; $this->_yMode = $value;
return $this; return $this;
} }
/** /**
* Get X-Position * Get X-Position
* *
* @return number * @return number
*/ */
public function getXPosition() { public function getXPosition() {
return $this->_xPos; return $this->_xPos;
} }
/** /**
* Set X-Position * Set X-Position
* *
* @param X-Position $value * @param X-Position $value
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setXPosition($value) { public function setXPosition($value) {
$this->_xPos = $value; $this->_xPos = $value;
return $this; return $this;
} }
/** /**
* Get Y-Position * Get Y-Position
* *
* @return number * @return number
*/ */
public function getYPosition() { public function getYPosition() {
return $this->_yPos; return $this->_yPos;
} }
/** /**
* Set Y-Position * Set Y-Position
* *
* @param Y-Position $value * @param Y-Position $value
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setYPosition($value) { public function setYPosition($value) {
$this->_yPos = $value; $this->_yPos = $value;
return $this; return $this;
} }
/** /**
* Get Width * Get Width
* *
* @return number * @return number
*/ */
public function getWidth() { public function getWidth() {
return $this->_width; return $this->_width;
} }
/** /**
* Set Width * Set Width
* *
* @param Width $value * @param Width $value
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setWidth($value) { public function setWidth($value) {
$this->_width = $value; $this->_width = $value;
return $this; return $this;
} }
/** /**
* Get Height * Get Height
* *
* @return number * @return number
*/ */
public function getHeight() { public function getHeight() {
return $this->_height; return $this->_height;
} }
/** /**
* Set Height * Set Height
* *
* @param Height $value * @param Height $value
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setHeight($value) { public function setHeight($value) {
$this->_height = $value; $this->_height = $value;
return $this; return $this;
} }
/** /**
* Get show legend key * Get show legend key
* *
* @return boolean * @return boolean
*/ */
public function getShowLegendKey() { public function getShowLegendKey() {
return $this->_showLegendKey; return $this->_showLegendKey;
} }
/** /**
* Set show legend key * Set show legend key
* Specifies that legend keys should be shown in data labels. * Specifies that legend keys should be shown in data labels.
* *
* @param boolean $value Show legend key * @param boolean $value Show legend key
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setShowLegendKey($value) { public function setShowLegendKey($value) {
$this->_showLegendKey = $value; $this->_showLegendKey = $value;
return $this; return $this;
} }
/** /**
* Get show value * Get show value
* *
* @return boolean * @return boolean
*/ */
public function getShowVal() { public function getShowVal() {
return $this->_showVal; return $this->_showVal;
} }
/** /**
* Set show val * Set show val
* Specifies that the value should be shown in data labels. * Specifies that the value should be shown in data labels.
* *
* @param boolean $value Show val * @param boolean $value Show val
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setShowVal($value) { public function setShowVal($value) {
$this->_showVal = $value; $this->_showVal = $value;
return $this; return $this;
} }
/** /**
* Get show category name * Get show category name
* *
* @return boolean * @return boolean
*/ */
public function getShowCatName() { public function getShowCatName() {
return $this->_showCatName; return $this->_showCatName;
} }
/** /**
* Set show cat name * Set show cat name
* Specifies that the category name should be shown in data labels. * Specifies that the category name should be shown in data labels.
* *
* @param boolean $value Show cat name * @param boolean $value Show cat name
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setShowCatName($value) { public function setShowCatName($value) {
$this->_showCatName = $value; $this->_showCatName = $value;
return $this; return $this;
} }
/** /**
* Get show data series name * Get show data series name
* *
* @return boolean * @return boolean
*/ */
public function getShowSerName() { public function getShowSerName() {
return $this->_showSerName; return $this->_showSerName;
} }
/** /**
* Set show ser name * Set show ser name
* Specifies that the series name should be shown in data labels. * Specifies that the series name should be shown in data labels.
* *
* @param boolean $value Show series name * @param boolean $value Show series name
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setShowSerName($value) { public function setShowSerName($value) {
$this->_showSerName = $value; $this->_showSerName = $value;
return $this; return $this;
} }
/** /**
* Get show percentage * Get show percentage
* *
* @return boolean * @return boolean
*/ */
public function getShowPercent() { public function getShowPercent() {
return $this->_showPercent; return $this->_showPercent;
} }
/** /**
* Set show percentage * Set show percentage
* Specifies that the percentage should be shown in data labels. * Specifies that the percentage should be shown in data labels.
* *
* @param boolean $value Show percentage * @param boolean $value Show percentage
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setShowPercent($value) { public function setShowPercent($value) {
$this->_showPercent = $value; $this->_showPercent = $value;
return $this; return $this;
} }
/** /**
* Get show bubble size * Get show bubble size
* *
* @return boolean * @return boolean
*/ */
public function getShowBubbleSize() { public function getShowBubbleSize() {
return $this->_showBubbleSize; return $this->_showBubbleSize;
} }
/** /**
* Set show bubble size * Set show bubble size
* Specifies that the bubble size should be shown in data labels. * Specifies that the bubble size should be shown in data labels.
* *
* @param boolean $value Show bubble size * @param boolean $value Show bubble size
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setShowBubbleSize($value) { public function setShowBubbleSize($value) {
$this->_showBubbleSize = $value; $this->_showBubbleSize = $value;
return $this; return $this;
} }
/** /**
* Get show leader lines * Get show leader lines
* *
* @return boolean * @return boolean
*/ */
public function getShowLeaderLines() { public function getShowLeaderLines() {
return $this->_showLeaderLines; return $this->_showLeaderLines;
} }
/** /**
* Set show leader lines * Set show leader lines
* Specifies that leader lines should be shown in data labels. * Specifies that leader lines should be shown in data labels.
* *
* @param boolean $value Show leader lines * @param boolean $value Show leader lines
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function setShowLeaderLines($value) { public function setShowLeaderLines($value) {
$this->_showLeaderLines = $value; $this->_showLeaderLines = $value;
return $this; return $this;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Chart_Legend
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -18,154 +19,146 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_Legend
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Legend class PHPExcel_Chart_Legend
{ {
/** Legend positions */ /** Legend positions */
const xlLegendPositionBottom = -4107; // Below the chart. const xlLegendPositionBottom = -4107; // Below the chart.
const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border. const xlLegendPositionCorner = 2; // In the upper right-hand corner of the chart border.
const xlLegendPositionCustom = -4161; // A custom position. const xlLegendPositionCustom = -4161; // A custom position.
const xlLegendPositionLeft = -4131; // Left of the chart. const xlLegendPositionLeft = -4131; // Left of the chart.
const xlLegendPositionRight = -4152; // Right of the chart. const xlLegendPositionRight = -4152; // Right of the chart.
const xlLegendPositionTop = -4160; // Above the chart. const xlLegendPositionTop = -4160; // Above the chart.
const POSITION_RIGHT = 'r'; const POSITION_RIGHT = 'r';
const POSITION_LEFT = 'l'; const POSITION_LEFT = 'l';
const POSITION_BOTTOM = 'b'; const POSITION_BOTTOM = 'b';
const POSITION_TOP = 't'; const POSITION_TOP = 't';
const POSITION_TOPRIGHT = 'tr'; const POSITION_TOPRIGHT = 'tr';
private static $_positionXLref = array( self::xlLegendPositionBottom => self::POSITION_BOTTOM, private static $_positionXLref = array(
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT, self::xlLegendPositionBottom => self::POSITION_BOTTOM,
self::xlLegendPositionCustom => '??', self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
self::xlLegendPositionLeft => self::POSITION_LEFT, self::xlLegendPositionCustom => '??',
self::xlLegendPositionRight => self::POSITION_RIGHT, self::xlLegendPositionLeft => self::POSITION_LEFT,
self::xlLegendPositionTop => self::POSITION_TOP self::xlLegendPositionRight => self::POSITION_RIGHT,
); self::xlLegendPositionTop => self::POSITION_TOP
);
/** /**
* Legend position * Legend position
* *
* @var string * @var string
*/ */
private $_position = self::POSITION_RIGHT; private $_position = self::POSITION_RIGHT;
/** /**
* Allow overlay of other elements? * Allow overlay of other elements?
* *
* @var boolean * @var boolean
*/ */
private $_overlay = TRUE; private $_overlay = TRUE;
/** /**
* Legend Layout * Legend Layout
* *
* @var PHPExcel_Chart_Layout * @var PHPExcel_Chart_Layout
*/ */
private $_layout = NULL; private $_layout = NULL;
/** /**
* Create a new PHPExcel_Chart_Legend * Create a new PHPExcel_Chart_Legend
*/ */
public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE) public function __construct($position = self::POSITION_RIGHT, PHPExcel_Chart_Layout $layout = NULL, $overlay = FALSE)
{ {
$this->setPosition($position); $this->setPosition($position);
$this->_layout = $layout; $this->_layout = $layout;
$this->setOverlay($overlay); $this->setOverlay($overlay);
} }
/** /**
* Get legend position as an excel string value * Get legend position as an excel string value
* *
* @return string * @return string
*/ */
public function getPosition() { public function getPosition() {
return $this->_position; return $this->_position;
} }
/** /**
* Get legend position using an excel string value * Get legend position using an excel string value
* *
* @param string $position * @param string $position
*/ */
public function setPosition($position = self::POSITION_RIGHT) { public function setPosition($position = self::POSITION_RIGHT) {
if (!in_array($position,self::$_positionXLref)) { if (!in_array($position,self::$_positionXLref)) {
return false; return false;
} }
$this->_position = $position; $this->_position = $position;
return true; return true;
} }
/** /**
* Get legend position as an Excel internal numeric value * Get legend position as an Excel internal numeric value
* *
* @return number * @return number
*/ */
public function getPositionXL() { public function getPositionXL() {
return array_search($this->_position,self::$_positionXLref); return array_search($this->_position,self::$_positionXLref);
} }
/** /**
* Set legend position using an Excel internal numeric value * Set legend position using an Excel internal numeric value
* *
* @param number $positionXL * @param number $positionXL
*/ */
public function setPositionXL($positionXL = self::xlLegendPositionRight) { public function setPositionXL($positionXL = self::xlLegendPositionRight) {
if (!array_key_exists($positionXL,self::$_positionXLref)) { if (!array_key_exists($positionXL,self::$_positionXLref)) {
return false; return false;
} }
$this->_position = self::$_positionXLref[$positionXL]; $this->_position = self::$_positionXLref[$positionXL];
return true; return true;
} }
/** /**
* Get allow overlay of other elements? * Get allow overlay of other elements?
* *
* @return boolean * @return boolean
*/ */
public function getOverlay() { public function getOverlay() {
return $this->_overlay; return $this->_overlay;
} }
/** /**
* Set allow overlay of other elements? * Set allow overlay of other elements?
* *
* @param boolean $overlay * @param boolean $overlay
* @return boolean * @return boolean
*/ */
public function setOverlay($overlay = FALSE) { public function setOverlay($overlay = FALSE) {
if (!is_bool($overlay)) { if (!is_bool($overlay)) {
return false; return false;
} }
$this->_overlay = $overlay; $this->_overlay = $overlay;
return true; return true;
} }
/** /**
* Get Layout * Get Layout
* *
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function getLayout() { public function getLayout() {
return $this->_layout; return $this->_layout;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Chart_PlotArea
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -18,111 +19,102 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/
/**
* PHPExcel_Chart_PlotArea
*
* @category PHPExcel
* @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_PlotArea class PHPExcel_Chart_PlotArea
{ {
/** /**
* PlotArea Layout * PlotArea Layout
* *
* @var PHPExcel_Chart_Layout * @var PHPExcel_Chart_Layout
*/ */
private $_layout = null; private $_layout = null;
/** /**
* Plot Series * Plot Series
* *
* @var array of PHPExcel_Chart_DataSeries * @var array of PHPExcel_Chart_DataSeries
*/ */
private $_plotSeries = array(); private $_plotSeries = array();
/** /**
* Create a new PHPExcel_Chart_PlotArea * Create a new PHPExcel_Chart_PlotArea
*/ */
public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array()) public function __construct(PHPExcel_Chart_Layout $layout = null, $plotSeries = array())
{ {
$this->_layout = $layout; $this->_layout = $layout;
$this->_plotSeries = $plotSeries; $this->_plotSeries = $plotSeries;
} }
/** /**
* Get Layout * Get Layout
* *
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function getLayout() { public function getLayout() {
return $this->_layout; return $this->_layout;
} }
/** /**
* Get Number of Plot Groups * Get Number of Plot Groups
* *
* @return array of PHPExcel_Chart_DataSeries * @return array of PHPExcel_Chart_DataSeries
*/ */
public function getPlotGroupCount() { public function getPlotGroupCount() {
return count($this->_plotSeries); return count($this->_plotSeries);
} }
/** /**
* Get Number of Plot Series * Get Number of Plot Series
* *
* @return integer * @return integer
*/ */
public function getPlotSeriesCount() { public function getPlotSeriesCount() {
$seriesCount = 0; $seriesCount = 0;
foreach($this->_plotSeries as $plot) { foreach($this->_plotSeries as $plot) {
$seriesCount += $plot->getPlotSeriesCount(); $seriesCount += $plot->getPlotSeriesCount();
} }
return $seriesCount; return $seriesCount;
} }
/** /**
* Get Plot Series * Get Plot Series
* *
* @return array of PHPExcel_Chart_DataSeries * @return array of PHPExcel_Chart_DataSeries
*/ */
public function getPlotGroup() { public function getPlotGroup() {
return $this->_plotSeries; return $this->_plotSeries;
} }
/** /**
* Get Plot Series by Index * Get Plot Series by Index
* *
* @return PHPExcel_Chart_DataSeries * @return PHPExcel_Chart_DataSeries
*/ */
public function getPlotGroupByIndex($index) { public function getPlotGroupByIndex($index) {
return $this->_plotSeries[$index]; return $this->_plotSeries[$index];
} }
/** /**
* Set Plot Series * Set Plot Series
* *
* @param [PHPExcel_Chart_DataSeries] * @param [PHPExcel_Chart_DataSeries]
* @return PHPExcel_Chart_PlotArea * @return PHPExcel_Chart_PlotArea
*/ */
public function setPlotSeries($plotSeries = array()) { public function setPlotSeries($plotSeries = array()) {
$this->_plotSeries = $plotSeries; $this->_plotSeries = $plotSeries;
return $this; return $this;
} }
public function refresh(PHPExcel_Worksheet $worksheet) { public function refresh(PHPExcel_Worksheet $worksheet) {
foreach($this->_plotSeries as $plotSeries) { foreach($this->_plotSeries as $plotSeries) {
$plotSeries->refresh($worksheet); $plotSeries->refresh($worksheet);
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -18,75 +18,75 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** /**
* PHPExcel_Chart_Title * PHPExcel_Chart_Title
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Chart * @package PHPExcel_Chart
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Chart_Title class PHPExcel_Chart_Title
{ {
/** /**
* Title Caption * Title Caption
* *
* @var string * @var string
*/ */
private $_caption = null; private $_caption = null;
/** /**
* Title Layout * Title Layout
* *
* @var PHPExcel_Chart_Layout * @var PHPExcel_Chart_Layout
*/ */
private $_layout = null; private $_layout = null;
/** /**
* Create a new PHPExcel_Chart_Title * Create a new PHPExcel_Chart_Title
*/ */
public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null) public function __construct($caption = null, PHPExcel_Chart_Layout $layout = null)
{ {
$this->_caption = $caption; $this->_caption = $caption;
$this->_layout = $layout; $this->_layout = $layout;
} }
/** /**
* Get caption * Get caption
* *
* @return string * @return string
*/ */
public function getCaption() { public function getCaption() {
return $this->_caption; return $this->_caption;
} }
/** /**
* Set caption * Set caption
* *
* @param string $caption * @param string $caption
* @return PHPExcel_Chart_Title * @return PHPExcel_Chart_Title
*/ */
public function setCaption($caption = null) { public function setCaption($caption = null) {
$this->_caption = $caption; $this->_caption = $caption;
return $this; return $this;
} }
/** /**
* Get Layout * Get Layout
* *
* @return PHPExcel_Chart_Layout * @return PHPExcel_Chart_Layout
*/ */
public function getLayout() { public function getLayout() {
return $this->_layout; return $this->_layout;
} }
} }

View File

@ -53,7 +53,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @var boolean * @var boolean
*/ */
private $_embedImages = FALSE; private $_embedImages = false;
/** /**
* Use inline CSS? * Use inline CSS?
@ -130,7 +130,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @param PHPExcel $phpExcel PHPExcel object * @param PHPExcel $phpExcel PHPExcel object
*/ */
public function __construct(PHPExcel $phpExcel) { public function __construct(PHPExcel $phpExcel)
{
$this->_phpExcel = $phpExcel; $this->_phpExcel = $phpExcel;
$this->_defaultFont = $this->_phpExcel->getDefaultStyle()->getFont(); $this->_defaultFont = $this->_phpExcel->getDefaultStyle()->getFont();
} }
@ -141,12 +142,13 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param string $pFilename * @param string $pFilename
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function save($pFilename = null) { public function save($pFilename = null)
{
// garbage collect // garbage collect
$this->_phpExcel->garbageCollect(); $this->_phpExcel->garbageCollect();
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_phpExcel)->getDebugLog()->getWriteDebugLog(); $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(); $saveArrayReturnType = PHPExcel_Calculation::getArrayReturnType();
PHPExcel_Calculation::setArrayReturnType(PHPExcel_Calculation::RETURN_ARRAY_AS_VALUE); 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 * @param string $vAlign Vertical alignment
* @return string * @return string
*/ */
private function _mapVAlign($vAlign) { private function _mapVAlign($vAlign)
{
switch ($vAlign) { switch ($vAlign) {
case PHPExcel_Style_Alignment::VERTICAL_BOTTOM: return 'bottom'; case PHPExcel_Style_Alignment::VERTICAL_BOTTOM:
case PHPExcel_Style_Alignment::VERTICAL_TOP: return 'top'; return 'bottom';
case PHPExcel_Style_Alignment::VERTICAL_TOP:
return 'top';
case PHPExcel_Style_Alignment::VERTICAL_CENTER: case PHPExcel_Style_Alignment::VERTICAL_CENTER:
case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY: return 'middle'; case PHPExcel_Style_Alignment::VERTICAL_JUSTIFY:
default: return 'baseline'; return 'middle';
default:
return 'baseline';
} }
} }
@ -202,15 +209,22 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param string $hAlign Horizontal alignment * @param string $hAlign Horizontal alignment
* @return string|false * @return string|false
*/ */
private function _mapHAlign($hAlign) { private function _mapHAlign($hAlign)
{
switch ($hAlign) { switch ($hAlign) {
case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL: return false; case PHPExcel_Style_Alignment::HORIZONTAL_GENERAL:
case PHPExcel_Style_Alignment::HORIZONTAL_LEFT: return 'left'; return false;
case PHPExcel_Style_Alignment::HORIZONTAL_RIGHT: return 'right'; 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:
case PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS: return 'center'; case PHPExcel_Style_Alignment::HORIZONTAL_CENTER_CONTINUOUS:
case PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY: return 'justify'; return 'center';
default: return false; 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 * @param int $borderStyle Sheet index
* @return string * @return string
*/ */
private function _mapBorderStyle($borderStyle) { private function _mapBorderStyle($borderStyle)
{
switch ($borderStyle) { switch ($borderStyle) {
case PHPExcel_Style_Border::BORDER_NONE: return 'none'; case PHPExcel_Style_Border::BORDER_NONE:
case PHPExcel_Style_Border::BORDER_DASHDOT: return '1px dashed'; return 'none';
case PHPExcel_Style_Border::BORDER_DASHDOTDOT: return '1px dotted'; case PHPExcel_Style_Border::BORDER_DASHDOT:
case PHPExcel_Style_Border::BORDER_DASHED: return '1px dashed'; return '1px dashed';
case PHPExcel_Style_Border::BORDER_DOTTED: return '1px dotted'; case PHPExcel_Style_Border::BORDER_DASHDOTDOT:
case PHPExcel_Style_Border::BORDER_DOUBLE: return '3px double'; return '1px dotted';
case PHPExcel_Style_Border::BORDER_HAIR: return '1px solid'; case PHPExcel_Style_Border::BORDER_DASHED:
case PHPExcel_Style_Border::BORDER_MEDIUM: return '2px solid'; return '1px dashed';
case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOT: return '2px dashed'; case PHPExcel_Style_Border::BORDER_DOTTED:
case PHPExcel_Style_Border::BORDER_MEDIUMDASHDOTDOT: return '2px dotted'; return '1px dotted';
case PHPExcel_Style_Border::BORDER_MEDIUMDASHED: return '2px dashed'; case PHPExcel_Style_Border::BORDER_DOUBLE:
case PHPExcel_Style_Border::BORDER_SLANTDASHDOT: return '2px dashed'; return '3px double';
case PHPExcel_Style_Border::BORDER_THICK: return '3px solid'; case PHPExcel_Style_Border::BORDER_HAIR:
case PHPExcel_Style_Border::BORDER_THIN: return '1px solid'; return '1px solid';
default: return '1px solid'; // map others to thin 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 * @return int
*/ */
public function getSheetIndex() { public function getSheetIndex()
{
return $this->_sheetIndex; return $this->_sheetIndex;
} }
@ -255,7 +287,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param int $pValue Sheet index * @param int $pValue Sheet index
* @return PHPExcel_Writer_HTML * @return PHPExcel_Writer_HTML
*/ */
public function setSheetIndex($pValue = 0) { public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue; $this->_sheetIndex = $pValue;
return $this; return $this;
} }
@ -265,7 +298,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getGenerateSheetNavigationBlock() { public function getGenerateSheetNavigationBlock()
{
return $this->_generateSheetNavigationBlock; 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 * @param boolean $pValue Flag indicating whether the sheet navigation block should be generated or not
* @return PHPExcel_Writer_HTML * @return PHPExcel_Writer_HTML
*/ */
public function setGenerateSheetNavigationBlock($pValue = true) { public function setGenerateSheetNavigationBlock($pValue = true)
{
$this->_generateSheetNavigationBlock = (bool) $pValue; $this->_generateSheetNavigationBlock = (bool) $pValue;
return $this; return $this;
} }
@ -283,7 +318,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
/** /**
* Write all sheets (resets sheetIndex to NULL) * Write all sheets (resets sheetIndex to NULL)
*/ */
public function writeAllSheets() { public function writeAllSheets()
{
$this->_sheetIndex = null; $this->_sheetIndex = null;
return $this; return $this;
} }
@ -295,7 +331,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function generateHTMLHeader($pIncludeStyles = false) { public function generateHTMLHeader($pIncludeStyles = false)
{
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->_phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); 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 .= '<html>' . PHP_EOL; $html .= '<html>' . PHP_EOL;
$html .= ' <head>' . PHP_EOL; $html .= ' <head>' . PHP_EOL;
$html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . PHP_EOL; $html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . PHP_EOL;
if ($properties->getTitle() > '') if ($properties->getTitle() > '') {
$html .= ' <title>' . htmlspecialchars($properties->getTitle()) . '</title>' . PHP_EOL; $html .= ' <title>' . htmlspecialchars($properties->getTitle()) . '</title>' . PHP_EOL;
}
if ($properties->getCreator() > '') if ($properties->getCreator() > '') {
$html .= ' <meta name="author" content="' . htmlspecialchars($properties->getCreator()) . '" />' . PHP_EOL; $html .= ' <meta name="author" content="' . htmlspecialchars($properties->getCreator()) . '" />' . PHP_EOL;
if ($properties->getTitle() > '') }
if ($properties->getTitle() > '') {
$html .= ' <meta name="title" content="' . htmlspecialchars($properties->getTitle()) . '" />' . PHP_EOL; $html .= ' <meta name="title" content="' . htmlspecialchars($properties->getTitle()) . '" />' . PHP_EOL;
if ($properties->getDescription() > '') }
if ($properties->getDescription() > '') {
$html .= ' <meta name="description" content="' . htmlspecialchars($properties->getDescription()) . '" />' . PHP_EOL; $html .= ' <meta name="description" content="' . htmlspecialchars($properties->getDescription()) . '" />' . PHP_EOL;
if ($properties->getSubject() > '') }
if ($properties->getSubject() > '') {
$html .= ' <meta name="subject" content="' . htmlspecialchars($properties->getSubject()) . '" />' . PHP_EOL; $html .= ' <meta name="subject" content="' . htmlspecialchars($properties->getSubject()) . '" />' . PHP_EOL;
if ($properties->getKeywords() > '') }
if ($properties->getKeywords() > '') {
$html .= ' <meta name="keywords" content="' . htmlspecialchars($properties->getKeywords()) . '" />' . PHP_EOL; $html .= ' <meta name="keywords" content="' . htmlspecialchars($properties->getKeywords()) . '" />' . PHP_EOL;
if ($properties->getCategory() > '') }
if ($properties->getCategory() > '') {
$html .= ' <meta name="category" content="' . htmlspecialchars($properties->getCategory()) . '" />' . PHP_EOL; $html .= ' <meta name="category" content="' . htmlspecialchars($properties->getCategory()) . '" />' . PHP_EOL;
if ($properties->getCompany() > '') }
if ($properties->getCompany() > '') {
$html .= ' <meta name="company" content="' . htmlspecialchars($properties->getCompany()) . '" />' . PHP_EOL; $html .= ' <meta name="company" content="' . htmlspecialchars($properties->getCompany()) . '" />' . PHP_EOL;
if ($properties->getManager() > '') }
if ($properties->getManager() > '') {
$html .= ' <meta name="manager" content="' . htmlspecialchars($properties->getManager()) . '" />' . PHP_EOL; $html .= ' <meta name="manager" content="' . htmlspecialchars($properties->getManager()) . '" />' . PHP_EOL;
}
if ($pIncludeStyles) { if ($pIncludeStyles) {
$html .= $this->generateStyles(true); $html .= $this->generateStyles(true);
@ -336,7 +381,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$html .= '' . PHP_EOL; $html .= '' . PHP_EOL;
$html .= ' <body>' . PHP_EOL; $html .= ' <body>' . PHP_EOL;
// Return
return $html; return $html;
} }
@ -346,7 +390,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function generateSheetData() { public function generateSheetData()
{
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->_phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); 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 // Loop through cells
$row = $rowMin-1; $row = $rowMin-1;
while($row++ < $rowMax) { while ($row++ < $rowMax) {
// <thead> ? // <thead> ?
if ($row == $theadStart) { if ($row == $theadStart) {
$html .= ' <thead>' . PHP_EOL; $html .= ' <thead>' . 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 // 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 // Start a new rowData
$rowData = array(); $rowData = array();
// Loop through columns // Loop through columns
$column = $dimension[0][0] - 1; $column = $dimension[0][0] - 1;
while($column++ < $dimension[1][0]) { while ($column++ < $dimension[1][0]) {
// Cell exists? // Cell exists?
if ($sheet->cellExistsByColumnAndRow($column, $row)) { if ($sheet->cellExistsByColumnAndRow($column, $row)) {
$rowData[$column] = PHPExcel_Cell::stringFromColumnIndex($column) . $row; $rowData[$column] = PHPExcel_Cell::stringFromColumnIndex($column) . $row;
@ -455,7 +500,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
++$sheetId; ++$sheetId;
} }
// Return
return $html; return $html;
} }
@ -501,7 +545,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
return $html; return $html;
} }
private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row) { private function _extendRowsForChartsAndImages(PHPExcel_Worksheet $pSheet, $row)
{
$rowMax = $row; $rowMax = $row;
$colMax = 'A'; $colMax = 'A';
if ($this->_includeCharts) { if ($this->_includeCharts) {
@ -559,7 +604,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) { private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates)
{
// Construct HTML // Construct HTML
$html = ''; $html = '';
@ -590,8 +636,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$imageData = $filename; $imageData = $filename;
} else { } else {
$imageDetails = getimagesize($filename); $imageDetails = getimagesize($filename);
if ($fp = fopen($filename,"rb", 0)) { if ($fp = fopen($filename, "rb", 0)) {
$picture = fread($fp,filesize($filename)); $picture = fread($fp, filesize($filename));
fclose($fp); fclose($fp);
// base64 encode the binary data, then break it // base64 encode the binary data, then break it
// into chunks according to RFC 2045 semantics // into chunks according to RFC 2045 semantics
@ -612,7 +658,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
} }
// Return
return $html; return $html;
} }
@ -624,7 +669,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates) { private function _writeChartInCell(PHPExcel_Worksheet $pSheet, $coordinates)
{
// Construct HTML // Construct HTML
$html = ''; $html = '';
@ -640,8 +686,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$html .= PHP_EOL; $html .= PHP_EOL;
$imageDetails = getimagesize($chartFileName); $imageDetails = getimagesize($chartFileName);
if ($fp = fopen($chartFileName,"rb", 0)) { if ($fp = fopen($chartFileName, "rb", 0)) {
$picture = fread($fp,filesize($chartFileName)); $picture = fread($fp, filesize($chartFileName));
fclose($fp); fclose($fp);
// base64 encode the binary data, then break it // base64 encode the binary data, then break it
// into chunks according to RFC 2045 semantics // into chunks according to RFC 2045 semantics
@ -669,7 +715,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function generateStyles($generateSurroundingHTML = true) { public function generateStyles($generateSurroundingHTML = true)
{
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->_phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); 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 * @return array
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function buildCSS($generateSurroundingHTML = true) { public function buildCSS($generateSurroundingHTML = true)
{
// PHPExcel object known? // PHPExcel object known?
if (is_null($this->_phpExcel)) { if (is_null($this->_phpExcel)) {
throw new PHPExcel_Writer_Exception('Internal PHPExcel object not set to an instance of an object.'); 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 // Calculate cell style hashes
foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) { foreach ($this->_phpExcel->getCellXfCollection() as $index => $style) {
$css['td.style' . $index] = $this->_createCSSStyle( $style ); $css['td.style' . $index] = $this->_createCSSStyle($style);
$css['th.style' . $index] = $this->_createCSSStyle( $style ); $css['th.style' . $index] = $this->_createCSSStyle($style);
} }
// Fetch sheets // Fetch sheets
@ -792,7 +840,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// col elements, initialize // col elements, initialize
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1; $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
$column = -1; $column = -1;
while($column++ < $highestColumnIndex) { while ($column++ < $highestColumnIndex) {
$this->_columnWidths[$sheetIndex][$column] = 42; // approximation $this->_columnWidths[$sheetIndex][$column] = 42; // approximation
$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt'; $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 * @param PHPExcel_Style $pStyle PHPExcel_Style
* @return array * @return array
*/ */
private function _createCSSStyle(PHPExcel_Style $pStyle) { private function _createCSSStyle(PHPExcel_Style $pStyle)
{
// Construct CSS // Construct CSS
$css = ''; $css = '';
// Create CSS // Create CSS
$css = array_merge( $css = array_merge(
$this->_createCSSStyleAlignment($pStyle->getAlignment()) $this->_createCSSStyleAlignment($pStyle->getAlignment()),
, $this->_createCSSStyleBorders($pStyle->getBorders()) $this->_createCSSStyleBorders($pStyle->getBorders()),
, $this->_createCSSStyleFont($pStyle->getFont()) $this->_createCSSStyleFont($pStyle->getFont()),
, $this->_createCSSStyleFill($pStyle->getFill()) $this->_createCSSStyleFill($pStyle->getFill())
); );
// Return // Return
@ -886,7 +935,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Alignment $pStyle PHPExcel_Style_Alignment * @param PHPExcel_Style_Alignment $pStyle PHPExcel_Style_Alignment
* @return array * @return array
*/ */
private function _createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle) { private function _createCSSStyleAlignment(PHPExcel_Style_Alignment $pStyle)
{
// Construct CSS // Construct CSS
$css = array(); $css = array();
@ -894,11 +944,11 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$css['vertical-align'] = $this->_mapVAlign($pStyle->getVertical()); $css['vertical-align'] = $this->_mapVAlign($pStyle->getVertical());
if ($textAlign = $this->_mapHAlign($pStyle->getHorizontal())) { if ($textAlign = $this->_mapHAlign($pStyle->getHorizontal())) {
$css['text-align'] = $textAlign; $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'; $css['padding-'.$textAlign] = (string)((int)$pStyle->getIndent() * 9).'px';
}
} }
// Return
return $css; return $css;
} }
@ -908,7 +958,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font * @param PHPExcel_Style_Font $pStyle PHPExcel_Style_Font
* @return array * @return array
*/ */
private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle) { private function _createCSSStyleFont(PHPExcel_Style_Font $pStyle)
{
// Construct CSS // Construct CSS
$css = array(); $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()) { if ($pStyle->getUnderline() != PHPExcel_Style_Font::UNDERLINE_NONE && $pStyle->getStrikethrough()) {
$css['text-decoration'] = 'underline line-through'; $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'; $css['text-decoration'] = 'underline';
} else if ($pStyle->getStrikethrough()) { } elseif ($pStyle->getStrikethrough()) {
$css['text-decoration'] = 'line-through'; $css['text-decoration'] = 'line-through';
} }
if ($pStyle->getItalic()) { if ($pStyle->getItalic()) {
$css['font-style'] = 'italic'; $css['font-style'] = 'italic';
} }
$css['color'] = '#' . $pStyle->getColor()->getRGB(); $css['color'] = '#' . $pStyle->getColor()->getRGB();
$css['font-family'] = '\'' . $pStyle->getName() . '\''; $css['font-family'] = '\'' . $pStyle->getName() . '\'';
$css['font-size'] = $pStyle->getSize() . 'pt'; $css['font-size'] = $pStyle->getSize() . 'pt';
// Return
return $css; return $css;
} }
@ -941,17 +991,17 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Borders $pStyle PHPExcel_Style_Borders * @param PHPExcel_Style_Borders $pStyle PHPExcel_Style_Borders
* @return array * @return array
*/ */
private function _createCSSStyleBorders(PHPExcel_Style_Borders $pStyle) { private function _createCSSStyleBorders(PHPExcel_Style_Borders $pStyle)
{
// Construct CSS // Construct CSS
$css = array(); $css = array();
// Create CSS // Create CSS
$css['border-bottom'] = $this->_createCSSStyleBorder($pStyle->getBottom()); $css['border-bottom'] = $this->_createCSSStyleBorder($pStyle->getBottom());
$css['border-top'] = $this->_createCSSStyleBorder($pStyle->getTop()); $css['border-top'] = $this->_createCSSStyleBorder($pStyle->getTop());
$css['border-left'] = $this->_createCSSStyleBorder($pStyle->getLeft()); $css['border-left'] = $this->_createCSSStyleBorder($pStyle->getLeft());
$css['border-right'] = $this->_createCSSStyleBorder($pStyle->getRight()); $css['border-right'] = $this->_createCSSStyleBorder($pStyle->getRight());
// Return
return $css; return $css;
} }
@ -961,14 +1011,14 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Border $pStyle PHPExcel_Style_Border * @param PHPExcel_Style_Border $pStyle PHPExcel_Style_Border
* @return string * @return string
*/ */
private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle) { private function _createCSSStyleBorder(PHPExcel_Style_Border $pStyle)
{
// Create CSS // Create CSS
// $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB(); // $css = $this->_mapBorderStyle($pStyle->getBorderStyle()) . ' #' . $pStyle->getColor()->getRGB();
// Create CSS - add !important to non-none border styles for merged cells // Create CSS - add !important to non-none border styles for merged cells
$borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle()); $borderStyle = $this->_mapBorderStyle($pStyle->getBorderStyle());
$css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important'); $css = $borderStyle . ' #' . $pStyle->getColor()->getRGB() . (($borderStyle == 'none') ? '' : ' !important');
// Return
return $css; return $css;
} }
@ -978,7 +1028,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param PHPExcel_Style_Fill $pStyle PHPExcel_Style_Fill * @param PHPExcel_Style_Fill $pStyle PHPExcel_Style_Fill
* @return array * @return array
*/ */
private function _createCSSStyleFill(PHPExcel_Style_Fill $pStyle) { private function _createCSSStyleFill(PHPExcel_Style_Fill $pStyle)
{
// Construct HTML // Construct HTML
$css = array(); $css = array();
@ -987,20 +1038,19 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
'white' : '#' . $pStyle->getStartColor()->getRGB(); 'white' : '#' . $pStyle->getStartColor()->getRGB();
$css['background-color'] = $value; $css['background-color'] = $value;
// Return
return $css; return $css;
} }
/** /**
* Generate HTML footer * Generate HTML footer
*/ */
public function generateHTMLFooter() { public function generateHTMLFooter()
{
// Construct HTML // Construct HTML
$html = ''; $html = '';
$html .= ' </body>' . PHP_EOL; $html .= ' </body>' . PHP_EOL;
$html .= '</html>' . PHP_EOL; $html .= '</html>' . PHP_EOL;
// Return
return $html; return $html;
} }
@ -1011,7 +1061,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _generateTableHeader($pSheet) { private function _generateTableHeader($pSheet)
{
$sheetIndex = $pSheet->getParent()->getIndex($pSheet); $sheetIndex = $pSheet->getParent()->getIndex($pSheet);
// Construct HTML // Construct HTML
@ -1035,7 +1086,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
// Write <col> elements // Write <col> elements
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1; $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1;
$i = -1; $i = -1;
while($i++ < $highestColumnIndex) { while ($i++ < $highestColumnIndex) {
if (!$this->_isPdf) { if (!$this->_isPdf) {
if (!$this->_useInlineCss) { if (!$this->_useInlineCss) {
$html .= ' <col class="col' . $i . '">' . PHP_EOL; $html .= ' <col class="col' . $i . '">' . PHP_EOL;
@ -1047,7 +1098,6 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
} }
} }
// Return
return $html; return $html;
} }
@ -1056,12 +1106,10 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _generateTableFooter() { private function _generateTableFooter()
// Construct HTML {
$html = ''; $html = ' </table>' . PHP_EOL;
$html .= ' </table>' . PHP_EOL;
// Return
return $html; return $html;
} }
@ -1074,7 +1122,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @return string * @return string
* @throws PHPExcel_Writer_Exception * @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)) { if (is_array($pValues)) {
// Construct HTML // Construct HTML
$html = ''; $html = '';
@ -1152,7 +1201,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
if ($element->getFont()->getSuperScript()) { if ($element->getFont()->getSuperScript()) {
$cellData .= '<sup>'; $cellData .= '<sup>';
} else if ($element->getFont()->getSubScript()) { } elseif ($element->getFont()->getSubScript()) {
$cellData .= '<sub>'; $cellData .= '<sub>';
} }
} }
@ -1164,7 +1213,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
if ($element instanceof PHPExcel_RichText_Run) { if ($element instanceof PHPExcel_RichText_Run) {
if ($element->getFont()->getSuperScript()) { if ($element->getFont()->getSuperScript()) {
$cellData .= '</sup>'; $cellData .= '</sup>';
} else if ($element->getFont()->getSubScript()) { } elseif ($element->getFont()->getSubScript()) {
$cellData .= '</sub>'; $cellData .= '</sub>';
} }
@ -1175,20 +1224,20 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
if ($this->_preCalculateFormulas) { if ($this->_preCalculateFormulas) {
$cellData = PHPExcel_Style_NumberFormat::toFormattedString( $cellData = PHPExcel_Style_NumberFormat::toFormattedString(
$cell->getCalculatedValue(), $cell->getCalculatedValue(),
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(), $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(),
array($this, 'formatColor') array($this, 'formatColor')
); );
} else { } else {
$cellData = PHPExcel_Style_NumberFormat::toFormattedString( $cellData = PHPExcel_Style_NumberFormat::toFormattedString(
$cell->getValue(), $cell->getValue(),
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(), $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getNumberFormat()->getFormatCode(),
array($this, 'formatColor') array($this, 'formatColor')
); );
} }
$cellData = htmlspecialchars($cellData); $cellData = htmlspecialchars($cellData);
if ($pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getFont()->getSuperScript()) { if ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSuperScript()) {
$cellData = '<sup>'.$cellData.'</sup>'; $cellData = '<sup>'.$cellData.'</sup>';
} elseif ($pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getFont()->getSubScript()) { } elseif ($pSheet->getParent()->getCellXfByIndex($cell->getXfIndex())->getFont()->getSubScript()) {
$cellData = '<sub>'.$cellData.'</sub>'; $cellData = '<sub>'.$cellData.'</sub>';
} }
} }
@ -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? // 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]) $writeCell = !(isset($this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])
&& $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum] ); && $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum]);
// Colspan and Rowspan // Colspan and Rowspan
$colspan = 1; $colspan = 1;
@ -1263,7 +1312,7 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$width = 0; $width = 0;
$i = $colNum - 1; $i = $colNum - 1;
$e = $colNum + $colSpan - 1; $e = $colNum + $colSpan - 1;
while($i++ < $e) { while ($i++ < $e) {
if (isset($this->_columnWidths[$sheetIndex][$i])) { if (isset($this->_columnWidths[$sheetIndex][$i])) {
$width += $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) { if ($rowSpan > 1) {
$html .= ' rowspan="' . $rowSpan . '"'; $html .= ' rowspan="' . $rowSpan . '"';
} }
$html .= '>'; $html .= '>';
// Image? // Image?
$html .= $this->_writeImageInCell($pSheet, $coordinate); $html .= $this->_writeImageInCell($pSheet, $coordinate);
@ -1339,7 +1388,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @return string * @return string
*/ */
public function getImagesRoot() { public function getImagesRoot()
{
return $this->_imagesRoot; return $this->_imagesRoot;
} }
@ -1349,7 +1399,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param string $pValue * @param string $pValue
* @return PHPExcel_Writer_HTML * @return PHPExcel_Writer_HTML
*/ */
public function setImagesRoot($pValue = '.') { public function setImagesRoot($pValue = '.')
{
$this->_imagesRoot = $pValue; $this->_imagesRoot = $pValue;
return $this; return $this;
} }
@ -1359,7 +1410,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getEmbedImages() { public function getEmbedImages()
{
return $this->_embedImages; return $this->_embedImages;
} }
@ -1369,7 +1421,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Writer_HTML * @return PHPExcel_Writer_HTML
*/ */
public function setEmbedImages($pValue = '.') { public function setEmbedImages($pValue = '.')
{
$this->_embedImages = $pValue; $this->_embedImages = $pValue;
return $this; return $this;
} }
@ -1379,7 +1432,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* *
* @return boolean * @return boolean
*/ */
public function getUseInlineCss() { public function getUseInlineCss()
{
return $this->_useInlineCss; return $this->_useInlineCss;
} }
@ -1389,7 +1443,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
* @param boolean $pValue * @param boolean $pValue
* @return PHPExcel_Writer_HTML * @return PHPExcel_Writer_HTML
*/ */
public function setUseInlineCss($pValue = false) { public function setUseInlineCss($pValue = false)
{
$this->_useInlineCss = $pValue; $this->_useInlineCss = $pValue;
return $this; return $this;
} }
@ -1515,7 +1570,8 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
$this->_spansAreCalculated = true; $this->_spansAreCalculated = true;
} }
private function _setMargins(PHPExcel_Worksheet $pSheet) { private function _setMargins(PHPExcel_Worksheet $pSheet)
{
$htmlPage = '@page { '; $htmlPage = '@page { ';
$htmlBody = 'body { '; $htmlBody = 'body { ';
@ -1537,5 +1593,4 @@ class PHPExcel_Writer_HTML extends PHPExcel_Writer_Abstract implements PHPExcel_
return "<style>\n" . $htmlPage . $htmlBody . "</style>\n"; return "<style>\n" . $htmlPage . $htmlBody . "</style>\n";
} }
} }