PSR-2 : Fixes

This commit is contained in:
Progi1984 2015-05-13 12:27:01 +02:00
parent 06c1ea78de
commit 2881bca443
69 changed files with 2858 additions and 2994 deletions

View File

@ -38,7 +38,7 @@ if (!defined('PHPEXCEL_ROOT')) {
if (!defined('CALCULATION_REGEXP_CELLREF')) { if (!defined('CALCULATION_REGEXP_CELLREF')) {
// Test for support of \P (multibyte options) in PCRE // Test for support of \P (multibyte options) in PCRE
if(defined('PREG_BAD_UTF8_ERROR')) { if (defined('PREG_BAD_UTF8_ERROR')) {
// Cell reference (cell or range of cells, with or without a sheet reference) // Cell reference (cell or range of cells, with or without a sheet reference)
define('CALCULATION_REGEXP_CELLREF','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})'); define('CALCULATION_REGEXP_CELLREF','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})');
// Named Range of cells // Named Range of cells
@ -1724,7 +1724,7 @@ class PHPExcel_Calculation {
$setPrecision = (PHP_INT_SIZE == 4) ? 14 : 16; $setPrecision = (PHP_INT_SIZE == 4) ? 14 : 16;
$this->_savedPrecision = ini_get('precision'); $this->_savedPrecision = ini_get('precision');
if ($this->_savedPrecision < $setPrecision) { if ($this->_savedPrecision < $setPrecision) {
ini_set('precision',$setPrecision); ini_set('precision', $setPrecision);
} }
$this->delta = 1 * pow(10, -$setPrecision); $this->delta = 1 * pow(10, -$setPrecision);
@ -1740,7 +1740,7 @@ class PHPExcel_Calculation {
public function __destruct() { public function __destruct() {
if ($this->_savedPrecision != ini_get('precision')) { if ($this->_savedPrecision != ini_get('precision')) {
ini_set('precision',$this->_savedPrecision); ini_set('precision', $this->_savedPrecision);
} }
} }
@ -1963,7 +1963,7 @@ class PHPExcel_Calculation {
// Identify our locale and language // Identify our locale and language
$language = $locale = strtolower($locale); $language = $locale = strtolower($locale);
if (strpos($locale,'_') !== FALSE) { if (strpos($locale,'_') !== FALSE) {
list($language) = explode('_',$locale); list($language) = explode('_', $locale);
} }
if (count(self::$_validLocaleLanguages) == 1) if (count(self::$_validLocaleLanguages) == 1)
@ -1978,7 +1978,7 @@ class PHPExcel_Calculation {
// Default is English, if user isn't requesting english, then read the necessary data from the locale files // Default is English, if user isn't requesting english, then read the necessary data from the locale files
if ($locale != 'en_us') { if ($locale != 'en_us') {
// Search for a file with a list of function names for locale // Search for a file with a list of function names for locale
$functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'functions'; $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'functions';
if (!file_exists($functionNamesFile)) { if (!file_exists($functionNamesFile)) {
// If there isn't a locale specific function file, look for a language specific function file // If there isn't a locale specific function file, look for a language specific function file
$functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions'; $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions';
@ -1989,9 +1989,9 @@ class PHPExcel_Calculation {
// Retrieve the list of locale or language specific function names // Retrieve the list of locale or language specific function names
$localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeFunctions as $localeFunction) { foreach ($localeFunctions as $localeFunction) {
list($localeFunction) = explode('##',$localeFunction); // Strip out comments list($localeFunction) = explode('##', $localeFunction); // Strip out comments
if (strpos($localeFunction,'=') !== FALSE) { if (strpos($localeFunction,'=') !== FALSE) {
list($fName,$lfName) = explode('=',$localeFunction); list($fName, $lfName) = explode('=', $localeFunction);
$fName = trim($fName); $fName = trim($fName);
$lfName = trim($lfName); $lfName = trim($lfName);
if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) { if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
@ -2003,16 +2003,16 @@ class PHPExcel_Calculation {
if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; } if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; }
if (isset(self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; } if (isset(self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; }
$configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'config'; $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR, $locale).DIRECTORY_SEPARATOR.'config';
if (!file_exists($configFile)) { if (!file_exists($configFile)) {
$configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config'; $configFile = PHPEXCEL_ROOT . 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config';
} }
if (file_exists($configFile)) { if (file_exists($configFile)) {
$localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeSettings as $localeSetting) { foreach ($localeSettings as $localeSetting) {
list($localeSetting) = explode('##',$localeSetting); // Strip out comments list($localeSetting) = explode('##', $localeSetting); // Strip out comments
if (strpos($localeSetting,'=') !== FALSE) { if (strpos($localeSetting,'=') !== FALSE) {
list($settingName,$settingValue) = explode('=',$localeSetting); list($settingName, $settingValue) = explode('=', $localeSetting);
$settingName = strtoupper(trim($settingName)); $settingName = strtoupper(trim($settingName));
switch ($settingName) { switch ($settingName) {
case 'ARGUMENTSEPARATOR' : case 'ARGUMENTSEPARATOR' :
@ -2034,10 +2034,10 @@ class PHPExcel_Calculation {
public static function _translateSeparator($fromSeparator,$toSeparator,$formula,&$inBraces) { public static function _translateSeparator($fromSeparator, $toSeparator, $formula,&$inBraces) {
$strlen = mb_strlen($formula); $strlen = mb_strlen($formula);
for ($i = 0; $i < $strlen; ++$i) { for ($i = 0; $i < $strlen; ++$i) {
$chr = mb_substr($formula,$i,1); $chr = mb_substr($formula, $i,1);
switch ($chr) { switch ($chr) {
case '{' : $inBraces = TRUE; case '{' : $inBraces = TRUE;
break; break;
@ -2045,14 +2045,14 @@ class PHPExcel_Calculation {
break; break;
case $fromSeparator : case $fromSeparator :
if (!$inBraces) { if (!$inBraces) {
$formula = mb_substr($formula,0,$i).$toSeparator.mb_substr($formula,$i+1); $formula = mb_substr($formula,0, $i).$toSeparator.mb_substr($formula, $i+1);
} }
} }
} }
return $formula; return $formula;
} }
private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) { private static function _translateFormula($from, $to, $formula, $fromSeparator, $toSeparator) {
// Convert any Excel function names to the required language // Convert any Excel function names to the required language
if (self::$_localeLanguage !== 'en_us') { if (self::$_localeLanguage !== 'en_us') {
$inBraces = FALSE; $inBraces = FALSE;
@ -2060,22 +2060,22 @@ class PHPExcel_Calculation {
if (strpos($formula,'"') !== FALSE) { if (strpos($formula,'"') !== FALSE) {
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
// the formula // the formula
$temp = explode('"',$formula); $temp = explode('"', $formula);
$i = FALSE; $i = FALSE;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only count/replace in alternating array entries // Only count/replace in alternating array entries
if ($i = !$i) { if ($i = !$i) {
$value = preg_replace($from,$to,$value); $value = preg_replace($from, $to, $value);
$value = self::_translateSeparator($fromSeparator,$toSeparator,$value,$inBraces); $value = self::_translateSeparator($fromSeparator, $toSeparator, $value, $inBraces);
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$formula = implode('"',$temp); $formula = implode('"', $temp);
} else { } else {
// If there's no quoted strings, then we do a simple count/replace // If there's no quoted strings, then we do a simple count/replace
$formula = preg_replace($from,$to,$formula); $formula = preg_replace($from, $to, $formula);
$formula = self::_translateSeparator($fromSeparator,$toSeparator,$formula,$inBraces); $formula = self::_translateSeparator($fromSeparator, $toSeparator, $formula, $inBraces);
} }
} }
@ -2088,10 +2088,10 @@ class PHPExcel_Calculation {
public function _translateFormulaToLocale($formula) { public function _translateFormulaToLocale($formula) {
if (self::$functionReplaceFromExcel === NULL) { if (self::$functionReplaceFromExcel === NULL) {
self::$functionReplaceFromExcel = array(); self::$functionReplaceFromExcel = array();
foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) { foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) {
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui'; self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
} }
foreach(array_keys(self::$_localeBoolean) as $excelBoolean) { foreach (array_keys(self::$_localeBoolean) as $excelBoolean) {
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui'; self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
} }
@ -2099,15 +2099,15 @@ class PHPExcel_Calculation {
if (self::$functionReplaceToLocale === NULL) { if (self::$functionReplaceToLocale === NULL) {
self::$functionReplaceToLocale = array(); self::$functionReplaceToLocale = array();
foreach(array_values(self::$_localeFunctions) as $localeFunctionName) { foreach (array_values(self::$_localeFunctions) as $localeFunctionName) {
self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2'; self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
} }
foreach(array_values(self::$_localeBoolean) as $localeBoolean) { foreach (array_values(self::$_localeBoolean) as $localeBoolean) {
self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2'; self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2';
} }
} }
return self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale,$formula,',',self::$_localeArgumentSeparator); return self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale, $formula,',',self::$_localeArgumentSeparator);
} // function _translateFormulaToLocale() } // function _translateFormulaToLocale()
@ -2117,25 +2117,25 @@ class PHPExcel_Calculation {
public function _translateFormulaToEnglish($formula) { public function _translateFormulaToEnglish($formula) {
if (self::$functionReplaceFromLocale === NULL) { if (self::$functionReplaceFromLocale === NULL) {
self::$functionReplaceFromLocale = array(); self::$functionReplaceFromLocale = array();
foreach(array_values(self::$_localeFunctions) as $localeFunctionName) { foreach (array_values(self::$_localeFunctions) as $localeFunctionName) {
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui'; self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
} }
foreach(array_values(self::$_localeBoolean) as $excelBoolean) { foreach (array_values(self::$_localeBoolean) as $excelBoolean) {
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui'; self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
} }
} }
if (self::$functionReplaceToExcel === NULL) { if (self::$functionReplaceToExcel === NULL) {
self::$functionReplaceToExcel = array(); self::$functionReplaceToExcel = array();
foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) { foreach (array_keys(self::$_localeFunctions) as $excelFunctionName) {
self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2'; self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
} }
foreach(array_keys(self::$_localeBoolean) as $excelBoolean) { foreach (array_keys(self::$_localeBoolean) as $excelBoolean) {
self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2'; self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2';
} }
} }
return self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel,$formula,self::$_localeArgumentSeparator,','); return self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel, $formula,self::$_localeArgumentSeparator,',');
} // function _translateFormulaToEnglish() } // function _translateFormulaToEnglish()
@ -2170,7 +2170,7 @@ class PHPExcel_Calculation {
// Return strings wrapped in quotes // Return strings wrapped in quotes
return '"'.$value.'"'; return '"'.$value.'"';
// Convert numeric errors to NaN error // Convert numeric errors to NaN error
} else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { } else if ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
@ -2190,7 +2190,7 @@ class PHPExcel_Calculation {
return substr($value,1,-1); return substr($value,1,-1);
} }
// Convert numeric errors to NaN error // Convert numeric errors to NaN error
} else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) { } else if ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
return $value; return $value;
@ -2284,7 +2284,7 @@ class PHPExcel_Calculation {
if ($result === NULL) { if ($result === NULL) {
return 0; return 0;
} elseif((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) { } elseif ((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
return $result; return $result;
@ -2435,33 +2435,33 @@ class PHPExcel_Calculation {
* 1 = shrink to fit * 1 = shrink to fit
* 2 = extend to fit * 2 = extend to fit
*/ */
private static function _checkMatrixOperands(&$operand1,&$operand2,$resize = 1) { private static function _checkMatrixOperands(&$operand1,&$operand2, $resize = 1) {
// Examine each of the two operands, and turn them into an array if they aren't one already // Examine each of the two operands, and turn them into an array if they aren't one already
// Note that this function should only be called if one or both of the operand is already an array // Note that this function should only be called if one or both of the operand is already an array
if (!is_array($operand1)) { if (!is_array($operand1)) {
list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand2); list($matrixRows, $matrixColumns) = self::_getMatrixDimensions($operand2);
$operand1 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand1)); $operand1 = array_fill(0, $matrixRows,array_fill(0, $matrixColumns, $operand1));
$resize = 0; $resize = 0;
} elseif (!is_array($operand2)) { } elseif (!is_array($operand2)) {
list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand1); list($matrixRows, $matrixColumns) = self::_getMatrixDimensions($operand1);
$operand2 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand2)); $operand2 = array_fill(0, $matrixRows,array_fill(0, $matrixColumns, $operand2));
$resize = 0; $resize = 0;
} }
list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($operand1); list($matrix1Rows, $matrix1Columns) = self::_getMatrixDimensions($operand1);
list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($operand2); list($matrix2Rows, $matrix2Columns) = self::_getMatrixDimensions($operand2);
if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) { if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) {
$resize = 1; $resize = 1;
} }
if ($resize == 2) { if ($resize == 2) {
// Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger // Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger
self::_resizeMatricesExtend($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns); self::_resizeMatricesExtend($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns);
} elseif ($resize == 1) { } elseif ($resize == 1) {
// Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller // Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller
self::_resizeMatricesShrink($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns); self::_resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns);
} }
return array( $matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns); return array( $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns);
} // function _checkMatrixOperands() } // function _checkMatrixOperands()
@ -2474,8 +2474,8 @@ class PHPExcel_Calculation {
public static function _getMatrixDimensions(&$matrix) { public static function _getMatrixDimensions(&$matrix) {
$matrixRows = count($matrix); $matrixRows = count($matrix);
$matrixColumns = 0; $matrixColumns = 0;
foreach($matrix as $rowKey => $rowValue) { foreach ($matrix as $rowKey => $rowValue) {
$matrixColumns = max(count($rowValue),$matrixColumns); $matrixColumns = max(count($rowValue), $matrixColumns);
if (!is_array($rowValue)) { if (!is_array($rowValue)) {
$matrix[$rowKey] = array($rowValue); $matrix[$rowKey] = array($rowValue);
} else { } else {
@ -2483,7 +2483,7 @@ class PHPExcel_Calculation {
} }
} }
$matrix = array_values($matrix); $matrix = array_values($matrix);
return array($matrixRows,$matrixColumns); return array($matrixRows, $matrixColumns);
} // function _getMatrixDimensions() } // function _getMatrixDimensions()
@ -2497,7 +2497,7 @@ class PHPExcel_Calculation {
* @param integer $matrix2Rows Row size of second matrix operand * @param integer $matrix2Rows Row size of second matrix operand
* @param integer $matrix2Columns Column size of second matrix operand * @param integer $matrix2Columns Column size of second matrix operand
*/ */
private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { private static function _resizeMatricesShrink(&$matrix1,&$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Rows < $matrix1Rows) { if ($matrix2Rows < $matrix1Rows) {
for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) { for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) {
@ -2540,7 +2540,7 @@ class PHPExcel_Calculation {
* @param integer $matrix2Rows Row size of second matrix operand * @param integer $matrix2Rows Row size of second matrix operand
* @param integer $matrix2Columns Column size of second matrix operand * @param integer $matrix2Columns Column size of second matrix operand
*/ */
private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) { private static function _resizeMatricesExtend(&$matrix1,&$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns) {
if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
if ($matrix2Columns < $matrix1Columns) { if ($matrix2Columns < $matrix1Columns) {
for ($i = 0; $i < $matrix2Rows; ++$i) { for ($i = 0; $i < $matrix2Rows; ++$i) {
@ -2593,18 +2593,18 @@ class PHPExcel_Calculation {
if (is_array($value)) { if (is_array($value)) {
$returnMatrix = array(); $returnMatrix = array();
$pad = $rpad = ', '; $pad = $rpad = ', ';
foreach($value as $row) { foreach ($value as $row) {
if (is_array($row)) { if (is_array($row)) {
$returnMatrix[] = implode($pad,array_map(array($this,'_showValue'),$row)); $returnMatrix[] = implode($pad,array_map(array($this,'_showValue'), $row));
$rpad = '; '; $rpad = '; ';
} else { } else {
$returnMatrix[] = $this->_showValue($row); $returnMatrix[] = $this->_showValue($row);
} }
} }
return '{ '.implode($rpad,$returnMatrix).' }'; return '{ '.implode($rpad, $returnMatrix).' }';
} elseif(is_string($value) && (trim($value,'"') == $value)) { } elseif (is_string($value) && (trim($value,'"') == $value)) {
return '"'.$value.'"'; return '"'.$value.'"';
} elseif(is_bool($value)) { } elseif (is_bool($value)) {
return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE']; return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
} }
} }
@ -2629,11 +2629,11 @@ class PHPExcel_Calculation {
return 'a NULL value'; return 'a NULL value';
} elseif (is_float($value)) { } elseif (is_float($value)) {
$typeString = 'a floating point number'; $typeString = 'a floating point number';
} elseif(is_int($value)) { } elseif (is_int($value)) {
$typeString = 'an integer number'; $typeString = 'an integer number';
} elseif(is_bool($value)) { } elseif (is_bool($value)) {
$typeString = 'a boolean'; $typeString = 'a boolean';
} elseif(is_array($value)) { } elseif (is_array($value)) {
$typeString = 'a matrix'; $typeString = 'a matrix';
} else { } else {
if ($value == '') { if ($value == '') {
@ -2659,26 +2659,26 @@ class PHPExcel_Calculation {
if (strpos($formula,'"') !== FALSE) { if (strpos($formula,'"') !== FALSE) {
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
// the formula // the formula
$temp = explode('"',$formula); $temp = explode('"', $formula);
// Open and Closed counts used for trapping mismatched braces in the formula // Open and Closed counts used for trapping mismatched braces in the formula
$openCount = $closeCount = 0; $openCount = $closeCount = 0;
$i = FALSE; $i = FALSE;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only count/replace in alternating array entries // Only count/replace in alternating array entries
if ($i = !$i) { if ($i = !$i) {
$openCount += substr_count($value,'{'); $openCount += substr_count($value,'{');
$closeCount += substr_count($value,'}'); $closeCount += substr_count($value,'}');
$value = str_replace($matrixReplaceFrom,$matrixReplaceTo,$value); $value = str_replace($matrixReplaceFrom, $matrixReplaceTo, $value);
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$formula = implode('"',$temp); $formula = implode('"', $temp);
} else { } else {
// If there's no quoted strings, then we do a simple count/replace // If there's no quoted strings, then we do a simple count/replace
$openCount = substr_count($formula,'{'); $openCount = substr_count($formula,'{');
$closeCount = substr_count($formula,'}'); $closeCount = substr_count($formula,'}');
$formula = str_replace($matrixReplaceFrom,$matrixReplaceTo,$formula); $formula = str_replace($matrixReplaceFrom, $matrixReplaceTo, $formula);
} }
// Trap for mismatched braces and trigger an appropriate error // Trap for mismatched braces and trigger an appropriate error
if ($openCount < $closeCount) { if ($openCount < $closeCount) {
@ -2765,7 +2765,7 @@ class PHPExcel_Calculation {
// should be null in a function call // should be null in a function call
// The guts of the lexical parser // The guts of the lexical parser
// Loop through the formula extracting each operator and operand in turn // Loop through the formula extracting each operator and operand in turn
while(TRUE) { while (TRUE) {
//echo 'Assessing Expression '.substr($formula, $index),PHP_EOL; //echo 'Assessing Expression '.substr($formula, $index),PHP_EOL;
$opCharacter = $formula{$index}; // Get the first character of the value at the current index position $opCharacter = $formula{$index}; // Get the first character of the value at the current index position
//echo 'Initial character of expression block is '.$opCharacter,PHP_EOL; //echo 'Initial character of expression block is '.$opCharacter,PHP_EOL;
@ -2795,13 +2795,13 @@ class PHPExcel_Calculation {
} elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? } elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
//echo 'Element with value '.$opCharacter.' is an Operator',PHP_EOL; //echo 'Element with value '.$opCharacter.' is an Operator',PHP_EOL;
while($stack->count() > 0 && while ($stack->count() > 0 &&
($o2 = $stack->last()) && ($o2 = $stack->last()) &&
isset(self::$_operators[$o2['value']]) && isset(self::$_operators[$o2['value']]) &&
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) { @(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
} }
$stack->push('Binary Operator',$opCharacter); // Finally put our current operator onto the stack $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack
++$index; ++$index;
$expectingOperator = FALSE; $expectingOperator = FALSE;
@ -2855,7 +2855,7 @@ class PHPExcel_Calculation {
} }
} }
} elseif ($expectedArgumentCount != '*') { } elseif ($expectedArgumentCount != '*') {
$isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch); $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/', $expectedArgumentCount, $argMatch);
//print_r($argMatch); //print_r($argMatch);
//echo PHP_EOL; //echo PHP_EOL;
switch ($argMatch[2]) { switch ($argMatch[2]) {
@ -2901,7 +2901,7 @@ class PHPExcel_Calculation {
if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches))
return $this->_raiseFormulaError("Formula Error: Unexpected ,"); return $this->_raiseFormulaError("Formula Error: Unexpected ,");
$d = $stack->pop(); $d = $stack->pop();
$stack->push($d['type'],++$d['value'],$d['reference']); // increment the argument count $stack->push($d['type'],++$d['value'], $d['reference']); // increment the argument count
$stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again
$expectingOperator = FALSE; $expectingOperator = FALSE;
$expectingOperand = TRUE; $expectingOperand = TRUE;
@ -2920,7 +2920,7 @@ class PHPExcel_Calculation {
// echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function<br />'; // echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function<br />';
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) { if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
$val = preg_replace('/\s/u','',$val); $val = preg_replace('/\s/u','', $val);
// echo 'Element '.$val.' is a Function<br />'; // echo 'Element '.$val.' is a Function<br />';
if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) { // it's a function
$stack->push('Function', strtoupper($val)); $stack->push('Function', strtoupper($val));
@ -2967,13 +2967,13 @@ class PHPExcel_Calculation {
if ($testPrevOp['value'] == ':') { if ($testPrevOp['value'] == ':') {
$startRowColRef = $output[count($output)-1]['value']; $startRowColRef = $output[count($output)-1]['value'];
$rangeWS1 = ''; $rangeWS1 = '';
if (strpos('!',$startRowColRef) !== FALSE) { if (strpos('!', $startRowColRef) !== FALSE) {
list($rangeWS1,$startRowColRef) = explode('!',$startRowColRef); list($rangeWS1, $startRowColRef) = explode('!', $startRowColRef);
} }
if ($rangeWS1 != '') $rangeWS1 .= '!'; if ($rangeWS1 != '') $rangeWS1 .= '!';
$rangeWS2 = $rangeWS1; $rangeWS2 = $rangeWS1;
if (strpos('!',$val) !== FALSE) { if (strpos('!', $val) !== FALSE) {
list($rangeWS2,$val) = explode('!',$val); list($rangeWS2, $val) = explode('!', $val);
} }
if ($rangeWS2 != '') $rangeWS2 .= '!'; if ($rangeWS2 != '') $rangeWS2 .= '!';
if ((is_integer($startRowColRef)) && (ctype_digit($val)) && if ((is_integer($startRowColRef)) && (ctype_digit($val)) &&
@ -3058,7 +3058,7 @@ class PHPExcel_Calculation {
if (($expectingOperator) && (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'.*/Ui', substr($formula, $index), $match)) && if (($expectingOperator) && (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'.*/Ui', substr($formula, $index), $match)) &&
($output[count($output)-1]['type'] == 'Cell Reference')) { ($output[count($output)-1]['type'] == 'Cell Reference')) {
// echo 'Element is an Intersect Operator<br />'; // echo 'Element is an Intersect Operator<br />';
while($stack->count() > 0 && while ($stack->count() > 0 &&
($o2 = $stack->last()) && ($o2 = $stack->last()) &&
isset(self::$_operators[$o2['value']]) && isset(self::$_operators[$o2['value']]) &&
@(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) { @(self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
@ -3136,18 +3136,18 @@ class PHPExcel_Calculation {
case '<=' : // Less than or Equal to case '<=' : // Less than or Equal to
case '=' : // Equality case '=' : // Equality
case '<>' : // Inequality case '<>' : // Inequality
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operand2,$token,$stack); $this->_executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack);
break; break;
// Binary Operators // Binary Operators
case ':' : // Range case ':' : // Range
$sheet1 = $sheet2 = ''; $sheet1 = $sheet2 = '';
if (strpos($operand1Data['reference'],'!') !== FALSE) { if (strpos($operand1Data['reference'],'!') !== FALSE) {
list($sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']); list($sheet1, $operand1Data['reference']) = explode('!', $operand1Data['reference']);
} else { } else {
$sheet1 = ($pCellParent !== NULL) ? $pCellWorksheet->getTitle() : ''; $sheet1 = ($pCellParent !== NULL) ? $pCellWorksheet->getTitle() : '';
} }
if (strpos($operand2Data['reference'],'!') !== FALSE) { if (strpos($operand2Data['reference'],'!') !== FALSE) {
list($sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']); list($sheet2, $operand2Data['reference']) = explode('!', $operand2Data['reference']);
} else { } else {
$sheet2 = $sheet1; $sheet2 = $sheet1;
} }
@ -3171,9 +3171,9 @@ class PHPExcel_Calculation {
} }
} }
$oData = array_merge(explode(':',$operand1Data['reference']),explode(':',$operand2Data['reference'])); $oData = array_merge(explode(':', $operand1Data['reference']),explode(':', $operand2Data['reference']));
$oCol = $oRow = array(); $oCol = $oRow = array();
foreach($oData as $oDatum) { foreach ($oData as $oDatum) {
$oCR = PHPExcel_Cell::coordinateFromString($oDatum); $oCR = PHPExcel_Cell::coordinateFromString($oDatum);
$oCol[] = PHPExcel_Cell::columnIndexFromString($oCR[0]) - 1; $oCol[] = PHPExcel_Cell::columnIndexFromString($oCR[0]) - 1;
$oRow[] = $oCR[1]; $oRow[] = $oCR[1];
@ -3184,26 +3184,26 @@ class PHPExcel_Calculation {
} else { } else {
return $this->_raiseFormulaError('Unable to access Cell Reference'); return $this->_raiseFormulaError('Unable to access Cell Reference');
} }
$stack->push('Cell Reference',$cellValue,$cellRef); $stack->push('Cell Reference', $cellValue, $cellRef);
} else { } else {
$stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL); $stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL);
} }
break; break;
case '+' : // Addition case '+' : // Addition
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'plusEquals',$stack); $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token,'plusEquals', $stack);
break; break;
case '-' : // Subtraction case '-' : // Subtraction
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'minusEquals',$stack); $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token,'minusEquals', $stack);
break; break;
case '*' : // Multiplication case '*' : // Multiplication
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayTimesEquals',$stack); $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token,'arrayTimesEquals', $stack);
break; break;
case '/' : // Division case '/' : // Division
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayRightDivide',$stack); $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token,'arrayRightDivide', $stack);
break; break;
case '^' : // Exponential case '^' : // Exponential
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'power',$stack); $this->_executeNumericBinaryOperation($cellID, $operand1, $operand2, $token,'power', $stack);
break; break;
case '&' : // Concatenation case '&' : // Concatenation
// If either of the operands is a matrix, we need to treat them both as matrices // If either of the operands is a matrix, we need to treat them both as matrices
@ -3217,7 +3217,7 @@ class PHPExcel_Calculation {
} }
if ((is_array($operand1)) || (is_array($operand2))) { if ((is_array($operand1)) || (is_array($operand2))) {
// Ensure that both operands are arrays/matrices // Ensure that both operands are arrays/matrices
self::_checkMatrixOperands($operand1,$operand2,2); self::_checkMatrixOperands($operand1, $operand2,2);
try { try {
// Convert operand 1 from a PHP array to a matrix // Convert operand 1 from a PHP array to a matrix
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1); $matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
@ -3232,21 +3232,21 @@ class PHPExcel_Calculation {
$result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"'; $result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"';
} }
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
$stack->push('Value',$result); $stack->push('Value', $result);
break; break;
case '|' : // Intersect case '|' : // Intersect
$rowIntersect = array_intersect_key($operand1,$operand2); $rowIntersect = array_intersect_key($operand1, $operand2);
$cellIntersect = $oCol = $oRow = array(); $cellIntersect = $oCol = $oRow = array();
foreach(array_keys($rowIntersect) as $row) { foreach (array_keys($rowIntersect) as $row) {
$oRow[] = $row; $oRow[] = $row;
foreach($rowIntersect[$row] as $col => $data) { foreach ($rowIntersect[$row] as $col => $data) {
$oCol[] = PHPExcel_Cell::columnIndexFromString($col) - 1; $oCol[] = PHPExcel_Cell::columnIndexFromString($col) - 1;
$cellIntersect[$row] = array_intersect_key($operand1[$row],$operand2[$row]); $cellIntersect[$row] = array_intersect_key($operand1[$row], $operand2[$row]);
} }
} }
$cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow); $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($cellIntersect)); $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($cellIntersect));
$stack->push('Value',$cellIntersect,$cellRef); $stack->push('Value', $cellIntersect, $cellRef);
break; break;
} }
@ -3265,7 +3265,7 @@ class PHPExcel_Calculation {
$multiplier = 0.01; $multiplier = 0.01;
} }
if (is_array($arg)) { if (is_array($arg)) {
self::_checkMatrixOperands($arg,$multiplier,2); self::_checkMatrixOperands($arg, $multiplier,2);
try { try {
$matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg); $matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg);
$matrixResult = $matrix1->arrayTimesEquals($multiplier); $matrixResult = $matrix1->arrayTimesEquals($multiplier);
@ -3275,9 +3275,9 @@ class PHPExcel_Calculation {
$result = '#VALUE!'; $result = '#VALUE!';
} }
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
$stack->push('Value',$result); $stack->push('Value', $result);
} else { } else {
$this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack); $this->_executeNumericBinaryOperation($cellID, $multiplier, $arg,'*','arrayTimesEquals', $stack);
} }
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) { } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) {
@ -3358,7 +3358,7 @@ class PHPExcel_Calculation {
} }
} }
} }
$stack->push('Value',$cellValue,$cellRef); $stack->push('Value', $cellValue, $cellRef);
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $token, $matches)) { } elseif (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $token, $matches)) {
@ -3421,18 +3421,18 @@ class PHPExcel_Calculation {
// $this->_debugLog->writeDebugLog('Argument is a matrix: ', $this->_showValue($operand1)); // $this->_debugLog->writeDebugLog('Argument is a matrix: ', $this->_showValue($operand1));
// $result = array(); // $result = array();
// $row = 0; // $row = 0;
// foreach($operand1 as $args) { // foreach ($operand1 as $args) {
// if (is_array($args)) { // if (is_array($args)) {
// foreach($args as $arg) { // foreach ($args as $arg) {
// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($arg), ' )'); // $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($arg), ' )');
// $r = call_user_func_array($functionCall,$arg); // $r = call_user_func_array($functionCall, $arg);
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r)); // $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
// $result[$row][] = $r; // $result[$row][] = $r;
// } // }
// ++$row; // ++$row;
// } else { // } else {
// $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($args), ' )'); // $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($args), ' )');
// $r = call_user_func_array($functionCall,$args); // $r = call_user_func_array($functionCall, $args);
// $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r)); // $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
// $result[] = $r; // $result[] = $r;
// } // }
@ -3443,13 +3443,13 @@ class PHPExcel_Calculation {
$args[] = $pCell; $args[] = $pCell;
} }
if (strpos($functionCall,'::') !== FALSE) { if (strpos($functionCall,'::') !== FALSE) {
$result = call_user_func_array(explode('::',$functionCall),$args); $result = call_user_func_array(explode('::', $functionCall), $args);
} else { } else {
foreach($args as &$arg) { foreach ($args as &$arg) {
$arg = PHPExcel_Calculation_Functions::flattenSingleValue($arg); $arg = PHPExcel_Calculation_Functions::flattenSingleValue($arg);
} }
unset($arg); unset($arg);
$result = call_user_func_array($functionCall,$args); $result = call_user_func_array($functionCall, $args);
} }
// } // }
if ($functionName != 'MKMATRIX') { if ($functionName != 'MKMATRIX') {
@ -3467,7 +3467,7 @@ class PHPExcel_Calculation {
$this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->_showTypeDetails(self::$_ExcelConstants[$excelConstant])); $this->_debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
} elseif ((is_numeric($token)) || ($token === NULL) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) { } elseif ((is_numeric($token)) || ($token === NULL) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
// echo 'Token is a number, boolean, string, null or an Excel error<br />'; // echo 'Token is a number, boolean, string, null or an Excel error<br />';
$stack->push('Value',$token); $stack->push('Value', $token);
// if the token is a named range, push the named range name onto the stack // if the token is a named range, push the named range name onto the stack
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $token, $matches)) { } elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $token, $matches)) {
// echo 'Token is a named range<br />'; // echo 'Token is a named range<br />';
@ -3477,7 +3477,7 @@ class PHPExcel_Calculation {
$cellValue = $this->extractNamedRange($namedRange, ((NULL !== $pCell) ? $pCellWorksheet : NULL), FALSE); $cellValue = $this->extractNamedRange($namedRange, ((NULL !== $pCell) ? $pCellWorksheet : NULL), FALSE);
$pCell->attach($pCellParent); $pCell->attach($pCellParent);
$this->_debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->_showTypeDetails($cellValue)); $this->_debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->_showTypeDetails($cellValue));
$stack->push('Named Range',$cellValue,$namedRange); $stack->push('Named Range', $cellValue, $namedRange);
} else { } else {
return $this->_raiseFormulaError("undefined variable '$token'"); return $this->_raiseFormulaError("undefined variable '$token'");
} }
@ -3534,24 +3534,24 @@ class PHPExcel_Calculation {
if ((is_array($operand1)) || (is_array($operand2))) { if ((is_array($operand1)) || (is_array($operand2))) {
$result = array(); $result = array();
if ((is_array($operand1)) && (!is_array($operand2))) { if ((is_array($operand1)) && (!is_array($operand2))) {
foreach($operand1 as $x => $operandData) { foreach ($operand1 as $x => $operandData) {
$this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2)); $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2));
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack); $this->_executeBinaryComparisonOperation($cellID, $operandData, $operand2, $operation, $stack);
$r = $stack->pop(); $r = $stack->pop();
$result[$x] = $r['value']; $result[$x] = $r['value'];
} }
} elseif ((!is_array($operand1)) && (is_array($operand2))) { } elseif ((!is_array($operand1)) && (is_array($operand2))) {
foreach($operand2 as $x => $operandData) { foreach ($operand2 as $x => $operandData) {
$this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operand1), ' ', $operation, ' ', $this->_showValue($operandData)); $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operand1), ' ', $operation, ' ', $this->_showValue($operandData));
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack); $this->_executeBinaryComparisonOperation($cellID, $operand1, $operandData, $operation, $stack);
$r = $stack->pop(); $r = $stack->pop();
$result[$x] = $r['value']; $result[$x] = $r['value'];
} }
} else { } else {
if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); } if (!$recursingArrays) { self::_checkMatrixOperands($operand1, $operand2,2); }
foreach($operand1 as $x => $operandData) { foreach ($operand1 as $x => $operandData) {
$this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2[$x])); $this->_debugLog->writeDebugLog('Evaluating Comparison ', $this->_showValue($operandData), ' ', $operation, ' ', $this->_showValue($operand2[$x]));
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,TRUE); $this->_executeBinaryComparisonOperation($cellID, $operandData, $operand2[$x], $operation, $stack,TRUE);
$r = $stack->pop(); $r = $stack->pop();
$result[$x] = $r['value']; $result[$x] = $r['value'];
} }
@ -3559,7 +3559,7 @@ class PHPExcel_Calculation {
// Log the result details // Log the result details
$this->_debugLog->writeDebugLog('Comparison Evaluation Result is ', $this->_showTypeDetails($result)); $this->_debugLog->writeDebugLog('Comparison Evaluation Result is ', $this->_showTypeDetails($result));
// And push the result onto the stack // And push the result onto the stack
$stack->push('Array',$result); $stack->push('Array', $result);
return TRUE; return TRUE;
} }
@ -3640,7 +3640,7 @@ class PHPExcel_Calculation {
// Log the result details // Log the result details
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
// And push the result onto the stack // And push the result onto the stack
$stack->push('Value',$result); $stack->push('Value', $result);
return true; return true;
} }
@ -3658,10 +3658,10 @@ class PHPExcel_Calculation {
return strcmp($inversedStr1, $inversedStr2); return strcmp($inversedStr1, $inversedStr2);
} }
private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) { private function _executeNumericBinaryOperation($cellID, $operand1, $operand2, $operation, $matrixFunction,&$stack) {
// Validate the two operands // Validate the two operands
if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return FALSE; if (!$this->_validateBinaryOperand($cellID, $operand1, $stack)) return FALSE;
if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return FALSE; if (!$this->_validateBinaryOperand($cellID, $operand2, $stack)) return FALSE;
// If either of the operands is a matrix, we need to treat them both as matrices // If either of the operands is a matrix, we need to treat them both as matrices
// (converting the other operand to a matrix if need be); then perform the required // (converting the other operand to a matrix if need be); then perform the required
@ -3722,7 +3722,7 @@ class PHPExcel_Calculation {
// Log the result details // Log the result details
$this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result)); $this->_debugLog->writeDebugLog('Evaluation Result is ', $this->_showTypeDetails($result));
// And push the result onto the stack // And push the result onto the stack
$stack->push('Value',$result); $stack->push('Value', $result);
return TRUE; return TRUE;
} // function _executeNumericBinaryOperation() } // function _executeNumericBinaryOperation()
@ -3756,7 +3756,7 @@ class PHPExcel_Calculation {
// echo 'Range reference is '.$pRange.PHP_EOL; // echo 'Range reference is '.$pRange.PHP_EOL;
if (strpos ($pRange, '!') !== false) { if (strpos ($pRange, '!') !== false) {
// echo '$pRange reference includes sheet reference',PHP_EOL; // echo '$pRange reference includes sheet reference',PHP_EOL;
list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true); list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
// echo 'New sheet name is '.$pSheetName,PHP_EOL; // echo 'New sheet name is '.$pSheetName,PHP_EOL;
// echo 'Adjusted Range reference is '.$pRange,PHP_EOL; // echo 'Adjusted Range reference is '.$pRange,PHP_EOL;
$pSheet = $this->_workbook->getSheetByName($pSheetName); $pSheet = $this->_workbook->getSheetByName($pSheetName);
@ -3814,7 +3814,7 @@ class PHPExcel_Calculation {
// echo 'Range reference is '.$pRange.'<br />'; // echo 'Range reference is '.$pRange.'<br />';
if (strpos ($pRange, '!') !== false) { if (strpos ($pRange, '!') !== false) {
// echo '$pRange reference includes sheet reference',PHP_EOL; // echo '$pRange reference includes sheet reference',PHP_EOL;
list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true); list($pSheetName, $pRange) = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
// echo 'New sheet name is '.$pSheetName,PHP_EOL; // echo 'New sheet name is '.$pSheetName,PHP_EOL;
// echo 'Adjusted Range reference is '.$pRange,PHP_EOL; // echo 'Adjusted Range reference is '.$pRange,PHP_EOL;
$pSheet = $this->_workbook->getSheetByName($pSheetName); $pSheet = $this->_workbook->getSheetByName($pSheetName);
@ -3830,7 +3830,7 @@ class PHPExcel_Calculation {
// Convert row and column references // Convert row and column references
if (ctype_alpha($splitRange[0][0])) { if (ctype_alpha($splitRange[0][0])) {
$pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow(); $pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
} elseif(ctype_digit($splitRange[0][0])) { } elseif (ctype_digit($splitRange[0][0])) {
$pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1]; $pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
} }
// echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'<br />'; // echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'<br />';
@ -3851,7 +3851,7 @@ class PHPExcel_Calculation {
// var_dump($aReferences); // var_dump($aReferences);
if (!isset($aReferences[1])) { if (!isset($aReferences[1])) {
// Single cell (or single column or row) in range // Single cell (or single column or row) in range
list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]); list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
$cellValue = NULL; $cellValue = NULL;
if ($pSheet->cellExists($aReferences[0])) { if ($pSheet->cellExists($aReferences[0])) {
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog); $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
@ -3862,7 +3862,7 @@ class PHPExcel_Calculation {
// Extract cell data for all cells in the range // Extract cell data for all cells in the range
foreach ($aReferences as $reference) { foreach ($aReferences as $reference) {
// Extract range // Extract range
list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference); list($currentCol, $currentRow) = PHPExcel_Cell::coordinateFromString($reference);
// echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'<br />'; // echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'<br />';
$cellValue = NULL; $cellValue = NULL;
if ($pSheet->cellExists($reference)) { if ($pSheet->cellExists($reference)) {
@ -3906,7 +3906,7 @@ class PHPExcel_Calculation {
// Return value // Return value
$returnValue = array(); $returnValue = array();
// Loop functions // Loop functions
foreach(self::$_PHPExcelFunctions as $functionName => $function) { foreach (self::$_PHPExcelFunctions as $functionName => $function) {
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') { if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
$returnValue[$functionName] = new PHPExcel_Calculation_Function($function['category'], $returnValue[$functionName] = new PHPExcel_Calculation_Function($function['category'],
$functionName, $functionName,
@ -3938,7 +3938,7 @@ class PHPExcel_Calculation {
// Return value // Return value
$returnValue = array(); $returnValue = array();
// Loop functions // Loop functions
foreach(self::$_PHPExcelFunctions as $functionName => $function) { foreach (self::$_PHPExcelFunctions as $functionName => $function) {
if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') { if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
$returnValue[] = $functionName; $returnValue[] = $functionName;
} }

View File

@ -847,7 +847,7 @@ class PHPExcel_Calculation_DateTime
} }
if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) { if (((is_numeric($method)) && (!is_string($method))) || ($method == '')) {
switch($method) { switch ($method) {
case 0: case 0:
return self::DAYS360($startDate, $endDate) / 360; return self::DAYS360($startDate, $endDate) / 360;
case 1: case 1:

View File

@ -1019,7 +1019,7 @@ class PHPExcel_Calculation_Engineering
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
switch(floor($ord)) { switch (floor($ord)) {
case 0: case 0:
return self::besselK0($x); return self::besselK0($x);
case 1: case 1:
@ -1103,7 +1103,7 @@ class PHPExcel_Calculation_Engineering
return PHPExcel_Calculation_Functions::NaN(); return PHPExcel_Calculation_Functions::NaN();
} }
switch(floor($ord)) { switch (floor($ord)) {
case 0: case 0:
return self::besselY0($x); return self::besselY0($x);
case 1: case 1:

View File

@ -1120,7 +1120,7 @@ class PHPExcel_Calculation_MathTrig
$subtotal = array_shift($aArgs); $subtotal = array_shift($aArgs);
if ((is_numeric($subtotal)) && (!is_string($subtotal))) { if ((is_numeric($subtotal)) && (!is_string($subtotal))) {
switch($subtotal) { switch ($subtotal) {
case 1: case 1:
return PHPExcel_Calculation_Statistical::AVERAGE($aArgs); return PHPExcel_Calculation_Statistical::AVERAGE($aArgs);
case 2: case 2:

View File

@ -3452,7 +3452,7 @@ class PHPExcel_Calculation_Statistical
* of a data set. * of a data set.
* *
* Excel Function: * Excel Function:
* TRIMEAN(value1[,value2[, ...]],$discard) * TRIMEAN(value1[,value2[, ...]], $discard)
* *
* @access public * @access public
* @category Statistical Functions * @category Statistical Functions

View File

@ -584,7 +584,7 @@ class PHPExcel_Cell
public static function coordinateFromString($pCoordinateString = 'A1') public static function coordinateFromString($pCoordinateString = 'A1')
{ {
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 == '') {

View File

@ -90,33 +90,33 @@ class PHPExcel_Chart
*/ */
private $_displayBlanksAs = '0'; private $_displayBlanksAs = '0';
/** /**
* Chart Asix Y as * Chart Asix Y as
* *
* @var PHPExcel_Chart_Axis * @var PHPExcel_Chart_Axis
*/ */
private $_yAxis = null; private $_yAxis = null;
/** /**
* Chart Asix X as * Chart Asix X as
* *
* @var PHPExcel_Chart_Axis * @var PHPExcel_Chart_Axis
*/ */
private $_xAxis = null; private $_xAxis = null;
/** /**
* Chart Major Gridlines as * Chart Major Gridlines as
* *
* @var PHPExcel_Chart_GridLines * @var PHPExcel_Chart_GridLines
*/ */
private $_majorGridlines = null; private $_majorGridlines = null;
/** /**
* Chart Minor Gridlines as * Chart Minor Gridlines as
* *
* @var PHPExcel_Chart_GridLines * @var PHPExcel_Chart_GridLines
*/ */
private $_minorGridlines = null; private $_minorGridlines = null;
/** /**
* Top-Left Cell Position * Top-Left Cell Position
@ -304,7 +304,8 @@ class PHPExcel_Chart
* @param PHPExcel_Chart_Title $label * @param PHPExcel_Chart_Title $label
* @return PHPExcel_Chart * @return PHPExcel_Chart
*/ */
public function setYAxisLabel(PHPExcel_Chart_Title $label) { public function setYAxisLabel(PHPExcel_Chart_Title $label)
{
$this->_yAxisLabel = $label; $this->_yAxisLabel = $label;
return $this; return $this;
@ -365,62 +366,62 @@ class PHPExcel_Chart
} }
/** /**
* Get yAxis * Get yAxis
* *
* @return PHPExcel_Chart_Axis * @return PHPExcel_Chart_Axis
*/ */
public function getChartAxisY() public function getChartAxisY()
{ {
if ($this->_yAxis !== null) { if ($this->_yAxis !== null) {
return $this->_yAxis; return $this->_yAxis;
}
return new PHPExcel_Chart_Axis();
} }
return new PHPExcel_Chart_Axis(); /**
} * Get xAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisX()
{
if ($this->_xAxis !== null) {
return $this->_xAxis;
}
/** return new PHPExcel_Chart_Axis();
* Get xAxis
*
* @return PHPExcel_Chart_Axis
*/
public function getChartAxisX()
{
if ($this->_xAxis !== null) {
return $this->_xAxis;
} }
return new PHPExcel_Chart_Axis(); /**
} * Get Major Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMajorGridlines()
{
if ($this->_majorGridlines !== null) {
return $this->_majorGridlines;
}
/** return new PHPExcel_Chart_GridLines();
* Get Major Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMajorGridlines()
{
if ($this->_majorGridlines !== null) {
return $this->_majorGridlines;
} }
return new PHPExcel_Chart_GridLines(); /**
} * Get Minor Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMinorGridlines()
{
if ($this->_minorGridlines !== null) {
return $this->_minorGridlines;
}
/** return new PHPExcel_Chart_GridLines();
* Get Minor Gridlines
*
* @return PHPExcel_Chart_GridLines
*/
public function getMinorGridlines()
{
if ($this->_minorGridlines !== null) {
return $this->_minorGridlines;
} }
return new PHPExcel_Chart_GridLines();
}
/** /**
* Set the Top Left position for the chart * Set the Top Left position for the chart
@ -430,7 +431,7 @@ class PHPExcel_Chart
* @param integer $yOffset * @param integer $yOffset
* @return PHPExcel_Chart * @return PHPExcel_Chart
*/ */
public function setTopLeftPosition($cell, $xOffset=null, $yOffset=null) public function setTopLeftPosition($cell, $xOffset = null, $yOffset = null)
{ {
$this->_topLeftCellRef = $cell; $this->_topLeftCellRef = $cell;
if (!is_null($xOffset)) { if (!is_null($xOffset)) {
@ -662,9 +663,9 @@ class PHPExcel_Chart
$this->refresh(); $this->refresh();
$libraryPath = PHPExcel_Settings::getChartRendererPath(); $libraryPath = PHPExcel_Settings::getChartRendererPath();
$includePath = str_replace('\\','/',get_include_path()); $includePath = str_replace('\\', '/', get_include_path());
$rendererPath = str_replace('\\','/',$libraryPath); $rendererPath = str_replace('\\', '/', $libraryPath);
if (strpos($rendererPath,$includePath) === false) { if (strpos($rendererPath, $includePath) === false) {
set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath); set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
} }

View File

@ -371,17 +371,17 @@ class PHPExcel_Chart_DataSeries
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

@ -215,7 +215,7 @@ class PHPExcel_Chart_DataSeriesValues
*/ */
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;
@ -281,31 +281,31 @@ class PHPExcel_Chart_DataSeriesValues
); );
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;

View File

@ -71,7 +71,7 @@ class PHPExcel_Chart_Renderer_jpgraph
private static $_plotMark = 0; private static $_plotMark = 0;
private function _formatPointMarker($seriesPlot,$markerID) { private function _formatPointMarker($seriesPlot, $markerID) {
$plotMarkKeys = array_keys(self::$_markSet); $plotMarkKeys = array_keys(self::$_markSet);
if (is_null($markerID)) { if (is_null($markerID)) {
// Use default plot marker (next marker in the series) // Use default plot marker (next marker in the series)
@ -106,18 +106,18 @@ class PHPExcel_Chart_Renderer_jpgraph
} }
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($datasetLabels as $i => $datasetLabel) { foreach ($datasetLabels as $i => $datasetLabel) {
if (is_array($datasetLabel)) { if (is_array($datasetLabel)) {
if ($rotation == 'bar') { if ($rotation == 'bar') {
$datasetLabels[$i] = implode(" ",$datasetLabel); $datasetLabels[$i] = implode(" ", $datasetLabel);
} else { } else {
$datasetLabel = array_reverse($datasetLabel); $datasetLabel = array_reverse($datasetLabel);
$datasetLabels[$i] = implode("\n",$datasetLabel); $datasetLabels[$i] = implode("\n", $datasetLabel);
} }
} else { } else {
// Format labels according to any formatting code // Format labels according to any formatting code
if (!is_null($datasetLabelFormatCode)) { if (!is_null($datasetLabelFormatCode)) {
$datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel,$datasetLabelFormatCode); $datasetLabels[$i] = PHPExcel_Style_NumberFormat::toFormattedString($datasetLabel, $datasetLabelFormatCode);
} }
} }
++$testCurrentIndex; ++$testCurrentIndex;
@ -127,14 +127,14 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _formatDataSetLabels() } // function _formatDataSetLabels()
private function _percentageSumCalculation($groupID,$seriesCount) { private function _percentageSumCalculation($groupID, $seriesCount) {
// Adjust our values to a percentage value across all series in the group // Adjust our values to a percentage value across all series in the group
for($i = 0; $i < $seriesCount; ++$i) { for($i = 0; $i < $seriesCount; ++$i) {
if ($i == 0) { if ($i == 0) {
$sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); $sumValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
} else { } else {
$nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); $nextValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
foreach($nextValues as $k => $value) { foreach ($nextValues as $k => $value) {
if (isset($sumValues[$k])) { if (isset($sumValues[$k])) {
$sumValues[$k] += $value; $sumValues[$k] += $value;
} else { } else {
@ -148,8 +148,8 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _percentageSumCalculation() } // function _percentageSumCalculation()
private function _percentageAdjustValues($dataValues,$sumValues) { private function _percentageAdjustValues($dataValues, $sumValues) {
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
$dataValues[$k] = $dataValue / $sumValues[$k] * 100; $dataValues[$k] = $dataValue / $sumValues[$k] * 100;
} }
@ -165,7 +165,7 @@ class PHPExcel_Chart_Renderer_jpgraph
// If we do, it could be a plain string or an array // If we do, it could be a plain string or an array
if (is_array($caption)) { if (is_array($caption)) {
// Implode an array to a plain string // Implode an array to a plain string
$caption = implode('',$caption); $caption = implode('', $caption);
} }
} }
return $caption; return $caption;
@ -276,7 +276,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
$seriesPlots = array(); $seriesPlots = array();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
} }
// Loop through each data series in turn // Loop through each data series in turn
@ -285,13 +285,13 @@ class PHPExcel_Chart_Renderer_jpgraph
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
} }
// Fill in any missing values in the $dataValues array // Fill in any missing values in the $dataValues array
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
while($k != $testCurrentIndex) { while ($k != $testCurrentIndex) {
$dataValues[$testCurrentIndex] = null; $dataValues[$testCurrentIndex] = null;
++$testCurrentIndex; ++$testCurrentIndex;
} }
@ -309,7 +309,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]); $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour++]);
} else { } else {
// Set the appropriate plot marker // Set the appropriate plot marker
$this->_formatPointMarker($seriesPlot,$marker); $this->_formatPointMarker($seriesPlot, $marker);
} }
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
$seriesPlot->SetLegend($dataLabel); $seriesPlot->SetLegend($dataLabel);
@ -352,20 +352,20 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
$seriesPlots = array(); $seriesPlots = array();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$sumValues = $this->_percentageSumCalculation($groupID,$seriesCount); $sumValues = $this->_percentageSumCalculation($groupID, $seriesCount);
} }
// Loop through each data series in turn // Loop through each data series in turn
for($j = 0; $j < $seriesCount; ++$j) { for($j = 0; $j < $seriesCount; ++$j) {
$dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues(); $dataValues = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($j)->getDataValues();
if ($grouping == 'percentStacked') { if ($grouping == 'percentStacked') {
$dataValues = $this->_percentageAdjustValues($dataValues,$sumValues); $dataValues = $this->_percentageAdjustValues($dataValues, $sumValues);
} }
// Fill in any missing values in the $dataValues array // Fill in any missing values in the $dataValues array
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
while($k != $testCurrentIndex) { while ($k != $testCurrentIndex) {
$dataValues[$testCurrentIndex] = null; $dataValues[$testCurrentIndex] = null;
++$testCurrentIndex; ++$testCurrentIndex;
} }
@ -411,7 +411,7 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _renderPlotBar() } // function _renderPlotBar()
private function _renderPlotScatter($groupID,$bubble) { private function _renderPlotScatter($groupID, $bubble) {
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); $grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
$scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); $scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
@ -423,18 +423,18 @@ class PHPExcel_Chart_Renderer_jpgraph
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues(); $dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues(); $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
foreach($dataValuesY as $k => $dataValueY) { foreach ($dataValuesY as $k => $dataValueY) {
$dataValuesY[$k] = $k; $dataValuesY[$k] = $k;
} }
$seriesPlot = new ScatterPlot($dataValuesX,$dataValuesY); $seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
if ($scatterStyle == 'lineMarker') { if ($scatterStyle == 'lineMarker') {
$seriesPlot->SetLinkPoints(); $seriesPlot->SetLinkPoints();
$seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]); $seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]);
} elseif ($scatterStyle == 'smoothMarker') { } elseif ($scatterStyle == 'smoothMarker') {
$spline = new Spline($dataValuesY,$dataValuesX); $spline = new Spline($dataValuesY, $dataValuesX);
list($splineDataY,$splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20); list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20);
$lplot = new LinePlot($splineDataX,$splineDataY); $lplot = new LinePlot($splineDataX, $splineDataY);
$lplot->SetColor(self::$_colourSet[self::$_plotColour]); $lplot->SetColor(self::$_colourSet[self::$_plotColour]);
$this->_graph->Add($lplot); $this->_graph->Add($lplot);
@ -446,7 +446,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$seriesPlot->mark->SetSize($bubbleSize); $seriesPlot->mark->SetSize($bubbleSize);
} else { } else {
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
$this->_formatPointMarker($seriesPlot,$marker); $this->_formatPointMarker($seriesPlot, $marker);
} }
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue(); $dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
$seriesPlot->SetLegend($dataLabel); $seriesPlot->SetLegend($dataLabel);
@ -469,7 +469,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker(); $marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
$dataValues = array(); $dataValues = array();
foreach($dataValuesY as $k => $dataValueY) { foreach ($dataValuesY as $k => $dataValueY) {
$dataValues[$k] = implode(' ',array_reverse($dataValueY)); $dataValues[$k] = implode(' ',array_reverse($dataValueY));
} }
$tmp = array_shift($dataValues); $tmp = array_shift($dataValues);
@ -486,7 +486,7 @@ class PHPExcel_Chart_Renderer_jpgraph
if ($radarStyle == 'filled') { if ($radarStyle == 'filled') {
$seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]); $seriesPlot->SetFillColor(self::$_colourSet[self::$_plotColour]);
} }
$this->_formatPointMarker($seriesPlot,$marker); $this->_formatPointMarker($seriesPlot, $marker);
$seriesPlot->SetLegend($dataLabel); $seriesPlot->SetLegend($dataLabel);
$this->_graph->Add($seriesPlot); $this->_graph->Add($seriesPlot);
@ -520,13 +520,13 @@ class PHPExcel_Chart_Renderer_jpgraph
$dataValues = array(); $dataValues = array();
// Loop through each data series in turn and build the plot arrays // Loop through each data series in turn and build the plot arrays
foreach($plotOrder as $i => $v) { foreach ($plotOrder as $i => $v) {
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues(); $dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($v)->getDataValues();
foreach($dataValuesX as $j => $dataValueX) { foreach ($dataValuesX as $j => $dataValueX) {
$dataValues[$plotOrder[$i]][$j] = $dataValueX; $dataValues[$plotOrder[$i]][$j] = $dataValueX;
} }
} }
if(empty($dataValues)) { if (empty($dataValues)) {
return; return;
} }
@ -559,7 +559,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$this->_renderCartesianPlotArea(); $this->_renderCartesianPlotArea();
for($i = 0; $i < $groupCount; ++$i) { for($i = 0; $i < $groupCount; ++$i) {
$this->_renderPlotLine($i,True,False,$dimensions); $this->_renderPlotLine($i,True,False, $dimensions);
} }
} // function _renderAreaChart() } // function _renderAreaChart()
@ -570,7 +570,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$this->_renderCartesianPlotArea(); $this->_renderCartesianPlotArea();
for($i = 0; $i < $groupCount; ++$i) { for($i = 0; $i < $groupCount; ++$i) {
$this->_renderPlotLine($i,False,False,$dimensions); $this->_renderPlotLine($i,False,False, $dimensions);
} }
} // function _renderLineChart() } // function _renderLineChart()
@ -581,7 +581,7 @@ class PHPExcel_Chart_Renderer_jpgraph
$this->_renderCartesianPlotArea(); $this->_renderCartesianPlotArea();
for($i = 0; $i < $groupCount; ++$i) { for($i = 0; $i < $groupCount; ++$i) {
$this->_renderPlotBar($i,$dimensions); $this->_renderPlotBar($i, $dimensions);
} }
} // function _renderBarChart() } // function _renderBarChart()
@ -640,8 +640,8 @@ class PHPExcel_Chart_Renderer_jpgraph
// Fill in any missing values in the $dataValues array // Fill in any missing values in the $dataValues array
$testCurrentIndex = 0; $testCurrentIndex = 0;
foreach($dataValues as $k => $dataValue) { foreach ($dataValues as $k => $dataValue) {
while($k != $testCurrentIndex) { while ($k != $testCurrentIndex) {
$dataValues[$testCurrentIndex] = null; $dataValues[$testCurrentIndex] = null;
++$testCurrentIndex; ++$testCurrentIndex;
} }
@ -707,7 +707,7 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _renderStockChart() } // function _renderStockChart()
private function _renderContourChart($groupCount,$dimensions) { private function _renderContourChart($groupCount, $dimensions) {
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_contour.php');
$this->_renderCartesianPlotArea('intint'); $this->_renderCartesianPlotArea('intint');
@ -718,7 +718,7 @@ class PHPExcel_Chart_Renderer_jpgraph
} // function _renderContourChart() } // function _renderContourChart()
private function _renderCombinationChart($groupCount,$dimensions,$outputDestination) { private function _renderCombinationChart($groupCount, $dimensions, $outputDestination) {
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_line.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_bar.php');
require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php'); require_once(PHPExcel_Settings::getChartRendererPath().'jpgraph_scatter.php');
@ -734,17 +734,17 @@ class PHPExcel_Chart_Renderer_jpgraph
case 'area3DChart' : case 'area3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'areaChart' : case 'areaChart' :
$this->_renderPlotLine($i,True,True,$dimensions); $this->_renderPlotLine($i,True,True, $dimensions);
break; break;
case 'bar3DChart' : case 'bar3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'barChart' : case 'barChart' :
$this->_renderPlotBar($i,$dimensions); $this->_renderPlotBar($i, $dimensions);
break; break;
case 'line3DChart' : case 'line3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'lineChart' : case 'lineChart' :
$this->_renderPlotLine($i,False,True,$dimensions); $this->_renderPlotLine($i,False,True, $dimensions);
break; break;
case 'scatterChart' : case 'scatterChart' :
$this->_renderPlotScatter($i,false); $this->_renderPlotScatter($i,false);
@ -785,7 +785,7 @@ class PHPExcel_Chart_Renderer_jpgraph
echo 'Chart is not yet implemented<br />'; echo 'Chart is not yet implemented<br />';
return false; return false;
} else { } else {
return $this->_renderCombinationChart($groupCount,$dimensions,$outputDestination); return $this->_renderCombinationChart($groupCount, $dimensions, $outputDestination);
} }
} }
@ -793,27 +793,27 @@ class PHPExcel_Chart_Renderer_jpgraph
case 'area3DChart' : case 'area3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'areaChart' : case 'areaChart' :
$this->_renderAreaChart($groupCount,$dimensions); $this->_renderAreaChart($groupCount, $dimensions);
break; break;
case 'bar3DChart' : case 'bar3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'barChart' : case 'barChart' :
$this->_renderBarChart($groupCount,$dimensions); $this->_renderBarChart($groupCount, $dimensions);
break; break;
case 'line3DChart' : case 'line3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'lineChart' : case 'lineChart' :
$this->_renderLineChart($groupCount,$dimensions); $this->_renderLineChart($groupCount, $dimensions);
break; break;
case 'pie3DChart' : case 'pie3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'pieChart' : case 'pieChart' :
$this->_renderPieChart($groupCount,$dimensions,False,False); $this->_renderPieChart($groupCount, $dimensions,False,False);
break; break;
case 'doughnut3DChart' : case 'doughnut3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'doughnutChart' : case 'doughnutChart' :
$this->_renderPieChart($groupCount,$dimensions,True,True); $this->_renderPieChart($groupCount, $dimensions,True,True);
break; break;
case 'scatterChart' : case 'scatterChart' :
$this->_renderScatterChart($groupCount); $this->_renderScatterChart($groupCount);
@ -827,10 +827,10 @@ class PHPExcel_Chart_Renderer_jpgraph
case 'surface3DChart' : case 'surface3DChart' :
$dimensions = '3d'; $dimensions = '3d';
case 'surfaceChart' : case 'surfaceChart' :
$this->_renderContourChart($groupCount,$dimensions); $this->_renderContourChart($groupCount, $dimensions);
break; break;
case 'stockChart' : case 'stockChart' :
$this->_renderStockChart($groupCount,$dimensions); $this->_renderStockChart($groupCount, $dimensions);
break; break;
default : default :
echo $chartType.' is not yet implemented<br />'; echo $chartType.' is not yet implemented<br />';

View File

@ -466,7 +466,7 @@ class PHPExcel_DocumentProperties
$propertyType = self::PROPERTY_TYPE_STRING; $propertyType = self::PROPERTY_TYPE_STRING;
} elseif (is_float($propertyValue)) { } elseif (is_float($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_FLOAT; $propertyType = self::PROPERTY_TYPE_FLOAT;
} elseif(is_int($propertyValue)) { } elseif (is_int($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_INTEGER; $propertyType = self::PROPERTY_TYPE_INTEGER;
} elseif (is_bool($propertyValue)) { } elseif (is_bool($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_BOOLEAN; $propertyType = self::PROPERTY_TYPE_BOOLEAN;
@ -497,7 +497,7 @@ class PHPExcel_DocumentProperties
} }
} }
public static function convertProperty($propertyValue,$propertyType) public static function convertProperty($propertyValue, $propertyType)
{ {
switch ($propertyType) { switch ($propertyType) {
case 'empty': // Empty case 'empty': // Empty

View File

@ -637,7 +637,7 @@ class PHPExcel_Helper_HTML
protected function rgbToColour($rgb) { protected function rgbToColour($rgb) {
preg_match_all('/\d+/', $rgb, $values); preg_match_all('/\d+/', $rgb, $values);
foreach($values[0] as &$value) { foreach ($values[0] as &$value) {
$value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT); $value = str_pad(dechex($value), 2, '0', STR_PAD_LEFT);
} }
return implode($values[0]); return implode($values[0]);
@ -655,7 +655,7 @@ class PHPExcel_Helper_HTML
if ($attributeName == 'color') { if ($attributeName == 'color') {
if (preg_match('/rgb\s*\(/', $attributeValue)) { if (preg_match('/rgb\s*\(/', $attributeValue)) {
$this->$attributeName = $this->rgbToColour($attributeValue); $this->$attributeName = $this->rgbToColour($attributeValue);
} elseif(strpos(trim($attributeValue), '#') === 0) { } elseif (strpos(trim($attributeValue), '#') === 0) {
$this->$attributeName = ltrim($attributeValue, '#'); $this->$attributeName = ltrim($attributeValue, '#');
} else { } else {
$this->$attributeName = $this->colourNameLookup($attributeValue); $this->$attributeName = $this->colourNameLookup($attributeValue);

View File

@ -203,7 +203,7 @@ class PHPExcel_IOFactory
{ {
$reader = self::createReaderForFile($pFilename); $reader = self::createReaderForFile($pFilename);
$className = get_class($reader); $className = get_class($reader);
$classType = explode('_',$className); $classType = explode('_', $className);
unset($reader); unset($reader);
return array_pop($classType); return array_pop($classType);
} }

View File

@ -110,7 +110,7 @@ class PHPExcel_NamedRange
// Re-attach // Re-attach
if ($this->_worksheet !== NULL) { if ($this->_worksheet !== NULL) {
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet); $this->_worksheet->getParent()->removeNamedRange($this->_name, $this->_worksheet);
} }
$this->_name = $value; $this->_name = $value;

View File

@ -266,7 +266,7 @@ class PHPExcel_Reader_CSV extends PHPExcel_Reader_Abstract implements PHPExcel_R
// Loop through each line of the file in turn // Loop through each line of the file in turn
while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) { while (($rowData = fgetcsv($fileHandle, 0, $this->_delimiter, $this->_enclosure)) !== FALSE) {
$columnLetter = 'A'; $columnLetter = 'A';
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) { if ($rowDatum != '' && $this->_readFilter->readCell($columnLetter, $currentRow)) {
// Unescape enclosures // Unescape enclosures
$rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum); $rowDatum = str_replace($escapeEnclosures, $this->_enclosure, $rowDatum);

View File

@ -101,7 +101,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
fclose($fileHandle); fclose($fileHandle);
$valid = true; $valid = true;
foreach($signature as $match) { foreach ($signature as $match) {
// every part of the signature must be present // every part of the signature must be present
if (strpos($data, $match) === false) { if (strpos($data, $match) === false) {
$valid = false; $valid = false;
@ -110,10 +110,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
// Retrieve charset encoding // Retrieve charset encoding
if(preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um',$data,$matches)) { if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/um', $data, $matches)) {
$this->_charSet = strtoupper($matches[1]); $this->_charSet = strtoupper($matches[1]);
} }
// echo 'Character Set is ',$this->_charSet,'<br />'; // echo 'Character Set is ', $this->_charSet,'<br />';
return $valid; return $valid;
} }
@ -141,9 +141,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$namespaces = $xml->getNamespaces(true); $namespaces = $xml->getNamespaces(true);
$xml_ss = $xml->children($namespaces['ss']); $xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
$worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet); $worksheetNames[] = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->_charSet);
} }
return $worksheetNames; return $worksheetNames;
@ -170,7 +170,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetID = 1; $worksheetID = 1;
$xml_ss = $xml->children($namespaces['ss']); $xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
$tmpInfo = array(); $tmpInfo = array();
@ -189,11 +189,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
if (isset($worksheet->Table->Row)) { if (isset($worksheet->Table->Row)) {
$rowIndex = 0; $rowIndex = 0;
foreach($worksheet->Table->Row as $rowData) { foreach ($worksheet->Table->Row as $rowData) {
$columnIndex = 0; $columnIndex = 0;
$rowHasData = false; $rowHasData = false;
foreach($rowData->Cell as $cell) { foreach ($rowData->Cell as $cell) {
if (isset($cell->Data)) { if (isset($cell->Data)) {
$tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex); $tmpInfo['lastColumnIndex'] = max($tmpInfo['lastColumnIndex'], $columnIndex);
$rowHasData = true; $rowHasData = true;
@ -241,7 +241,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { protected static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue); $styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) { foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) { if ($styleAttributeValue == strtolower($style)) {
$styleAttributeValue = $style; $styleAttributeValue = $style;
return true; return true;
@ -336,52 +336,52 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$docProps = $objPHPExcel->getProperties(); $docProps = $objPHPExcel->getProperties();
if (isset($xml->DocumentProperties[0])) { if (isset($xml->DocumentProperties[0])) {
foreach($xml->DocumentProperties[0] as $propertyName => $propertyValue) { foreach ($xml->DocumentProperties[0] as $propertyName => $propertyValue) {
switch ($propertyName) { switch ($propertyName) {
case 'Title' : case 'Title' :
$docProps->setTitle(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setTitle(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Subject' : case 'Subject' :
$docProps->setSubject(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setSubject(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Author' : case 'Author' :
$docProps->setCreator(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setCreator(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Created' : case 'Created' :
$creationDate = strtotime($propertyValue); $creationDate = strtotime($propertyValue);
$docProps->setCreated($creationDate); $docProps->setCreated($creationDate);
break; break;
case 'LastAuthor' : case 'LastAuthor' :
$docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setLastModifiedBy(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'LastSaved' : case 'LastSaved' :
$lastSaveDate = strtotime($propertyValue); $lastSaveDate = strtotime($propertyValue);
$docProps->setModified($lastSaveDate); $docProps->setModified($lastSaveDate);
break; break;
case 'Company' : case 'Company' :
$docProps->setCompany(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setCompany(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Category' : case 'Category' :
$docProps->setCategory(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setCategory(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Manager' : case 'Manager' :
$docProps->setManager(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setManager(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Keywords' : case 'Keywords' :
$docProps->setKeywords(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setKeywords(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
case 'Description' : case 'Description' :
$docProps->setDescription(self::_convertStringEncoding($propertyValue,$this->_charSet)); $docProps->setDescription(self::_convertStringEncoding($propertyValue, $this->_charSet));
break; break;
} }
} }
} }
if (isset($xml->CustomDocumentProperties)) { if (isset($xml->CustomDocumentProperties)) {
foreach($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) { foreach ($xml->CustomDocumentProperties[0] as $propertyName => $propertyValue) {
$propertyAttributes = $propertyValue->attributes($namespaces['dt']); $propertyAttributes = $propertyValue->attributes($namespaces['dt']);
$propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str',$propertyName); $propertyName = preg_replace_callback('/_x([0-9a-z]{4})_/','PHPExcel_Reader_Excel2003XML::_hex2str', $propertyName);
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_UNKNOWN;
switch((string) $propertyAttributes) { switch ((string) $propertyAttributes) {
case 'string' : case 'string' :
$propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING; $propertyType = PHPExcel_DocumentProperties::PROPERTY_TYPE_STRING;
$propertyValue = trim($propertyValue); $propertyValue = trim($propertyValue);
@ -403,11 +403,11 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$propertyValue = strtotime(trim($propertyValue)); $propertyValue = strtotime(trim($propertyValue));
break; break;
} }
$docProps->setCustomProperty($propertyName,$propertyValue,$propertyType); $docProps->setCustomProperty($propertyName, $propertyValue, $propertyType);
} }
} }
foreach($xml->Styles[0] as $style) { foreach ($xml->Styles[0] as $style) {
$style_ss = $style->attributes($namespaces['ss']); $style_ss = $style->attributes($namespaces['ss']);
$styleID = (string) $style_ss['ID']; $styleID = (string) $style_ss['ID'];
// echo 'Style ID = '.$styleID.'<br />'; // echo 'Style ID = '.$styleID.'<br />';
@ -421,17 +421,17 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo $styleType.'<br />'; // echo $styleType.'<br />';
switch ($styleType) { switch ($styleType) {
case 'Alignment' : case 'Alignment' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Vertical' : case 'Vertical' :
if (self::identifyFixedStyleValue($verticalAlignmentStyles,$styleAttributeValue)) { if (self::identifyFixedStyleValue($verticalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['vertical'] = $styleAttributeValue;
} }
break; break;
case 'Horizontal' : case 'Horizontal' :
if (self::identifyFixedStyleValue($horizontalAlignmentStyles,$styleAttributeValue)) { if (self::identifyFixedStyleValue($horizontalAlignmentStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue; $this->_styles[$styleID]['alignment']['horizontal'] = $styleAttributeValue;
} }
break; break;
@ -442,10 +442,10 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Borders' : case 'Borders' :
foreach($styleData->Border as $borderStyle) { foreach ($styleData->Border as $borderStyle) {
$borderAttributes = $borderStyle->attributes($namespaces['ss']); $borderAttributes = $borderStyle->attributes($namespaces['ss']);
$thisBorder = array(); $thisBorder = array();
foreach($borderAttributes as $borderStyleKey => $borderStyleValue) { foreach ($borderAttributes as $borderStyleKey => $borderStyleValue) {
// echo $borderStyleKey.' = '.$borderStyleValue.'<br />'; // echo $borderStyleKey.' = '.$borderStyleValue.'<br />';
switch ($borderStyleKey) { switch ($borderStyleKey) {
case 'LineStyle' : case 'LineStyle' :
@ -472,7 +472,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Font' : case 'Font' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = (string) $styleAttributeValue; $styleAttributeValue = (string) $styleAttributeValue;
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
@ -492,7 +492,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$this->_styles[$styleID]['font']['italic'] = true; $this->_styles[$styleID]['font']['italic'] = true;
break; break;
case 'Underline' : case 'Underline' :
if (self::identifyFixedStyleValue($underlineStyles,$styleAttributeValue)) { if (self::identifyFixedStyleValue($underlineStyles, $styleAttributeValue)) {
$this->_styles[$styleID]['font']['underline'] = $styleAttributeValue; $this->_styles[$styleID]['font']['underline'] = $styleAttributeValue;
} }
break; break;
@ -500,7 +500,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Interior' : case 'Interior' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
switch ($styleAttributeKey) { switch ($styleAttributeKey) {
case 'Color' : case 'Color' :
@ -510,9 +510,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'NumberFormat' : case 'NumberFormat' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
$styleAttributeValue = str_replace($fromFormats,$toFormats,$styleAttributeValue); $styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue);
switch ($styleAttributeValue) { switch ($styleAttributeValue) {
case 'Short Date' : case 'Short Date' :
$styleAttributeValue = 'dd/mm/yyyy'; $styleAttributeValue = 'dd/mm/yyyy';
@ -524,7 +524,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
break; break;
case 'Protection' : case 'Protection' :
foreach($styleAttributes as $styleAttributeKey => $styleAttributeValue) { foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
// echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />'; // echo $styleAttributeKey.' = '.$styleAttributeValue.'<br />';
} }
break; break;
@ -538,7 +538,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$worksheetID = 0; $worksheetID = 0;
$xml_ss = $xml->children($namespaces['ss']); $xml_ss = $xml->children($namespaces['ss']);
foreach($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) && if ((isset($this->_loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
@ -546,13 +546,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
continue; continue;
} }
// echo '<h3>Worksheet: ',$worksheet_ss['Name'],'<h3>'; // echo '<h3>Worksheet: ', $worksheet_ss['Name'],'<h3>';
// //
// Create new Worksheet // Create new Worksheet
$objPHPExcel->createSheet(); $objPHPExcel->createSheet();
$objPHPExcel->setActiveSheetIndex($worksheetID); $objPHPExcel->setActiveSheetIndex($worksheetID);
if (isset($worksheet_ss['Name'])) { if (isset($worksheet_ss['Name'])) {
$worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'],$this->_charSet); $worksheetName = self::_convertStringEncoding((string) $worksheet_ss['Name'], $this->_charSet);
// Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in // Use false for $updateFormulaCellReferences to prevent adjustment of worksheet references in
// formula cells... during the load, all formulae should be correct, and we're simply bringing // formula cells... during the load, all formulae should be correct, and we're simply bringing
// the worksheet name in line with the formula, not the reverse // the worksheet name in line with the formula, not the reverse
@ -561,7 +561,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$columnID = 'A'; $columnID = 'A';
if (isset($worksheet->Table->Column)) { if (isset($worksheet->Table->Column)) {
foreach($worksheet->Table->Column as $columnData) { foreach ($worksheet->Table->Column as $columnData) {
$columnData_ss = $columnData->attributes($namespaces['ss']); $columnData_ss = $columnData->attributes($namespaces['ss']);
if (isset($columnData_ss['Index'])) { if (isset($columnData_ss['Index'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1); $columnID = PHPExcel_Cell::stringFromColumnIndex($columnData_ss['Index']-1);
@ -578,7 +578,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$rowID = 1; $rowID = 1;
if (isset($worksheet->Table->Row)) { if (isset($worksheet->Table->Row)) {
$additionalMergedCells = 0; $additionalMergedCells = 0;
foreach($worksheet->Table->Row as $rowData) { foreach ($worksheet->Table->Row as $rowData) {
$rowHasData = false; $rowHasData = false;
$row_ss = $rowData->attributes($namespaces['ss']); $row_ss = $rowData->attributes($namespaces['ss']);
if (isset($row_ss['Index'])) { if (isset($row_ss['Index'])) {
@ -587,7 +587,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// echo '<b>Row '.$rowID.'</b><br />'; // echo '<b>Row '.$rowID.'</b><br />';
$columnID = 'A'; $columnID = 'A';
foreach($rowData->Cell as $cell) { foreach ($rowData->Cell as $cell) {
$cell_ss = $cell->attributes($namespaces['ss']); $cell_ss = $cell->attributes($namespaces['ss']);
if (isset($cell_ss['Index'])) { if (isset($cell_ss['Index'])) {
@ -643,7 +643,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
const TYPE_ERROR = 'e'; const TYPE_ERROR = 'e';
*/ */
case 'String' : case 'String' :
$cellValue = self::_convertStringEncoding($cellValue,$this->_charSet); $cellValue = self::_convertStringEncoding($cellValue, $this->_charSet);
$type = PHPExcel_Cell_DataType::TYPE_STRING; $type = PHPExcel_Cell_DataType::TYPE_STRING;
break; break;
case 'Number' : case 'Number' :
@ -673,31 +673,31 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$columnNumber = PHPExcel_Cell::columnIndexFromString($columnID); $columnNumber = PHPExcel_Cell::columnIndexFromString($columnID);
if (substr($cellDataFormula,0,3) == 'of:') { if (substr($cellDataFormula,0,3) == 'of:') {
$cellDataFormula = substr($cellDataFormula,3); $cellDataFormula = substr($cellDataFormula,3);
// echo 'Before: ',$cellDataFormula,'<br />'; // echo 'Before: ', $cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$key = false; $key = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) { if ($key = !$key) {
$value = str_replace(array('[.','.',']'),'',$value); $value = str_replace(array('[.','.',']'),'', $value);
} }
} }
} else { } else {
// Convert R1C1 style references to A1 style references (but only when not quoted) // Convert R1C1 style references to A1 style references (but only when not quoted)
// echo 'Before: ',$cellDataFormula,'<br />'; // echo 'Before: ', $cellDataFormula,'<br />';
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$key = false; $key = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($key = !$key) { if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through // through the formula from left to right. Reversing means that we work right to left.through
// the formula // the formula
$cellReferences = array_reverse($cellReferences); $cellReferences = array_reverse($cellReferences);
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
// then modify the formula to use that new reference // then modify the formula to use that new reference
foreach($cellReferences as $cellReference) { foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0]; $rowReference = $cellReference[2][0];
// Empty R reference is the current row // Empty R reference is the current row
if ($rowReference == '') $rowReference = $rowID; if ($rowReference == '') $rowReference = $rowID;
@ -709,20 +709,20 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// Bracketed C references are relative to the current column // Bracketed C references are relative to the current column
if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]'); if ($columnReference{0} == '[') $columnReference = $columnNumber + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0]));
} }
} }
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"',$temp); $cellDataFormula = implode('"', $temp);
// echo 'After: ',$cellDataFormula,'<br />'; // echo 'After: ', $cellDataFormula,'<br />';
} }
// echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />'; // echo 'Cell '.$columnID.$rowID.' is a '.$type.' with a value of '.(($hasCalculatedValue) ? $cellDataFormula : $cellValue).'<br />';
// //
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue),$type); $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $cellValue), $type);
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
// echo 'Formula result is '.$cellValue.'<br />'; // echo 'Formula result is '.$cellValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue); $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setCalculatedValue($cellValue);
@ -736,15 +736,15 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$author = 'unknown'; $author = 'unknown';
if (isset($commentAttributes->Author)) { if (isset($commentAttributes->Author)) {
$author = (string)$commentAttributes->Author; $author = (string)$commentAttributes->Author;
// echo 'Author: ',$author,'<br />'; // echo 'Author: ', $author,'<br />';
} }
$node = $cell->Comment->Data->asXML(); $node = $cell->Comment->Data->asXML();
// $annotation = str_replace('html:','',substr($node,49,-10)); // $annotation = str_replace('html:','',substr($node,49,-10));
// echo $annotation,'<br />'; // echo $annotation,'<br />';
$annotation = strip_tags($node); $annotation = strip_tags($node);
// echo 'Annotation: ',$annotation,'<br />'; // echo 'Annotation: ', $annotation,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
->setAuthor(self::_convertStringEncoding($author ,$this->_charSet)) ->setAuthor(self::_convertStringEncoding($author , $this->_charSet))
->setText($this->_parseRichText($annotation) ); ->setText($this->_parseRichText($annotation) );
} }
@ -790,9 +790,9 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
} }
protected static function _convertStringEncoding($string,$charset) { protected static function _convertStringEncoding($string, $charset) {
if ($charset != 'UTF-8') { if ($charset != 'UTF-8') {
return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8',$charset); return PHPExcel_Shared_String::ConvertEncoding($string,'UTF-8', $charset);
} }
return $string; return $string;
} }
@ -801,7 +801,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
protected function _parseRichText($is = '') { protected function _parseRichText($is = '') {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
$value->createText(self::_convertStringEncoding($is,$this->_charSet)); $value->createText(self::_convertStringEncoding($is, $this->_charSet));
return $value; return $value;
} }

View File

@ -217,13 +217,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if ($xml->name == 'row' && $xml->nodeType == XMLReader::ELEMENT) { if ($xml->name == 'row' && $xml->nodeType == XMLReader::ELEMENT) {
$row = $xml->getAttribute('r'); $row = $xml->getAttribute('r');
$tmpInfo['totalRows'] = $row; $tmpInfo['totalRows'] = $row;
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$currCells = 0; $currCells = 0;
} elseif ($xml->name == 'c' && $xml->nodeType == XMLReader::ELEMENT) { } elseif ($xml->name == 'c' && $xml->nodeType == XMLReader::ELEMENT) {
$currCells++; $currCells++;
} }
} }
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$xml->close(); $xml->close();
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
@ -267,7 +267,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} // function _castToString() } // function _castToString()
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) { private function _castToFormula($c, $r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas, $castBaseType) {
// echo 'Formula', PHP_EOL; // echo 'Formula', PHP_EOL;
// echo '$c->f is ', $c->f, PHP_EOL; // echo '$c->f is ', $c->f, PHP_EOL;
$cellDataType = 'f'; $cellDataType = 'f';
@ -381,7 +381,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$themeColours = array(); $themeColours = array();
foreach ($colourScheme as $k => $xmlColour) { foreach ($colourScheme as $k => $xmlColour) {
$themePos = array_search($k,$themeOrderArray); $themePos = array_search($k, $themeOrderArray);
if ($themePos === false) { if ($themePos === false) {
$themePos = $themeOrderAdditional++; $themePos = $themeOrderAdditional++;
} }
@ -393,7 +393,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$themeColours[$themePos] = $xmlColourData['val']; $themeColours[$themePos] = $xmlColourData['val'];
} }
} }
self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName,$colourSchemeName,$themeColours); self::$_theme = new PHPExcel_Reader_Excel2007_Theme($themeName, $colourSchemeName, $themeColours);
} }
break; break;
} }
@ -443,9 +443,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $cellDataOfficeChildren = $xmlProperty->children('http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
$attributeType = $cellDataOfficeChildren->getName(); $attributeType = $cellDataOfficeChildren->getName();
$attributeValue = (string) $cellDataOfficeChildren->{$attributeType}; $attributeValue = (string) $cellDataOfficeChildren->{$attributeType};
$attributeValue = PHPExcel_DocumentProperties::convertProperty($attributeValue,$attributeType); $attributeValue = PHPExcel_DocumentProperties::convertProperty($attributeValue, $attributeType);
$attributeType = PHPExcel_DocumentProperties::convertPropertyType($attributeType); $attributeType = PHPExcel_DocumentProperties::convertPropertyType($attributeType);
$docProps->setCustomProperty($propertyName,$attributeValue,$attributeType); $docProps->setCustomProperty($propertyName, $attributeValue, $attributeType);
} }
} }
} }
@ -453,7 +453,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
//Ribbon //Ribbon
case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility": case "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility":
$customUI = $rel['Target']; $customUI = $rel['Target'];
if(!is_null($customUI)){ if (!is_null($customUI)) {
$this->_readRibbon($excel, $customUI, $zip); $this->_readRibbon($excel, $customUI, $zip);
} }
break; break;
@ -478,7 +478,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$worksheets = array(); $worksheets = array();
$macros = $customUI = NULL; $macros = $customUI = NULL;
foreach ($relsWorkbook->Relationship as $ele) { foreach ($relsWorkbook->Relationship as $ele) {
switch($ele['Type']){ switch ($ele['Type']) {
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet": case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet":
$worksheets[(string) $ele["Id"]] = $ele["Target"]; $worksheets[(string) $ele["Id"]] = $ele["Target"];
break; break;
@ -489,14 +489,14 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
} }
if(!is_null($macros)){ if (!is_null($macros)) {
$macrosCode = $this->_getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin $macrosCode = $this->_getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin
if($macrosCode !== false){ if ($macrosCode !== false) {
$excel->setMacrosCode($macrosCode); $excel->setMacrosCode($macrosCode);
$excel->setHasMacros(true); $excel->setHasMacros(true);
//short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir //short-circuit : not reading vbaProject.bin.rel to get Signature =>allways vbaProjectSignature.bin in 'xl' dir
$Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin'); $Certificate = $this->_getFromZipArchive($zip, 'xl/vbaProjectSignature.bin');
if($Certificate !== false) if ($Certificate !== false)
$excel->setMacrosCertificate($Certificate); $excel->setMacrosCertificate($Certificate);
} }
} }
@ -865,7 +865,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$value = self::_castToBool($c); $value = self::_castToBool($c);
} else { } else {
// Formula // Formula
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToBool'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToBool');
if (isset($c->f['t'])) { if (isset($c->f['t'])) {
$att = array(); $att = array();
$att = $c->f; $att = $c->f;
@ -885,7 +885,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$value = self::_castToError($c); $value = self::_castToError($c);
} else { } else {
// Formula // Formula
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToError'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToError');
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL; // echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
} }
@ -899,7 +899,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} else { } else {
// echo 'Treat as Formula', PHP_EOL; // echo 'Treat as Formula', PHP_EOL;
// Formula // Formula
$this->_castToFormula($c,$r,$cellDataType,$value,$calculatedValue,$sharedFormulas,'_castToString'); $this->_castToFormula($c, $r, $cellDataType, $value, $calculatedValue, $sharedFormulas,'_castToString');
// echo '$calculatedValue = ', $calculatedValue, PHP_EOL; // echo '$calculatedValue = ', $calculatedValue, PHP_EOL;
} }
@ -1207,8 +1207,8 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) { foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
// Uppercase coordinate // Uppercase coordinate
$range = strtoupper($dataValidation["sqref"]); $range = strtoupper($dataValidation["sqref"]);
$rangeSet = explode(' ',$range); $rangeSet = explode(' ', $range);
foreach($rangeSet as $range) { foreach ($rangeSet as $range) {
$stRange = $docSheet->shrinkRangeToFit($range); $stRange = $docSheet->shrinkRangeToFit($range);
// Extract all cell references in $range // Extract all cell references in $range
@ -1307,7 +1307,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
// Loop through contents // Loop through contents
foreach ($commentsFile->commentList->comment as $comment) { foreach ($commentsFile->commentList->comment as $comment) {
if(!empty($comment['authorId'])) if (!empty($comment['authorId']))
$docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] ); $docSheet->getComment( (string)$comment['ref'] )->setAuthor( $authors[(string)$comment['authorId']] );
$docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) ); $docSheet->getComment( (string)$comment['ref'] )->setText( $this->_parseRichText($comment->text) );
} }
@ -1526,7 +1526,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000); $shadow->setAlpha(self::array_item($outerShdw->srgbClr->alpha->attributes(), "val") / 1000);
} }
$objDrawing->setWorksheet($docSheet); $objDrawing->setWorksheet($docSheet);
} elseif(($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) { } elseif (($this->_includeCharts) && ($twoCellAnchor->graphicFrame)) {
$fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1); $fromCoordinate = PHPExcel_Cell::stringFromColumnIndex((string) $twoCellAnchor->from->col) . ($twoCellAnchor->from->row + 1);
$fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff); $fromOffsetX = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->colOff);
$fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff); $fromOffsetY = PHPExcel_Shared_Drawing::EMUToPixels($twoCellAnchor->from->rowOff);
@ -1561,7 +1561,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$extractedRange = (string)$definedName; $extractedRange = (string)$definedName;
$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange);
if (($spos = strpos($extractedRange,'!')) !== false) { if (($spos = strpos($extractedRange,'!')) !== false) {
$extractedRange = substr($extractedRange,0,$spos).str_replace('$', '', substr($extractedRange,$spos)); $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos));
} else { } else {
$extractedRange = str_replace('$', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange);
} }
@ -1611,7 +1611,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
case '_xlnm.Print_Area': case '_xlnm.Print_Area':
$rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma? $rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma?
$newRangeSets = array(); $newRangeSets = array();
foreach($rangeSets as $rangeSet) { foreach ($rangeSets as $rangeSet) {
$range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark?
$rangeSet = isset($range[1]) ? $range[1] : $range[0]; $rangeSet = isset($range[1]) ? $range[1] : $range[0];
if (strpos($rangeSet, ':') === FALSE) { if (strpos($rangeSet, ':') === FALSE) {
@ -1619,7 +1619,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
} }
$newRangeSets[] = str_replace('$', '', $rangeSet); $newRangeSets[] = str_replace('$', '', $rangeSet);
} }
$docSheet->getPageSetup()->setPrintArea(implode(',',$newRangeSets)); $docSheet->getPageSetup()->setPrintArea(implode(',', $newRangeSets));
break; break;
default: default:
@ -1640,7 +1640,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$extractedRange = (string)$definedName; $extractedRange = (string)$definedName;
$extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange); $extractedRange = preg_replace('/\'(\w+)\'\!/', '', $extractedRange);
if (($spos = strpos($extractedRange,'!')) !== false) { if (($spos = strpos($extractedRange,'!')) !== false) {
$extractedRange = substr($extractedRange,0,$spos).str_replace('$', '', substr($extractedRange,$spos)); $extractedRange = substr($extractedRange,0, $spos).str_replace('$', '', substr($extractedRange, $spos));
} else { } else {
$extractedRange = str_replace('$', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange);
} }
@ -1731,12 +1731,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
$chartElements = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $chartEntryRef)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $chartElements = simplexml_load_string($this->securityScan($this->_getFromZipArchive($zip, $chartEntryRef)), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml')); $objChart = PHPExcel_Reader_Excel2007_Chart::readChart($chartElements,basename($chartEntryRef,'.xml'));
// echo 'Chart ',$chartEntryRef,'<br />'; // echo 'Chart ', $chartEntryRef,'<br />';
// var_dump($charts[$chartEntryRef]); // var_dump($charts[$chartEntryRef]);
// //
if (isset($charts[$chartEntryRef])) { if (isset($charts[$chartEntryRef])) {
$chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id']; $chartPositionRef = $charts[$chartEntryRef]['sheet'].'!'.$charts[$chartEntryRef]['id'];
// echo 'Position Ref ',$chartPositionRef,'<br />'; // echo 'Position Ref ', $chartPositionRef,'<br />';
if (isset($chartDetails[$chartPositionRef])) { if (isset($chartDetails[$chartPositionRef])) {
// var_dump($chartDetails[$chartPositionRef]); // var_dump($chartDetails[$chartPositionRef]);
@ -1767,7 +1767,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB(); return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
} else if (isset($color["theme"])) { } else if (isset($color["theme"])) {
if (self::$_theme !== NULL) { if (self::$_theme !== NULL) {
$returnColour = self::$_theme->getColourByIndex((int)$color["theme"]); $returnColour = self::$_theme->getColourByIndex((int)$color["theme"]);
@ -1832,7 +1832,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($style->fill)) { if (isset($style->fill)) {
if ($style->fill->gradientFill) { if ($style->fill->gradientFill) {
$gradientFill = $style->fill->gradientFill[0]; $gradientFill = $style->fill->gradientFill[0];
if(!empty($gradientFill["type"])) { if (!empty($gradientFill["type"])) {
$docStyle->getFill()->setFillType((string) $gradientFill["type"]); $docStyle->getFill()->setFillType((string) $gradientFill["type"]);
} }
$docStyle->getFill()->setRotation(floatval($gradientFill["degree"])); $docStyle->getFill()->setRotation(floatval($gradientFill["degree"]));
@ -1934,7 +1934,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
if (isset($is->t)) { if (isset($is->t)) {
$value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) ); $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $is->t ) );
} else { } else {
if(is_object($is->r)) { if (is_object($is->r)) {
foreach ($is->r as $run) { foreach ($is->r as $run) {
if (!isset($run->rPr)) { if (!isset($run->rPr)) {
$objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) ); $objText = $value->createText( PHPExcel_Shared_String::ControlCharacterOOXML2PHP( (string) $run->t ) );

View File

@ -51,95 +51,95 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _getAttribute() } // function _getAttribute()
private static function _readColor($color,$background=false) { private static function _readColor($color, $background=false) {
if (isset($color["rgb"])) { if (isset($color["rgb"])) {
return (string)$color["rgb"]; return (string)$color["rgb"];
} else if (isset($color["indexed"])) { } else if (isset($color["indexed"])) {
return PHPExcel_Style_Color::indexedColor($color["indexed"]-7,$background)->getARGB(); return PHPExcel_Style_Color::indexedColor($color["indexed"]-7, $background)->getARGB();
} }
} }
public static function readChart($chartElements,$chartName) { public static function readChart($chartElements, $chartName) {
$namespacesChartMeta = $chartElements->getNamespaces(true); $namespacesChartMeta = $chartElements->getNamespaces(true);
$chartElementsC = $chartElements->children($namespacesChartMeta['c']); $chartElementsC = $chartElements->children($namespacesChartMeta['c']);
$XaxisLabel = $YaxisLabel = $legend = $title = NULL; $XaxisLabel = $YaxisLabel = $legend = $title = NULL;
$dispBlanksAs = $plotVisOnly = NULL; $dispBlanksAs = $plotVisOnly = NULL;
foreach($chartElementsC as $chartElementKey => $chartElement) { foreach ($chartElementsC as $chartElementKey => $chartElement) {
switch ($chartElementKey) { switch ($chartElementKey) {
case "chart": case "chart":
foreach($chartElement as $chartDetailsKey => $chartDetails) { foreach ($chartElement as $chartDetailsKey => $chartDetails) {
$chartDetailsC = $chartDetails->children($namespacesChartMeta['c']); $chartDetailsC = $chartDetails->children($namespacesChartMeta['c']);
switch ($chartDetailsKey) { switch ($chartDetailsKey) {
case "plotArea": case "plotArea":
$plotAreaLayout = $XaxisLable = $YaxisLable = null; $plotAreaLayout = $XaxisLable = $YaxisLable = null;
$plotSeries = $plotAttributes = array(); $plotSeries = $plotAttributes = array();
foreach($chartDetails as $chartDetailKey => $chartDetail) { foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) { switch ($chartDetailKey) {
case "layout": case "layout":
$plotAreaLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'plotArea'); $plotAreaLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'plotArea');
break; break;
case "catAx": case "catAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat'); $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "dateAx": case "dateAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat'); $XaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "valAx": case "valAx":
if (isset($chartDetail->title)) { if (isset($chartDetail->title)) {
$YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']),$namespacesChartMeta,'cat'); $YaxisLabel = self::_chartTitle($chartDetail->title->children($namespacesChartMeta['c']), $namespacesChartMeta,'cat');
} }
break; break;
case "barChart": case "barChart":
case "bar3DChart": case "bar3DChart":
$barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string'); $barDirection = self::_getAttribute($chartDetail->barDir, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotDirection($barDirection); $plotSer->setPlotDirection($barDirection);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "lineChart": case "lineChart":
case "line3DChart": case "line3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "areaChart": case "areaChart":
case "area3DChart": case "area3DChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "doughnutChart": case "doughnutChart":
case "pieChart": case "pieChart":
case "pie3DChart": case "pie3DChart":
$explosion = isset($chartDetail->ser->explosion); $explosion = isset($chartDetail->ser->explosion);
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($explosion); $plotSer->setPlotStyle($explosion);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "scatterChart": case "scatterChart":
$scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string'); $scatterStyle = self::_getAttribute($chartDetail->scatterStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($scatterStyle); $plotSer->setPlotStyle($scatterStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "bubbleChart": case "bubbleChart":
$bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer'); $bubbleScale = self::_getAttribute($chartDetail->bubbleScale, 'val', 'integer');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($bubbleScale); $plotSer->setPlotStyle($bubbleScale);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "radarChart": case "radarChart":
$radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string'); $radarStyle = self::_getAttribute($chartDetail->radarStyle, 'val', 'string');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($radarStyle); $plotSer->setPlotStyle($radarStyle);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
@ -147,13 +147,13 @@ class PHPExcel_Reader_Excel2007_Chart
case "surfaceChart": case "surfaceChart":
case "surface3DChart": case "surface3DChart":
$wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean'); $wireFrame = self::_getAttribute($chartDetail->wireframe, 'val', 'boolean');
$plotSer = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSer = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotSer->setPlotStyle($wireFrame); $plotSer->setPlotStyle($wireFrame);
$plotSeries[] = $plotSer; $plotSeries[] = $plotSer;
$plotAttributes = self::_readChartAttributes($chartDetail); $plotAttributes = self::_readChartAttributes($chartDetail);
break; break;
case "stockChart": case "stockChart":
$plotSeries[] = self::_chartDataSeries($chartDetail,$namespacesChartMeta,$chartDetailKey); $plotSeries[] = self::_chartDataSeries($chartDetail, $namespacesChartMeta, $chartDetailKey);
$plotAttributes = self::_readChartAttributes($plotAreaLayout); $plotAttributes = self::_readChartAttributes($plotAreaLayout);
break; break;
} }
@ -161,8 +161,8 @@ class PHPExcel_Reader_Excel2007_Chart
if ($plotAreaLayout == NULL) { if ($plotAreaLayout == NULL) {
$plotAreaLayout = new PHPExcel_Chart_Layout(); $plotAreaLayout = new PHPExcel_Chart_Layout();
} }
$plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout,$plotSeries); $plotArea = new PHPExcel_Chart_PlotArea($plotAreaLayout, $plotSeries);
self::_setChartAttributes($plotAreaLayout,$plotAttributes); self::_setChartAttributes($plotAreaLayout, $plotAttributes);
break; break;
case "plotVisOnly": case "plotVisOnly":
$plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string'); $plotVisOnly = self::_getAttribute($chartDetails, 'val', 'string');
@ -171,13 +171,13 @@ class PHPExcel_Reader_Excel2007_Chart
$dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string'); $dispBlanksAs = self::_getAttribute($chartDetails, 'val', 'string');
break; break;
case "title": case "title":
$title = self::_chartTitle($chartDetails,$namespacesChartMeta,'title'); $title = self::_chartTitle($chartDetails, $namespacesChartMeta,'title');
break; break;
case "legend": case "legend":
$legendPos = 'r'; $legendPos = 'r';
$legendLayout = null; $legendLayout = null;
$legendOverlay = false; $legendOverlay = false;
foreach($chartDetails as $chartDetailKey => $chartDetail) { foreach ($chartDetails as $chartDetailKey => $chartDetail) {
switch ($chartDetailKey) { switch ($chartDetailKey) {
case "legendPos": case "legendPos":
$legendPos = self::_getAttribute($chartDetail, 'val', 'string'); $legendPos = self::_getAttribute($chartDetail, 'val', 'string');
@ -186,7 +186,7 @@ class PHPExcel_Reader_Excel2007_Chart
$legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean'); $legendOverlay = self::_getAttribute($chartDetail, 'val', 'boolean');
break; break;
case "layout": case "layout":
$legendLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta,'legend'); $legendLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta,'legend');
break; break;
} }
} }
@ -196,20 +196,20 @@ class PHPExcel_Reader_Excel2007_Chart
} }
} }
} }
$chart = new PHPExcel_Chart($chartName,$title,$legend,$plotArea,$plotVisOnly,$dispBlanksAs,$XaxisLabel,$YaxisLabel); $chart = new PHPExcel_Chart($chartName, $title, $legend, $plotArea, $plotVisOnly, $dispBlanksAs, $XaxisLabel, $YaxisLabel);
return $chart; return $chart;
} // function readChart() } // function readChart()
private static function _chartTitle($titleDetails,$namespacesChartMeta,$type) { private static function _chartTitle($titleDetails, $namespacesChartMeta, $type) {
$caption = array(); $caption = array();
$titleLayout = null; $titleLayout = null;
foreach($titleDetails as $titleDetailKey => $chartDetail) { foreach ($titleDetails as $titleDetailKey => $chartDetail) {
switch ($titleDetailKey) { switch ($titleDetailKey) {
case "tx": case "tx":
$titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']); $titleDetails = $chartDetail->rich->children($namespacesChartMeta['a']);
foreach($titleDetails as $titleKey => $titleDetail) { foreach ($titleDetails as $titleKey => $titleDetail) {
switch ($titleKey) { switch ($titleKey) {
case "p": case "p":
$titleDetailPart = $titleDetail->children($namespacesChartMeta['a']); $titleDetailPart = $titleDetail->children($namespacesChartMeta['a']);
@ -218,7 +218,7 @@ class PHPExcel_Reader_Excel2007_Chart
} }
break; break;
case "layout": case "layout":
$titleLayout = self::_chartLayoutDetails($chartDetail,$namespacesChartMeta); $titleLayout = self::_chartLayoutDetails($chartDetail, $namespacesChartMeta);
break; break;
} }
} }
@ -227,7 +227,7 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _chartTitle() } // function _chartTitle()
private static function _chartLayoutDetails($chartDetail,$namespacesChartMeta) { private static function _chartLayoutDetails($chartDetail, $namespacesChartMeta) {
if (!isset($chartDetail->manualLayout)) { if (!isset($chartDetail->manualLayout)) {
return null; return null;
} }
@ -236,7 +236,7 @@ class PHPExcel_Reader_Excel2007_Chart
return null; return null;
} }
$layout = array(); $layout = array();
foreach($details as $detailKey => $detail) { foreach ($details as $detailKey => $detail) {
// echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL; // echo $detailKey,' => ',self::_getAttribute($detail, 'val', 'string'),PHP_EOL;
$layout[$detailKey] = self::_getAttribute($detail, 'val', 'string'); $layout[$detailKey] = self::_getAttribute($detail, 'val', 'string');
} }
@ -244,20 +244,20 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _chartLayoutDetails() } // function _chartLayoutDetails()
private static function _chartDataSeries($chartDetail,$namespacesChartMeta,$plotType) { private static function _chartDataSeries($chartDetail, $namespacesChartMeta, $plotType) {
$multiSeriesType = NULL; $multiSeriesType = NULL;
$smoothLine = false; $smoothLine = false;
$seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array(); $seriesLabel = $seriesCategory = $seriesValues = $plotOrder = array();
$seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']); $seriesDetailSet = $chartDetail->children($namespacesChartMeta['c']);
foreach($seriesDetailSet as $seriesDetailKey => $seriesDetails) { foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) {
switch ($seriesDetailKey) { switch ($seriesDetailKey) {
case "grouping": case "grouping":
$multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string'); $multiSeriesType = self::_getAttribute($chartDetail->grouping, 'val', 'string');
break; break;
case "ser": case "ser":
$marker = NULL; $marker = NULL;
foreach($seriesDetails as $seriesKey => $seriesDetail) { foreach ($seriesDetails as $seriesKey => $seriesDetail) {
switch ($seriesKey) { switch ($seriesKey) {
case "idx": case "idx":
$seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer'); $seriesIndex = self::_getAttribute($seriesDetail, 'val', 'integer');
@ -267,7 +267,7 @@ class PHPExcel_Reader_Excel2007_Chart
$plotOrder[$seriesIndex] = $seriesOrder; $plotOrder[$seriesIndex] = $seriesOrder;
break; break;
case "tx": case "tx":
$seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta); $seriesLabel[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break; break;
case "marker": case "marker":
$marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string'); $marker = self::_getAttribute($seriesDetail->symbol, 'val', 'string');
@ -276,22 +276,22 @@ class PHPExcel_Reader_Excel2007_Chart
$smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean'); $smoothLine = self::_getAttribute($seriesDetail, 'val', 'boolean');
break; break;
case "cat": case "cat":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta); $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta);
break; break;
case "val": case "val":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker); $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
case "xVal": case "xVal":
$seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker); $seriesCategory[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
case "yVal": case "yVal":
$seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail,$namespacesChartMeta,$marker); $seriesValues[$seriesIndex] = self::_chartDataSeriesValueSet($seriesDetail, $namespacesChartMeta, $marker);
break; break;
} }
} }
} }
} }
return new PHPExcel_Chart_DataSeries($plotType,$multiSeriesType,$plotOrder,$seriesLabel,$seriesCategory,$seriesValues,$smoothLine); return new PHPExcel_Chart_DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine);
} // function _chartDataSeries() } // function _chartDataSeries()
@ -300,35 +300,35 @@ class PHPExcel_Reader_Excel2007_Chart
$seriesSource = (string) $seriesDetail->strRef->f; $seriesSource = (string) $seriesDetail->strRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValues($seriesDetail->strRef->strCache->children($namespacesChartMeta['c']),'s');
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->numRef)) { } elseif (isset($seriesDetail->numRef)) {
$seriesSource = (string) $seriesDetail->numRef->f; $seriesSource = (string) $seriesDetail->numRef->f;
$seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c'])); $seriesData = self::_chartDataSeriesValues($seriesDetail->numRef->numCache->children($namespacesChartMeta['c']));
return new PHPExcel_Chart_DataSeriesValues('Number',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('Number', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->multiLvlStrRef)) { } elseif (isset($seriesDetail->multiLvlStrRef)) {
$seriesSource = (string) $seriesDetail->multiLvlStrRef->f; $seriesSource = (string) $seriesDetail->multiLvlStrRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlStrRef->multiLvlStrCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']); $seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} elseif (isset($seriesDetail->multiLvlNumRef)) { } elseif (isset($seriesDetail->multiLvlNumRef)) {
$seriesSource = (string) $seriesDetail->multiLvlNumRef->f; $seriesSource = (string) $seriesDetail->multiLvlNumRef->f;
$seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s'); $seriesData = self::_chartDataSeriesValuesMultiLevel($seriesDetail->multiLvlNumRef->multiLvlNumCache->children($namespacesChartMeta['c']),'s');
$seriesData['pointCount'] = count($seriesData['dataValues']); $seriesData['pointCount'] = count($seriesData['dataValues']);
return new PHPExcel_Chart_DataSeriesValues('String',$seriesSource,$seriesData['formatCode'],$seriesData['pointCount'],$seriesData['dataValues'],$marker,$smoothLine); return new PHPExcel_Chart_DataSeriesValues('String', $seriesSource, $seriesData['formatCode'], $seriesData['pointCount'], $seriesData['dataValues'], $marker, $smoothLine);
} }
return null; return null;
} // function _chartDataSeriesValueSet() } // function _chartDataSeriesValueSet()
private static function _chartDataSeriesValues($seriesValueSet,$dataType='n') { private static function _chartDataSeriesValues($seriesValueSet, $dataType='n') {
$seriesVal = array(); $seriesVal = array();
$formatCode = ''; $formatCode = '';
$pointCount = 0; $pointCount = 0;
foreach($seriesValueSet as $seriesValueIdx => $seriesValue) { foreach ($seriesValueSet as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) { switch ($seriesValueIdx) {
case 'ptCount': case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer'); $pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
@ -358,13 +358,13 @@ class PHPExcel_Reader_Excel2007_Chart
} // function _chartDataSeriesValues() } // function _chartDataSeriesValues()
private static function _chartDataSeriesValuesMultiLevel($seriesValueSet,$dataType='n') { private static function _chartDataSeriesValuesMultiLevel($seriesValueSet, $dataType='n') {
$seriesVal = array(); $seriesVal = array();
$formatCode = ''; $formatCode = '';
$pointCount = 0; $pointCount = 0;
foreach($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) { foreach ($seriesValueSet->lvl as $seriesLevelIdx => $seriesLevel) {
foreach($seriesLevel as $seriesValueIdx => $seriesValue) { foreach ($seriesLevel as $seriesValueIdx => $seriesValue) {
switch ($seriesValueIdx) { switch ($seriesValueIdx) {
case 'ptCount': case 'ptCount':
$pointCount = self::_getAttribute($seriesValue, 'val', 'integer'); $pointCount = self::_getAttribute($seriesValue, 'val', 'integer');
@ -393,7 +393,7 @@ class PHPExcel_Reader_Excel2007_Chart
private static function _parseRichText($titleDetailPart = null) { private static function _parseRichText($titleDetailPart = null) {
$value = new PHPExcel_RichText(); $value = new PHPExcel_RichText();
foreach($titleDetailPart as $titleDetailElementKey => $titleDetailElement) { foreach ($titleDetailPart as $titleDetailElementKey => $titleDetailElement) {
if (isset($titleDetailElement->t)) { if (isset($titleDetailElement->t)) {
$objText = $value->createTextRun( (string) $titleDetailElement->t ); $objText = $value->createTextRun( (string) $titleDetailElement->t );
} }
@ -426,7 +426,7 @@ class PHPExcel_Reader_Excel2007_Chart
if (!is_null($baseline)) { if (!is_null($baseline)) {
if ($baseline > 0) { if ($baseline > 0) {
$objText->getFont()->setSuperScript(true); $objText->getFont()->setSuperScript(true);
} elseif($baseline < 0) { } elseif ($baseline < 0) {
$objText->getFont()->setSubScript(true); $objText->getFont()->setSubScript(true);
} }
} }
@ -435,7 +435,7 @@ class PHPExcel_Reader_Excel2007_Chart
if (!is_null($underscore)) { if (!is_null($underscore)) {
if ($underscore == 'sng') { if ($underscore == 'sng') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE); $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
} elseif($underscore == 'dbl') { } elseif ($underscore == 'dbl') {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE); $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_DOUBLE);
} else { } else {
$objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE); $objText->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_NONE);
@ -485,10 +485,10 @@ class PHPExcel_Reader_Excel2007_Chart
return $plotAttributes; return $plotAttributes;
} }
private static function _setChartAttributes($plotArea,$plotAttributes) private static function _setChartAttributes($plotArea, $plotAttributes)
{ {
foreach($plotAttributes as $plotAttributeKey => $plotAttributeValue) { foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) {
switch($plotAttributeKey) { switch ($plotAttributeKey) {
case 'showLegendKey' : case 'showLegendKey' :
$plotArea->setShowLegendKey($plotAttributeValue); $plotArea->setShowLegendKey($plotAttributeValue);
break; break;

View File

@ -69,7 +69,7 @@ class PHPExcel_Reader_Excel2007_Theme
* Create a new PHPExcel_Theme * Create a new PHPExcel_Theme
* *
*/ */
public function __construct($themeName,$colourSchemeName,$colourMap) public function __construct($themeName, $colourSchemeName, $colourMap)
{ {
// Initialise values // Initialise values
$this->_themeName = $themeName; $this->_themeName = $themeName;

View File

@ -676,7 +676,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
foreach ($this->_objFonts as $objFont) { foreach ($this->_objFonts as $objFont) {
if (isset($objFont->colorIndex)) { if (isset($objFont->colorIndex)) {
$color = self::_readColor($objFont->colorIndex,$this->_palette,$this->_version); $color = self::_readColor($objFont->colorIndex, $this->_palette, $this->_version);
$objFont->getColor()->setRGB($color['rgb']); $objFont->getColor()->setRGB($color['rgb']);
} }
} }
@ -686,12 +686,12 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$fill = $objStyle->getFill(); $fill = $objStyle->getFill();
if (isset($fill->startcolorIndex)) { if (isset($fill->startcolorIndex)) {
$startColor = self::_readColor($fill->startcolorIndex,$this->_palette,$this->_version); $startColor = self::_readColor($fill->startcolorIndex, $this->_palette, $this->_version);
$fill->getStartColor()->setRGB($startColor['rgb']); $fill->getStartColor()->setRGB($startColor['rgb']);
} }
if (isset($fill->endcolorIndex)) { if (isset($fill->endcolorIndex)) {
$endColor = self::_readColor($fill->endcolorIndex,$this->_palette,$this->_version); $endColor = self::_readColor($fill->endcolorIndex, $this->_palette, $this->_version);
$fill->getEndColor()->setRGB($endColor['rgb']); $fill->getEndColor()->setRGB($endColor['rgb']);
} }
@ -703,27 +703,27 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$diagonal = $objStyle->getBorders()->getDiagonal(); $diagonal = $objStyle->getBorders()->getDiagonal();
if (isset($top->colorIndex)) { if (isset($top->colorIndex)) {
$borderTopColor = self::_readColor($top->colorIndex,$this->_palette,$this->_version); $borderTopColor = self::_readColor($top->colorIndex, $this->_palette, $this->_version);
$top->getColor()->setRGB($borderTopColor['rgb']); $top->getColor()->setRGB($borderTopColor['rgb']);
} }
if (isset($right->colorIndex)) { if (isset($right->colorIndex)) {
$borderRightColor = self::_readColor($right->colorIndex,$this->_palette,$this->_version); $borderRightColor = self::_readColor($right->colorIndex, $this->_palette, $this->_version);
$right->getColor()->setRGB($borderRightColor['rgb']); $right->getColor()->setRGB($borderRightColor['rgb']);
} }
if (isset($bottom->colorIndex)) { if (isset($bottom->colorIndex)) {
$borderBottomColor = self::_readColor($bottom->colorIndex,$this->_palette,$this->_version); $borderBottomColor = self::_readColor($bottom->colorIndex, $this->_palette, $this->_version);
$bottom->getColor()->setRGB($borderBottomColor['rgb']); $bottom->getColor()->setRGB($borderBottomColor['rgb']);
} }
if (isset($left->colorIndex)) { if (isset($left->colorIndex)) {
$borderLeftColor = self::_readColor($left->colorIndex,$this->_palette,$this->_version); $borderLeftColor = self::_readColor($left->colorIndex, $this->_palette, $this->_version);
$left->getColor()->setRGB($borderLeftColor['rgb']); $left->getColor()->setRGB($borderLeftColor['rgb']);
} }
if (isset($diagonal->colorIndex)) { if (isset($diagonal->colorIndex)) {
$borderDiagonalColor = self::_readColor($diagonal->colorIndex,$this->_palette,$this->_version); $borderDiagonalColor = self::_readColor($diagonal->colorIndex, $this->_palette, $this->_version);
$diagonal->getColor()->setRGB($borderDiagonalColor['rgb']); $diagonal->getColor()->setRGB($borderDiagonalColor['rgb']);
} }
} }
@ -863,7 +863,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// treat OBJ records // treat OBJ records
foreach ($this->_objs as $n => $obj) { foreach ($this->_objs as $n => $obj) {
// echo '<hr /><b>Object</b> reference is ',$n,'<br />'; // echo '<hr /><b>Object</b> reference is ', $n,'<br />';
// var_dump($obj); // var_dump($obj);
// echo '<br />'; // echo '<br />';
@ -896,7 +896,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
case 0x19: case 0x19:
// Note // Note
// echo 'Cell Annotation Object<br />'; // echo 'Cell Annotation Object<br />';
// echo 'Object ID is ',$obj['idObjID'],'<br />'; // echo 'Object ID is ', $obj['idObjID'],'<br />';
// //
if (isset($this->_cellNotes[$obj['idObjID']])) { if (isset($this->_cellNotes[$obj['idObjID']])) {
$cellNote = $this->_cellNotes[$obj['idObjID']]; $cellNote = $this->_cellNotes[$obj['idObjID']];
@ -969,7 +969,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
} }
if (!empty($this->_cellNotes)) { if (!empty($this->_cellNotes)) {
foreach($this->_cellNotes as $note => $noteDetails) { foreach ($this->_cellNotes as $note => $noteDetails) {
if (!isset($noteDetails['objTextData'])) { if (!isset($noteDetails['objTextData'])) {
if (isset($this->_textObjects[$note])) { if (isset($this->_textObjects[$note])) {
$textObject = $this->_textObjects[$note]; $textObject = $this->_textObjects[$note];
@ -978,10 +978,10 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$noteDetails['objTextData']['text'] = ''; $noteDetails['objTextData']['text'] = '';
} }
} }
// echo '<b>Cell annotation ',$note,'</b><br />'; // echo '<b>Cell annotation ', $note,'</b><br />';
// var_dump($noteDetails); // var_dump($noteDetails);
// echo '<br />'; // echo '<br />';
$cellAddress = str_replace('$','',$noteDetails['cellRef']); $cellAddress = str_replace('$','', $noteDetails['cellRef']);
$this->_phpSheet->getComment( $cellAddress ) $this->_phpSheet->getComment( $cellAddress )
->setAuthor( $noteDetails['author'] ) ->setAuthor( $noteDetails['author'] )
->setText($this->_parseRichText($noteDetails['objTextData']['text']) ); ->setText($this->_parseRichText($noteDetails['objTextData']['text']) );
@ -1353,21 +1353,21 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// offset: 8; size: 16 // offset: 8; size: 16
// offset: 24; size: 4; section count // offset: 24; size: 4; section count
$secCount = self::_GetInt4d($this->_documentSummaryInformation, 24); $secCount = self::_GetInt4d($this->_documentSummaryInformation, 24);
// echo '$secCount = ',$secCount,'<br />'; // echo '$secCount = ', $secCount,'<br />';
// offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae // offset: 28; size: 16; first section's class id: 02 d5 cd d5 9c 2e 1b 10 93 97 08 00 2b 2c f9 ae
// offset: 44; size: 4; first section offset // offset: 44; size: 4; first section offset
$secOffset = self::_GetInt4d($this->_documentSummaryInformation, 44); $secOffset = self::_GetInt4d($this->_documentSummaryInformation, 44);
// echo '$secOffset = ',$secOffset,'<br />'; // echo '$secOffset = ', $secOffset,'<br />';
// section header // section header
// offset: $secOffset; size: 4; section length // offset: $secOffset; size: 4; section length
$secLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset); $secLength = self::_GetInt4d($this->_documentSummaryInformation, $secOffset);
// echo '$secLength = ',$secLength,'<br />'; // echo '$secLength = ', $secLength,'<br />';
// offset: $secOffset+4; size: 4; property count // offset: $secOffset+4; size: 4; property count
$countProperties = self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4); $countProperties = self::_GetInt4d($this->_documentSummaryInformation, $secOffset+4);
// echo '$countProperties = ',$countProperties,'<br />'; // echo '$countProperties = ', $countProperties,'<br />';
// initialize code page (used to resolve string values) // initialize code page (used to resolve string values)
$codePage = 'CP1252'; $codePage = 'CP1252';
@ -1375,17 +1375,17 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
// offset: ($secOffset+8); size: var // offset: ($secOffset+8); size: var
// loop through property decarations and properties // loop through property decarations and properties
for ($i = 0; $i < $countProperties; ++$i) { for ($i = 0; $i < $countProperties; ++$i) {
// echo 'Property ',$i,'<br />'; // echo 'Property ', $i,'<br />';
// offset: ($secOffset+8) + (8 * $i); size: 4; property ID // offset: ($secOffset+8) + (8 * $i); size: 4; property ID
$id = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i)); $id = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+8) + (8 * $i));
// echo 'ID is ',$id,'<br />'; // echo 'ID is ', $id,'<br />';
// Use value of property id as appropriate // Use value of property id as appropriate
// offset: 60 + 8 * $i; size: 4; offset from beginning of section (48) // offset: 60 + 8 * $i; size: 4; offset from beginning of section (48)
$offset = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i)); $offset = self::_GetInt4d($this->_documentSummaryInformation, ($secOffset+12) + (8 * $i));
$type = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + $offset); $type = self::_GetInt4d($this->_documentSummaryInformation, $secOffset + $offset);
// echo 'Type is ',$type,', '; // echo 'Type is ', $type,', ';
// initialize property value // initialize property value
$value = null; $value = null;
@ -1531,9 +1531,9 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$noteObjID = self::_GetInt2d($recordData, 6); $noteObjID = self::_GetInt2d($recordData, 6);
$noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8)); $noteAuthor = self::_readUnicodeStringLong(substr($recordData, 8));
$noteAuthor = $noteAuthor['value']; $noteAuthor = $noteAuthor['value'];
// echo 'Note Address=',$cellAddress,'<br />'; // echo 'Note Address=', $cellAddress,'<br />';
// echo 'Note Object ID=',$noteObjID,'<br />'; // echo 'Note Object ID=', $noteObjID,'<br />';
// echo 'Note Author=',$noteAuthor,'<hr />'; // echo 'Note Author=', $noteAuthor,'<hr />';
// //
$this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress, $this->_cellNotes[$noteObjID] = array('cellRef' => $cellAddress,
'objectID' => $noteObjID, 'objectID' => $noteObjID,
@ -1549,13 +1549,13 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$extension = true; $extension = true;
$cellAddress = array_pop(array_keys($this->_phpSheet->getComments())); $cellAddress = array_pop(array_keys($this->_phpSheet->getComments()));
} }
// echo 'Note Address=',$cellAddress,'<br />'; // echo 'Note Address=', $cellAddress,'<br />';
$cellAddress = str_replace('$','',$cellAddress); $cellAddress = str_replace('$','', $cellAddress);
$noteLength = self::_GetInt2d($recordData, 4); $noteLength = self::_GetInt2d($recordData, 4);
$noteText = trim(substr($recordData, 6)); $noteText = trim(substr($recordData, 6));
// echo 'Note Length=',$noteLength,'<br />'; // echo 'Note Length=', $noteLength,'<br />';
// echo 'Note Text=',$noteText,'<br />'; // echo 'Note Text=', $noteText,'<br />';
if ($extension) { if ($extension) {
// Concatenate this extension with the currently set comment for the cell // Concatenate this extension with the currently set comment for the cell
@ -1601,8 +1601,8 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$text = $this->_getSplicedRecordData(); $text = $this->_getSplicedRecordData();
$this->_textObjects[$this->textObjRef] = array( $this->_textObjects[$this->textObjRef] = array(
'text' => substr($text["recordData"],$text["spliceOffsets"][0]+1,$cchText), 'text' => substr($text["recordData"], $text["spliceOffsets"][0]+1, $cchText),
'format' => substr($text["recordData"],$text["spliceOffsets"][1],$cbRuns), 'format' => substr($text["recordData"], $text["spliceOffsets"][1], $cbRuns),
'alignment' => $grbitOpts, 'alignment' => $grbitOpts,
'rotation' => $rot 'rotation' => $rot
); );
@ -4294,7 +4294,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
/** /**
* Read PLV Record(Created by Excel2007 or upper) * Read PLV Record(Created by Excel2007 or upper)
*/ */
private function _readPageLayoutView(){ private function _readPageLayoutView() {
$length = self::_GetInt2d($this->_data, $this->_pos + 2); $length = self::_GetInt2d($this->_data, $this->_pos + 2);
$recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length); $recordData = $this->_readRecordData($this->_data, $this->_pos + 4, $length);
@ -4564,7 +4564,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
$url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false); $url = self::_encodeUTF16(substr($recordData, $offset, $us - 2), false);
$nullOffset = strpos($url, 0x00); $nullOffset = strpos($url, 0x00);
if ($nullOffset) if ($nullOffset)
$url = substr($url,0,$nullOffset); $url = substr($url,0, $nullOffset);
$url .= $hasText ? '#' : ''; $url .= $hasText ? '#' : '';
$offset += $us; $offset += $us;
break; break;
@ -4858,7 +4858,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
case 0x14: case 0x14:
// offset: 16; size: 2; color index for sheet tab // offset: 16; size: 2; color index for sheet tab
$colorIndex = self::_GetInt2d($recordData, 16); $colorIndex = self::_GetInt2d($recordData, 16);
$color = self::_readColor($colorIndex,$this->_palette,$this->_version); $color = self::_readColor($colorIndex, $this->_palette, $this->_version);
$this->_phpSheet->getTabColor()->setRGB($color['rgb']); $this->_phpSheet->getTabColor()->setRGB($color['rgb']);
break; break;
@ -6807,7 +6807,7 @@ class PHPExcel_Reader_Excel5 extends PHPExcel_Reader_Abstract implements PHPExce
* @param array $palette Color palette * @param array $palette Color palette
* @return array RGB color value, example: array('rgb' => 'FF0000') * @return array RGB color value, example: array('rgb' => 'FF0000')
*/ */
private static function _readColor($color,$palette,$version) private static function _readColor($color, $palette, $version)
{ {
if ($color <= 0x07 || $color >= 0x40) { if ($color <= 0x07 || $color >= 0x40) {
// special built-in color // special built-in color

View File

@ -257,13 +257,13 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$officeDocXML = $officeXML->{'document-meta'}; $officeDocXML = $officeXML->{'document-meta'};
$officeDocMetaXML = $officeDocXML->meta; $officeDocMetaXML = $officeDocXML->meta;
foreach($officeDocMetaXML as $officePropertyData) { foreach ($officeDocMetaXML as $officePropertyData) {
$officePropertyDC = array(); $officePropertyDC = array();
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
} }
foreach($officePropertyDC as $propertyName => $propertyValue) { foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'title' : case 'title' :
@ -290,7 +290,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if (isset($namespacesMeta['meta'])) { if (isset($namespacesMeta['meta'])) {
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
} }
foreach($officePropertyMeta as $propertyName => $propertyValue) { foreach ($officePropertyMeta as $propertyName => $propertyValue) {
$attributes = $propertyValue->attributes($namespacesMeta['meta']); $attributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
@ -307,7 +307,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$docProps->setModified($creationDate); $docProps->setModified($creationDate);
break; break;
case 'user-defined' : case 'user-defined' :
list(,$attrName) = explode(':',$attributes['name']); list(, $attrName) = explode(':', $attributes['name']);
switch ($attrName) { switch ($attrName) {
case 'publisher' : case 'publisher' :
$docProps->setCompany(trim($propertyValue)); $docProps->setCompany(trim($propertyValue));
@ -324,7 +324,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
} elseif (isset($gnmXML->Summary)) { } elseif (isset($gnmXML->Summary)) {
foreach($gnmXML->Summary->Item as $summaryItem) { foreach ($gnmXML->Summary->Item as $summaryItem) {
$propertyName = $summaryItem->name; $propertyName = $summaryItem->name;
$propertyValue = $summaryItem->{'val-string'}; $propertyValue = $summaryItem->{'val-string'};
switch ($propertyName) { switch ($propertyName) {
@ -355,9 +355,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
$worksheetID = 0; $worksheetID = 0;
foreach($gnmXML->Sheets->Sheet as $sheet) { foreach ($gnmXML->Sheets->Sheet as $sheet) {
$worksheetName = (string) $sheet->Name; $worksheetName = (string) $sheet->Name;
// echo '<b>Worksheet: ',$worksheetName,'</b><br />'; // echo '<b>Worksheet: ', $worksheetName,'</b><br />';
if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) { if ((isset($this->_loadSheetsOnly)) && (!in_array($worksheetName, $this->_loadSheetsOnly))) {
continue; continue;
} }
@ -374,15 +374,15 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) { if ((!$this->_readDataOnly) && (isset($sheet->PrintInformation))) {
if (isset($sheet->PrintInformation->Margins)) { if (isset($sheet->PrintInformation->Margins)) {
foreach($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) { foreach ($sheet->PrintInformation->Margins->children('gnm',TRUE) as $key => $margin) {
$marginAttributes = $margin->attributes(); $marginAttributes = $margin->attributes();
$marginSize = 72 / 100; // Default $marginSize = 72 / 100; // Default
switch($marginAttributes['PrefUnit']) { switch ($marginAttributes['PrefUnit']) {
case 'mm' : case 'mm' :
$marginSize = intval($marginAttributes['Points']) / 100; $marginSize = intval($marginAttributes['Points']) / 100;
break; break;
} }
switch($key) { switch ($key) {
case 'top' : case 'top' :
$objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize); $objPHPExcel->getActiveSheet()->getPageMargins()->setTop($marginSize);
break; break;
@ -406,7 +406,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
foreach($sheet->Cells->Cell as $cell) { foreach ($sheet->Cells->Cell as $cell) {
$cellAttributes = $cell->attributes(); $cellAttributes = $cell->attributes();
$row = (int) $cellAttributes->Row + 1; $row = (int) $cellAttributes->Row + 1;
$column = (int) $cellAttributes->Col; $column = (int) $cellAttributes->Col;
@ -425,9 +425,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$ValueType = $cellAttributes->ValueType; $ValueType = $cellAttributes->ValueType;
$ExprID = (string) $cellAttributes->ExprID; $ExprID = (string) $cellAttributes->ExprID;
// echo 'Cell ',$column,$row,'<br />'; // echo 'Cell ', $column, $row,'<br />';
// echo 'Type is ',$ValueType,'<br />'; // echo 'Type is ', $ValueType,'<br />';
// echo 'Value is ',$cell,'<br />'; // echo 'Value is ', $cell,'<br />';
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
if ($ExprID > '') { if ($ExprID > '') {
if (((string) $cell) > '') { if (((string) $cell) > '') {
@ -436,7 +436,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
'row' => $cellAttributes->Row, 'row' => $cellAttributes->Row,
'formula' => (string) $cell 'formula' => (string) $cell
); );
// echo 'NEW EXPRESSION ',$ExprID,'<br />'; // echo 'NEW EXPRESSION ', $ExprID,'<br />';
} else { } else {
$expression = $this->_expressions[$ExprID]; $expression = $this->_expressions[$ExprID];
@ -446,12 +446,12 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$cellAttributes->Row - $expression['row'], $cellAttributes->Row - $expression['row'],
$worksheetName $worksheetName
); );
// echo 'SHARED EXPRESSION ',$ExprID,'<br />'; // echo 'SHARED EXPRESSION ', $ExprID,'<br />';
// echo 'New Value is ',$cell,'<br />'; // echo 'New Value is ', $cell,'<br />';
} }
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
} else { } else {
switch($ValueType) { switch ($ValueType) {
case '10' : // NULL case '10' : // NULL
$type = PHPExcel_Cell_DataType::TYPE_NULL; $type = PHPExcel_Cell_DataType::TYPE_NULL;
break; break;
@ -474,11 +474,11 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
case '80' : // Array case '80' : // Array
} }
} }
$objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell,$type); $objPHPExcel->getActiveSheet()->getCell($column.$row)->setValueExplicit($cell, $type);
} }
if ((!$this->_readDataOnly) && (isset($sheet->Objects))) { if ((!$this->_readDataOnly) && (isset($sheet->Objects))) {
foreach($sheet->Objects->children('gnm',TRUE) as $key => $comment) { foreach ($sheet->Objects->children('gnm',TRUE) as $key => $comment) {
$commentAttributes = $comment->attributes(); $commentAttributes = $comment->attributes();
// Only comment objects are handled at the moment // Only comment objects are handled at the moment
if ($commentAttributes->Text) { if ($commentAttributes->Text) {
@ -488,9 +488,9 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
} }
} }
} }
// echo '$maxCol=',$maxCol,'; $maxRow=',$maxRow,'<br />'; // echo '$maxCol=', $maxCol,'; $maxRow=', $maxRow,'<br />';
// //
foreach($sheet->Styles->StyleRegion as $styleRegion) { foreach ($sheet->Styles->StyleRegion as $styleRegion) {
$styleAttributes = $styleRegion->attributes(); $styleAttributes = $styleRegion->attributes();
if (($styleAttributes['startRow'] <= $maxRow) && if (($styleAttributes['startRow'] <= $maxRow) &&
($styleAttributes['startCol'] <= $maxCol)) { ($styleAttributes['startCol'] <= $maxCol)) {
@ -516,7 +516,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['numberformat']['code'] = (string) $styleAttributes['Format']; $styleArray['numberformat']['code'] = (string) $styleAttributes['Format'];
// If _readDataOnly is false, we set all formatting information // If _readDataOnly is false, we set all formatting information
if (!$this->_readDataOnly) { if (!$this->_readDataOnly) {
switch($styleAttributes['HAlign']) { switch ($styleAttributes['HAlign']) {
case '1' : case '1' :
$styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL; $styleArray['alignment']['horizontal'] = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
break; break;
@ -538,7 +538,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
break; break;
} }
switch($styleAttributes['VAlign']) { switch ($styleAttributes['VAlign']) {
case '1' : case '1' :
$styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP; $styleArray['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_TOP;
break; break;
@ -565,7 +565,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB; $styleArray['fill']['color']['rgb'] = $styleArray['fill']['startcolor']['rgb'] = $RGB;
$RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]); $RGB2 = self::_parseGnumericColour($styleAttributes["PatternColor"]);
$styleArray['fill']['endcolor']['rgb'] = $RGB2; $styleArray['fill']['endcolor']['rgb'] = $RGB2;
switch($shade) { switch ($shade) {
case '1' : case '1' :
$styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID; $styleArray['fill']['type'] = PHPExcel_Style_Fill::FILL_SOLID;
break; break;
@ -637,7 +637,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False; $styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? True : False;
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False; $styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? True : False;
$styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False; $styleArray['font']['strike'] = ($fontAttributes['StrikeThrough'] == '1') ? True : False;
switch($fontAttributes['Underline']) { switch ($fontAttributes['Underline']) {
case '1' : case '1' :
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_SINGLE;
break; break;
@ -654,7 +654,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE; $styleArray['font']['underline'] = PHPExcel_Style_Font::UNDERLINE_NONE;
break; break;
} }
switch($fontAttributes['Script']) { switch ($fontAttributes['Script']) {
case '1' : case '1' :
$styleArray['font']['superScript'] = True; $styleArray['font']['superScript'] = True;
break; break;
@ -704,7 +704,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$columnAttributes = $sheet->Cols->attributes(); $columnAttributes = $sheet->Cols->attributes();
$defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4; $defaultWidth = $columnAttributes['DefaultSizePts'] / 5.4;
$c = 0; $c = 0;
foreach($sheet->Cols->ColInfo as $columnOverride) { foreach ($sheet->Cols->ColInfo as $columnOverride) {
$columnAttributes = $columnOverride->attributes(); $columnAttributes = $columnOverride->attributes();
$column = $columnAttributes['No']; $column = $columnAttributes['No'];
$columnWidth = $columnAttributes['Unit'] / 5.4; $columnWidth = $columnAttributes['Unit'] / 5.4;
@ -734,7 +734,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
$defaultHeight = $rowAttributes['DefaultSizePts']; $defaultHeight = $rowAttributes['DefaultSizePts'];
$r = 0; $r = 0;
foreach($sheet->Rows->RowInfo as $rowOverride) { foreach ($sheet->Rows->RowInfo as $rowOverride) {
$rowAttributes = $rowOverride->attributes(); $rowAttributes = $rowOverride->attributes();
$row = $rowAttributes['No']; $row = $rowAttributes['No'];
$rowHeight = $rowAttributes['Unit']; $rowHeight = $rowAttributes['Unit'];
@ -760,7 +760,7 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Handle Merged Cells in this worksheet // Handle Merged Cells in this worksheet
if (isset($sheet->MergedRegions)) { if (isset($sheet->MergedRegions)) {
foreach($sheet->MergedRegions->Merge as $mergeCells) { foreach ($sheet->MergedRegions->Merge as $mergeCells) {
if (strpos($mergeCells,':') !== FALSE) { if (strpos($mergeCells,':') !== FALSE) {
$objPHPExcel->getActiveSheet()->mergeCells($mergeCells); $objPHPExcel->getActiveSheet()->mergeCells($mergeCells);
} }
@ -772,14 +772,14 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
// Loop through definedNames (global named ranges) // Loop through definedNames (global named ranges)
if (isset($gnmXML->Names)) { if (isset($gnmXML->Names)) {
foreach($gnmXML->Names->Name as $namedRange) { foreach ($gnmXML->Names->Name as $namedRange) {
$name = (string) $namedRange->name; $name = (string) $namedRange->name;
$range = (string) $namedRange->value; $range = (string) $namedRange->value;
if (stripos($range, '#REF!') !== false) { if (stripos($range, '#REF!') !== false) {
continue; continue;
} }
$range = explode('!',$range); $range = explode('!', $range);
$range[0] = trim($range[0],"'");; $range[0] = trim($range[0],"'");;
if ($worksheet = $objPHPExcel->getSheetByName($range[0])) { if ($worksheet = $objPHPExcel->getSheetByName($range[0])) {
$extractedRange = str_replace('$', '', $range[1]); $extractedRange = str_replace('$', '', $range[1]);
@ -861,12 +861,12 @@ class PHPExcel_Reader_Gnumeric extends PHPExcel_Reader_Abstract implements PHPEx
private static function _parseGnumericColour($gnmColour) { private static function _parseGnumericColour($gnmColour) {
list($gnmR,$gnmG,$gnmB) = explode(':',$gnmColour); list($gnmR, $gnmG, $gnmB) = explode(':', $gnmColour);
$gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2); $gnmR = substr(str_pad($gnmR,4,'0',STR_PAD_RIGHT),0,2);
$gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2); $gnmG = substr(str_pad($gnmG,4,'0',STR_PAD_RIGHT),0,2);
$gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2); $gnmB = substr(str_pad($gnmB,4,'0',STR_PAD_RIGHT),0,2);
$RGB = $gnmR.$gnmG.$gnmB; $RGB = $gnmR.$gnmG.$gnmB;
// echo 'Excel Colour: ',$RGB,'<br />'; // echo 'Excel Colour: ', $RGB,'<br />';
return $RGB; return $RGB;
} }

View File

@ -89,12 +89,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$stat = $zip->statName('mimetype'); $stat = $zip->statName('mimetype');
if ($stat && ($stat['size'] <= 255)) { if ($stat && ($stat['size'] <= 255)) {
$mimeType = $zip->getFromName($stat['name']); $mimeType = $zip->getFromName($stat['name']);
} elseif($stat = $zip->statName('META-INF/manifest.xml')) { } elseif ($stat = $zip->statName('META-INF/manifest.xml')) {
$xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions()); $xml = simplexml_load_string($this->securityScan($zip->getFromName('META-INF/manifest.xml')), 'SimpleXMLElement', PHPExcel_Settings::getLibXmlLoaderOptions());
$namespacesContent = $xml->getNamespaces(true); $namespacesContent = $xml->getNamespaces(true);
if (isset($namespacesContent['manifest'])) { if (isset($namespacesContent['manifest'])) {
$manifest = $xml->children($namespacesContent['manifest']); $manifest = $xml->children($namespacesContent['manifest']);
foreach($manifest as $manifestDataSet) { foreach ($manifest as $manifestDataSet) {
$manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']); $manifestAttributes = $manifestDataSet->attributes($namespacesContent['manifest']);
if ($manifestAttributes->{'full-path'} == '/') { if ($manifestAttributes->{'full-path'} == '/') {
$mimeType = (string) $manifestAttributes->{'media-type'}; $mimeType = (string) $manifestAttributes->{'media-type'};
@ -222,7 +222,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$rowspan = $xml->getAttribute('table:number-rows-repeated'); $rowspan = $xml->getAttribute('table:number-rows-repeated');
$rowspan = empty($rowspan) ? 1 : $rowspan; $rowspan = empty($rowspan) ? 1 : $rowspan;
$tmpInfo['totalRows'] += $rowspan; $tmpInfo['totalRows'] += $rowspan;
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$currCells = 0; $currCells = 0;
// Step into the row // Step into the row
$xml->read(); $xml->read();
@ -243,14 +243,14 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
} while ($xml->name != 'table:table'); } while ($xml->name != 'table:table');
$tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'],$currCells); $tmpInfo['totalColumns'] = max($tmpInfo['totalColumns'], $currCells);
$tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1; $tmpInfo['lastColumnIndex'] = $tmpInfo['totalColumns'] - 1;
$tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']); $tmpInfo['lastColumnLetter'] = PHPExcel_Cell::stringFromColumnIndex($tmpInfo['lastColumnIndex']);
$worksheetInfo[] = $tmpInfo; $worksheetInfo[] = $tmpInfo;
} }
} }
// foreach($workbookData->table as $worksheetDataSet) { // foreach ($workbookData->table as $worksheetDataSet) {
// $worksheetData = $worksheetDataSet->children($namespacesContent['table']); // $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
// $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']); // $worksheetDataAttributes = $worksheetDataSet->attributes($namespacesContent['table']);
// //
@ -309,7 +309,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) { private static function identifyFixedStyleValue($styleList,&$styleAttributeValue) {
$styleAttributeValue = strtolower($styleAttributeValue); $styleAttributeValue = strtolower($styleAttributeValue);
foreach($styleList as $style) { foreach ($styleList as $style) {
if ($styleAttributeValue == strtolower($style)) { if ($styleAttributeValue == strtolower($style)) {
$styleAttributeValue = $style; $styleAttributeValue = $style;
return true; return true;
@ -353,12 +353,12 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$docProps = $objPHPExcel->getProperties(); $docProps = $objPHPExcel->getProperties();
$officeProperty = $xml->children($namespacesMeta['office']); $officeProperty = $xml->children($namespacesMeta['office']);
foreach($officeProperty as $officePropertyData) { foreach ($officeProperty as $officePropertyData) {
$officePropertyDC = array(); $officePropertyDC = array();
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyDC = $officePropertyData->children($namespacesMeta['dc']); $officePropertyDC = $officePropertyData->children($namespacesMeta['dc']);
} }
foreach($officePropertyDC as $propertyName => $propertyValue) { foreach ($officePropertyDC as $propertyName => $propertyValue) {
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
case 'title' : case 'title' :
@ -385,7 +385,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if (isset($namespacesMeta['dc'])) { if (isset($namespacesMeta['dc'])) {
$officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']); $officePropertyMeta = $officePropertyData->children($namespacesMeta['meta']);
} }
foreach($officePropertyMeta as $propertyName => $propertyValue) { foreach ($officePropertyMeta as $propertyName => $propertyValue) {
$propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']); $propertyValueAttributes = $propertyValue->attributes($namespacesMeta['meta']);
$propertyValue = (string) $propertyValue; $propertyValue = (string) $propertyValue;
switch ($propertyName) { switch ($propertyName) {
@ -404,7 +404,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
foreach ($propertyValueAttributes as $key => $value) { foreach ($propertyValueAttributes as $key => $value) {
if ($key == 'name') { if ($key == 'name') {
$propertyValueName = (string) $value; $propertyValueName = (string) $value;
} elseif($key == 'value-type') { } elseif ($key == 'value-type') {
switch ($value) { switch ($value) {
case 'date' : case 'date' :
$propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date'); $propertyValue = PHPExcel_DocumentProperties::convertProperty($propertyValue,'date');
@ -423,7 +423,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
} }
} }
$docProps->setCustomProperty($propertyValueName,$propertyValue,$propertyValueType); $docProps->setCustomProperty($propertyValueName, $propertyValue, $propertyValueType);
break; break;
} }
} }
@ -438,10 +438,10 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo '</pre><hr />'; // echo '</pre><hr />';
$workbook = $xml->children($namespacesContent['office']); $workbook = $xml->children($namespacesContent['office']);
foreach($workbook->body->spreadsheet as $workbookData) { foreach ($workbook->body->spreadsheet as $workbookData) {
$workbookData = $workbookData->children($namespacesContent['table']); $workbookData = $workbookData->children($namespacesContent['table']);
$worksheetID = 0; $worksheetID = 0;
foreach($workbookData->table as $worksheetDataSet) { foreach ($workbookData->table as $worksheetDataSet) {
$worksheetData = $worksheetDataSet->children($namespacesContent['table']); $worksheetData = $worksheetDataSet->children($namespacesContent['table']);
// print_r($worksheetData); // print_r($worksheetData);
// echo '<br />'; // echo '<br />';
@ -466,7 +466,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
} }
$rowID = 1; $rowID = 1;
foreach($worksheetData as $key => $rowData) { foreach ($worksheetData as $key => $rowData) {
// echo '<b>'.$key.'</b><br />'; // echo '<b>'.$key.'</b><br />';
switch ($key) { switch ($key) {
case 'table-header-rows': case 'table-header-rows':
@ -479,7 +479,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ? $rowRepeats = (isset($rowDataTableAttributes['number-rows-repeated'])) ?
$rowDataTableAttributes['number-rows-repeated'] : 1; $rowDataTableAttributes['number-rows-repeated'] : 1;
$columnID = 'A'; $columnID = 'A';
foreach($rowData as $key => $cellData) { foreach ($rowData as $key => $cellData) {
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== NULL) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue; continue;
@ -514,16 +514,16 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
// echo 'Cell has comment<br />'; // echo 'Cell has comment<br />';
$annotationText = $cellDataOffice->annotation->children($namespacesContent['text']); $annotationText = $cellDataOffice->annotation->children($namespacesContent['text']);
$textArray = array(); $textArray = array();
foreach($annotationText as $t) { foreach ($annotationText as $t) {
if (isset($t->span)) { if (isset($t->span)) {
foreach($t->span as $text) { foreach ($t->span as $text) {
$textArray[] = (string)$text; $textArray[] = (string)$text;
} }
} else { } else {
$textArray[] = (string) $t; $textArray[] = (string) $t;
} }
} }
$text = implode("\n",$textArray); $text = implode("\n", $textArray);
// echo $text,'<br />'; // echo $text,'<br />';
$objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID ) $objPHPExcel->getActiveSheet()->getComment( $columnID.$rowID )
// ->setAuthor( $author ) // ->setAuthor( $author )
@ -596,8 +596,8 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$type = PHPExcel_Cell_DataType::TYPE_NUMERIC; $type = PHPExcel_Cell_DataType::TYPE_NUMERIC;
$dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT); $dateObj = new DateTime($cellDataOfficeAttributes['date-value'], $GMT);
$dateObj->setTimeZone($timezoneObj); $dateObj->setTimeZone($timezoneObj);
list($year,$month,$day,$hour,$minute,$second) = explode(' ',$dateObj->format('Y m d H i s')); list($year, $month, $day, $hour, $minute, $second) = explode(' ', $dateObj->format('Y m d H i s'));
$dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year,$month,$day,$hour,$minute,$second); $dataValue = PHPExcel_Shared_Date::FormattedPHPToExcel($year, $month, $day, $hour, $minute, $second);
if ($dataValue != floor($dataValue)) { if ($dataValue != floor($dataValue)) {
$formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4; $formatting = PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX15.' '.PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME4;
} else { } else {
@ -623,21 +623,21 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
$type = PHPExcel_Cell_DataType::TYPE_FORMULA; $type = PHPExcel_Cell_DataType::TYPE_FORMULA;
// echo 'Formula: ', $cellDataFormula, PHP_EOL; // echo 'Formula: ', $cellDataFormula, PHP_EOL;
$cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1); $cellDataFormula = substr($cellDataFormula,strpos($cellDataFormula,':=')+1);
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$tKey = false; $tKey = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($tKey = !$tKey) { if ($tKey = !$tKey) {
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3',$value); // Cell range reference in another sheet $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui','$1!$2:$3', $value); // Cell range reference in another sheet
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2',$value); // Cell reference in another sheet $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui','$1!$2', $value); // Cell reference in another sheet
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2',$value); // Cell range reference $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui','$1:$2', $value); // Cell range reference
$value = preg_replace('/\[\.([^\.]+)\]/Ui','$1',$value); // Simple cell reference $value = preg_replace('/\[\.([^\.]+)\]/Ui','$1', $value); // Simple cell reference
$value = PHPExcel_Calculation::_translateSeparator(';',',',$value,$inBraces); $value = PHPExcel_Calculation::_translateSeparator(';',',', $value, $inBraces);
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"',$temp); $cellDataFormula = implode('"', $temp);
// echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL; // echo 'Adjusted Formula: ', $cellDataFormula, PHP_EOL;
} }
@ -651,7 +651,7 @@ class PHPExcel_Reader_OOCalc extends PHPExcel_Reader_Abstract implements PHPExce
if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) { if ($type !== PHPExcel_Cell_DataType::TYPE_NULL) {
for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) { for ($rowAdjust = 0; $rowAdjust < $rowRepeats; ++$rowAdjust) {
$rID = $rowID + $rowAdjust; $rID = $rowID + $rowAdjust;
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue),$type); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setValueExplicit((($hasCalculatedValue) ? $cellDataFormula : $dataValue), $type);
if ($hasCalculatedValue) { if ($hasCalculatedValue) {
// echo 'Forumla result is '.$dataValue.'<br />'; // echo 'Forumla result is '.$dataValue.'<br />';
$objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue); $objPHPExcel->getActiveSheet()->getCell($columnID.$rID)->setCalculatedValue($dataValue);

View File

@ -167,8 +167,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
$dataType = array_shift($rowData); $dataType = array_shift($rowData);
if ($dataType == 'C') { if ($dataType == 'C') {
// Read cell value data // Read cell value data
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : case 'X' :
$columnIndex = substr($rowDatum,1) - 1; $columnIndex = substr($rowDatum,1) - 1;
@ -256,9 +256,9 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
// Read shared styles // Read shared styles
if ($dataType == 'P') { if ($dataType == 'P') {
$formatArray = array(); $formatArray = array();
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats,$toFormats,substr($rowDatum,1)); case 'P' : $formatArray['numberformat']['code'] = str_replace($fromFormats, $toFormats,substr($rowDatum,1));
break; break;
case 'E' : case 'E' :
case 'F' : $formatArray['font']['name'] = substr($rowDatum,1); case 'F' : $formatArray['font']['name'] = substr($rowDatum,1);
@ -290,8 +290,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} elseif ($dataType == 'C') { } elseif ($dataType == 'C') {
$hasCalculatedValue = false; $hasCalculatedValue = false;
$cellData = $cellDataFormula = ''; $cellData = $cellDataFormula = '';
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : $column = substr($rowDatum,1); case 'X' : $column = substr($rowDatum,1);
break; break;
@ -302,19 +302,19 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'E' : $cellDataFormula = '='.substr($rowDatum,1); case 'E' : $cellDataFormula = '='.substr($rowDatum,1);
// Convert R1C1 style references to A1 style references (but only when not quoted) // Convert R1C1 style references to A1 style references (but only when not quoted)
$temp = explode('"',$cellDataFormula); $temp = explode('"', $cellDataFormula);
$key = false; $key = false;
foreach($temp as &$value) { foreach ($temp as &$value) {
// Only count/replace in alternate array entries // Only count/replace in alternate array entries
if ($key = !$key) { if ($key = !$key) {
preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/',$value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE); preg_match_all('/(R(\[?-?\d*\]?))(C(\[?-?\d*\]?))/', $value, $cellReferences,PREG_SET_ORDER+PREG_OFFSET_CAPTURE);
// Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way // Reverse the matches array, otherwise all our offsets will become incorrect if we modify our way
// through the formula from left to right. Reversing means that we work right to left.through // through the formula from left to right. Reversing means that we work right to left.through
// the formula // the formula
$cellReferences = array_reverse($cellReferences); $cellReferences = array_reverse($cellReferences);
// Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent, // Loop through each R1C1 style reference in turn, converting it to its A1 style equivalent,
// then modify the formula to use that new reference // then modify the formula to use that new reference
foreach($cellReferences as $cellReference) { foreach ($cellReferences as $cellReference) {
$rowReference = $cellReference[2][0]; $rowReference = $cellReference[2][0];
// Empty R reference is the current row // Empty R reference is the current row
if ($rowReference == '') $rowReference = $row; if ($rowReference == '') $rowReference = $row;
@ -327,13 +327,13 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]'); if ($columnReference{0} == '[') $columnReference = $column + trim($columnReference,'[]');
$A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference; $A1CellReference = PHPExcel_Cell::stringFromColumnIndex($columnReference-1).$rowReference;
$value = substr_replace($value,$A1CellReference,$cellReference[0][1],strlen($cellReference[0][0])); $value = substr_replace($value, $A1CellReference, $cellReference[0][1],strlen($cellReference[0][0]));
} }
} }
} }
unset($value); unset($value);
// Then rebuild the formula string // Then rebuild the formula string
$cellDataFormula = implode('"',$temp); $cellDataFormula = implode('"', $temp);
$hasCalculatedValue = true; $hasCalculatedValue = true;
break; break;
} }
@ -351,8 +351,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} elseif ($dataType == 'F') { } elseif ($dataType == 'F') {
$formatStyle = $columnWidth = $styleSettings = ''; $formatStyle = $columnWidth = $styleSettings = '';
$styleData = array(); $styleData = array();
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : $column = substr($rowDatum,1); case 'X' : $column = substr($rowDatum,1);
break; break;
@ -361,7 +361,7 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
break; break;
case 'P' : $formatStyle = $rowDatum; case 'P' : $formatStyle = $rowDatum;
break; break;
case 'W' : list($startCol,$endCol,$columnWidth) = explode(' ',substr($rowDatum,1)); case 'W' : list($startCol, $endCol, $columnWidth) = explode(' ',substr($rowDatum,1));
break; break;
case 'S' : $styleSettings = substr($rowDatum,1); case 'S' : $styleSettings = substr($rowDatum,1);
for ($i=0;$i<strlen($styleSettings);++$i) { for ($i=0;$i<strlen($styleSettings);++$i) {
@ -407,8 +407,8 @@ class PHPExcel_Reader_SYLK extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
} }
} else { } else {
foreach($rowData as $rowDatum) { foreach ($rowData as $rowDatum) {
switch($rowDatum{0}) { switch ($rowDatum{0}) {
case 'C' : case 'C' :
case 'X' : $column = substr($rowDatum,1); case 'X' : $column = substr($rowDatum,1);
break; break;

View File

@ -416,7 +416,7 @@ class PHPExcel_ReferenceHelper
} }
// Loop through cells, bottom-up, and change cell coordinates // Loop through cells, bottom-up, and change cell coordinates
if($remove) { if ($remove) {
// It's faster to reverse and pop than to use unshift, especially with large cell collections // It's faster to reverse and pop than to use unshift, especially with large cell collections
$aCellCollection = array_reverse($aCellCollection); $aCellCollection = array_reverse($aCellCollection);
} }
@ -548,7 +548,7 @@ class PHPExcel_ReferenceHelper
if (count($autoFilterColumns) > 0) { if (count($autoFilterColumns) > 0) {
sscanf($pBefore,'%[A-Z]%d', $column, $row); sscanf($pBefore,'%[A-Z]%d', $column, $row);
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($autoFilterRange);
if ($columnIndex <= $rangeEnd[0]) { if ($columnIndex <= $rangeEnd[0]) {
if ($pNumCols < 0) { if ($pNumCols < 0) {
// If we're actually deleting any columns that fall within the autofilter range, // If we're actually deleting any columns that fall within the autofilter range,
@ -556,7 +556,7 @@ class PHPExcel_ReferenceHelper
$deleteColumn = $columnIndex + $pNumCols - 1; $deleteColumn = $columnIndex + $pNumCols - 1;
$deleteCount = abs($pNumCols); $deleteCount = abs($pNumCols);
for ($i = 1; $i <= $deleteCount; ++$i) { for ($i = 1; $i <= $deleteCount; ++$i) {
if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn),$autoFilterColumns)) { if (in_array(PHPExcel_Cell::stringFromColumnIndex($deleteColumn), $autoFilterColumns)) {
$autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn)); $autoFilter->clearColumn(PHPExcel_Cell::stringFromColumnIndex($deleteColumn));
} }
++$deleteColumn; ++$deleteColumn;
@ -586,7 +586,7 @@ class PHPExcel_ReferenceHelper
$toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1); $toColID = PHPExcel_Cell::stringFromColumnIndex($startCol+$pNumCols-1);
$endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]); $endColID = PHPExcel_Cell::stringFromColumnIndex($rangeEnd[0]);
do { do {
$autoFilter->shiftColumn($startColID,$toColID); $autoFilter->shiftColumn($startColID, $toColID);
++$startColID; ++$startColID;
++$toColID; ++$toColID;
} while ($startColID != $endColID); } while ($startColID != $endColID);
@ -644,9 +644,9 @@ class PHPExcel_ReferenceHelper
*/ */
public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') { public function updateFormulaReferences($pFormula = '', $pBefore = 'A1', $pNumCols = 0, $pNumRows = 0, $sheetName = '') {
// Update cell references in the formula // Update cell references in the formula
$formulaBlocks = explode('"',$pFormula); $formulaBlocks = explode('"', $pFormula);
$i = false; $i = false;
foreach($formulaBlocks as &$formulaBlock) { foreach ($formulaBlocks as &$formulaBlock) {
// Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode) // Ignore blocks that were enclosed in quotes (alternating entries in the $formulaBlocks array after the explode)
if ($i = !$i) { if ($i = !$i) {
$adjustCount = 0; $adjustCount = 0;
@ -654,11 +654,11 @@ class PHPExcel_ReferenceHelper
// Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5) // Search for row ranges (e.g. 'Sheet1'!3:5 or 3:5) with or without $ absolutes (e.g. $3:5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_ROWRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference('$A'.$match[3],$pBefore,$pNumCols,$pNumRows),2); $modified3 = substr($this->updateCellReference('$A'.$match[3], $pBefore, $pNumCols, $pNumRows),2);
$modified4 = substr($this->updateCellReference('$A'.$match[4],$pBefore,$pNumCols,$pNumRows),2); $modified4 = substr($this->updateCellReference('$A'.$match[4], $pBefore, $pNumCols, $pNumRows),2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
@ -679,11 +679,11 @@ class PHPExcel_ReferenceHelper
// Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E) // Search for column ranges (e.g. 'Sheet1'!C:E or C:E) with or without $ absolutes (e.g. $C:E)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_COLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = substr($this->updateCellReference($match[3].'$1',$pBefore,$pNumCols,$pNumRows),0,-2); $modified3 = substr($this->updateCellReference($match[3].'$1', $pBefore, $pNumCols, $pNumRows),0,-2);
$modified4 = substr($this->updateCellReference($match[4].'$1',$pBefore,$pNumCols,$pNumRows),0,-2); $modified4 = substr($this->updateCellReference($match[4].'$1', $pBefore, $pNumCols, $pNumRows),0,-2);
if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) { if ($match[3].':'.$match[4] !== $modified3.':'.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
@ -704,17 +704,17 @@ class PHPExcel_ReferenceHelper
// Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5) // Search for cell ranges (e.g. 'Sheet1'!A3:C5 or A3:C5) with or without $ absolutes (e.g. $A1:C$5)
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLRANGE.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3].':'.$match[4]; $fromString .= $match[3].':'.$match[4];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows); $modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
$modified4 = $this->updateCellReference($match[4],$pBefore,$pNumCols,$pNumRows); $modified4 = $this->updateCellReference($match[4], $pBefore, $pNumCols, $pNumRows);
if ($match[3].$match[4] !== $modified3.$modified4) { if ($match[3].$match[4] !== $modified3.$modified4) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3.':'.$modified4; $toString .= $modified3.':'.$modified4;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row,'$') + 10000000;
@ -731,16 +731,16 @@ class PHPExcel_ReferenceHelper
$matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER); $matchCount = preg_match_all('/'.self::REFHELPER_REGEXP_CELLREF.'/i', ' '.$formulaBlock.' ', $matches, PREG_SET_ORDER);
if ($matchCount > 0) { if ($matchCount > 0) {
foreach($matches as $match) { foreach ($matches as $match) {
$fromString = ($match[2] > '') ? $match[2].'!' : ''; $fromString = ($match[2] > '') ? $match[2].'!' : '';
$fromString .= $match[3]; $fromString .= $match[3];
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows); $modified3 = $this->updateCellReference($match[3], $pBefore, $pNumCols, $pNumRows);
if ($match[3] !== $modified3) { if ($match[3] !== $modified3) {
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) { if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
$toString = ($match[2] > '') ? $match[2].'!' : ''; $toString = ($match[2] > '') ? $match[2].'!' : '';
$toString .= $modified3; $toString .= $modified3;
list($column,$row) = PHPExcel_Cell::coordinateFromString($match[3]); list($column, $row) = PHPExcel_Cell::coordinateFromString($match[3]);
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more // Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
$column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000; $column = PHPExcel_Cell::columnIndexFromString(trim($column,'$')) + 100000;
$row = trim($row,'$') + 10000000; $row = trim($row,'$') + 10000000;
@ -761,14 +761,14 @@ class PHPExcel_ReferenceHelper
ksort($cellTokens); ksort($cellTokens);
ksort($newCellTokens); ksort($newCellTokens);
} // Update cell references in the formula } // Update cell references in the formula
$formulaBlock = str_replace('\\','',preg_replace($cellTokens,$newCellTokens,$formulaBlock)); $formulaBlock = str_replace('\\','',preg_replace($cellTokens, $newCellTokens, $formulaBlock));
} }
} }
} }
unset($formulaBlock); unset($formulaBlock);
// Then rebuild the formula string // Then rebuild the formula string
return implode('"',$formulaBlocks); return implode('"', $formulaBlocks);
} }
/** /**
@ -846,7 +846,7 @@ class PHPExcel_ReferenceHelper
if (ctype_alpha($range[$i][$j])) { if (ctype_alpha($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows)); $r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference($range[$i][$j].'1', $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[0]; $range[$i][$j] = $r[0];
} elseif(ctype_digit($range[$i][$j])) { } elseif (ctype_digit($range[$i][$j])) {
$r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows)); $r = PHPExcel_Cell::coordinateFromString($this->_updateSingleCellReference('A'.$range[$i][$j], $pBefore, $pNumCols, $pNumRows));
$range[$i][$j] = $r[1]; $range[$i][$j] = $r[1];
} else { } else {

View File

@ -162,7 +162,7 @@ class PHPExcel_Shared_Date
$seconds = round($time) - ($hours * 3600) - ($minutes * 60); $seconds = round($time) - ($hours * 3600) - ($minutes * 60);
$dateObj = date_create('1-Jan-1970+'.$days.' days'); $dateObj = date_create('1-Jan-1970+'.$days.' days');
$dateObj->setTime($hours,$minutes,$seconds); $dateObj->setTime($hours, $minutes, $seconds);
return $dateObj; return $dateObj;
} }
@ -188,8 +188,8 @@ class PHPExcel_Shared_Date
$dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s') $dateValue->format('H'), $dateValue->format('i'), $dateValue->format('s')
); );
} elseif (is_numeric($dateValue)) { } elseif (is_numeric($dateValue)) {
$retValue = self::FormattedPHPToExcel( date('Y',$dateValue), date('m',$dateValue), date('d',$dateValue), $retValue = self::FormattedPHPToExcel( date('Y', $dateValue), date('m', $dateValue), date('d', $dateValue),
date('H',$dateValue), date('i',$dateValue), date('s',$dateValue) date('H', $dateValue), date('i', $dateValue), date('s', $dateValue)
); );
} }
date_default_timezone_set($saveTimeZone); date_default_timezone_set($saveTimeZone);
@ -327,7 +327,7 @@ class PHPExcel_Shared_Date
// we don't want to test for any of our characters within the quoted blocks // we don't want to test for any of our characters within the quoted blocks
if (strpos($pFormatCode, '"') !== false) { if (strpos($pFormatCode, '"') !== false) {
$segMatcher = false; $segMatcher = false;
foreach(explode('"', $pFormatCode) as $subVal) { foreach (explode('"', $pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks) // Only test in alternate array entries (the non-quoted blocks)
if (($segMatcher = !$segMatcher) && if (($segMatcher = !$segMatcher) &&
(preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) { (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i', $subVal))) {
@ -376,7 +376,7 @@ class PHPExcel_Shared_Date
public static function monthStringToNumber($month) public static function monthStringToNumber($month)
{ {
$monthIndex = 1; $monthIndex = 1;
foreach(self::$monthNames as $shortMonthName => $longMonthName) { foreach (self::$monthNames as $shortMonthName => $longMonthName) {
if (($month === $longMonthName) || ($month === $shortMonthName)) { if (($month === $longMonthName) || ($month === $shortMonthName)) {
return $monthIndex; return $monthIndex;
} }

View File

@ -181,10 +181,10 @@ class PHPExcel_Shared_Drawing
// Load the image into a string // Load the image into a string
$file = fopen($p_sFile,"rb"); $file = fopen($p_sFile,"rb");
$read = fread($file,10); $read = fread($file,10);
while(!feof($file)&&($read<>"")) while (!feof($file)&&($read<>""))
$read .= fread($file,1024); $read .= fread($file,1024);
$temp = unpack("H*",$read); $temp = unpack("H*", $read);
$hex = $temp[1]; $hex = $temp[1];
$header = substr($hex,0,108); $header = substr($hex,0,108);
@ -210,7 +210,7 @@ class PHPExcel_Shared_Drawing
$y = 1; $y = 1;
// Create newimage // Create newimage
$image = imagecreatetruecolor($width,$height); $image = imagecreatetruecolor($width, $height);
// Grab the body from the image // Grab the body from the image
$body = substr($hex,108); $body = substr($hex,108);
@ -255,8 +255,8 @@ class PHPExcel_Shared_Drawing
$b = hexdec($body[$i_pos].$body[$i_pos+1]); $b = hexdec($body[$i_pos].$body[$i_pos+1]);
// Calculate and draw the pixel // Calculate and draw the pixel
$color = imagecolorallocate($image,$r,$g,$b); $color = imagecolorallocate($image, $r, $g, $b);
imagesetpixel($image,$x,$height-$y,$color); imagesetpixel($image, $x, $height-$y, $color);
// Raise the horizontal position // Raise the horizontal position
$x++; $x++;

View File

@ -111,7 +111,7 @@ class PHPExcel_Shared_File
// Found something? // Found something?
if ($returnValue == '' || ($returnValue === NULL)) { if ($returnValue == '' || ($returnValue === NULL)) {
$pathArray = explode('/' , $pFilename); $pathArray = explode('/' , $pFilename);
while(in_array('..', $pathArray) && $pathArray[0] != '..') { while (in_array('..', $pathArray) && $pathArray[0] != '..') {
for ($i = 0; $i < count($pathArray); ++$i) { for ($i = 0; $i < count($pathArray); ++$i) {
if ($pathArray[$i] == '..' && $i > 0) { if ($pathArray[$i] == '..' && $i > 0) {
unset($pathArray[$i]); unset($pathArray[$i]);

View File

@ -763,7 +763,7 @@ class EigenvalueDecomposition {
for ($j = $nn-1; $j >= $low; --$j) { for ($j = $nn-1; $j >= $low; --$j) {
for ($i = $low; $i <= $high; ++$i) { for ($i = $low; $i <= $high; ++$i) {
$z = 0.0; $z = 0.0;
for ($k = $low; $k <= min($j,$high); ++$k) { for ($k = $low; $k <= min($j, $high); ++$k) {
$z = $z + $this->V[$i][$k] * $this->H[$k][$j]; $z = $z + $this->V[$i][$k] * $this->H[$k][$j];
} }
$this->V[$i][$j] = $z; $this->V[$i][$j] = $z;

View File

@ -82,7 +82,7 @@ class PHPExcel_Shared_JAMA_LUDecomposition {
for ($i = 0; $i < $this->m; ++$i) { for ($i = 0; $i < $this->m; ++$i) {
$LUrowi = $this->LU[$i]; $LUrowi = $this->LU[$i];
// Most of the time is spent in the following dot product. // Most of the time is spent in the following dot product.
$kmax = min($i,$j); $kmax = min($i, $j);
$s = 0.0; $s = 0.0;
for ($k = 0; $k < $kmax; ++$k) { for ($k = 0; $k < $kmax; ++$k) {
$s += $LUrowi[$k] * $LUcolj[$k]; $s += $LUrowi[$k] * $LUcolj[$k];

View File

@ -68,7 +68,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
//Rectangular matrix - m x n initialized from 2D array //Rectangular matrix - m x n initialized from 2D array
case 'array': case 'array':
$this->m = count($args[0]); $this->m = count($args[0]);
@ -173,7 +173,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
//A($i0...; $j0...) //A($i0...; $j0...)
case 'integer,integer': case 'integer,integer':
list($i0, $j0) = $args; list($i0, $j0) = $args;
@ -426,7 +426,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -462,7 +462,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -512,7 +512,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -548,7 +548,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -599,7 +599,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -636,7 +636,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -687,7 +687,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -743,7 +743,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -780,7 +780,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -817,7 +817,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -853,7 +853,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $B = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
if ($this->n == $B->m) { if ($this->n == $B->m) {
@ -944,7 +944,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
break; break;
@ -969,7 +969,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value); $validValues &= PHPExcel_Shared_String::convertToNumberIfFraction($value);
} }
if ($validValues) { if ($validValues) {
$this->A[$i][$j] = pow($this->A[$i][$j],$value); $this->A[$i][$j] = pow($this->A[$i][$j], $value);
} else { } else {
$this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN(); $this->A[$i][$j] = PHPExcel_Calculation_Functions::NaN();
} }
@ -994,7 +994,7 @@ class PHPExcel_Shared_JAMA_Matrix {
$args = func_get_args(); $args = func_get_args();
$match = implode(",", array_map('gettype', $args)); $match = implode(",", array_map('gettype', $args));
switch($match) { switch ($match) {
case 'object': case 'object':
if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); } if ($args[0] instanceof PHPExcel_Shared_JAMA_Matrix) { $M = $args[0]; } else { throw new PHPExcel_Calculation_Exception(self::ArgumentTypeException); }
case 'array': case 'array':

View File

@ -52,7 +52,7 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
* @return Structure to access R and the Householder vectors and compute Q. * @return Structure to access R and the Householder vectors and compute Q.
*/ */
public function __construct($A) { public function __construct($A) {
if($A instanceof PHPExcel_Shared_JAMA_Matrix) { if ($A instanceof PHPExcel_Shared_JAMA_Matrix) {
// Initialize. // Initialize.
$this->QR = $A->getArrayCopy(); $this->QR = $A->getArrayCopy();
$this->m = $A->getRowDimension(); $this->m = $A->getRowDimension();
@ -175,7 +175,7 @@ class PHPExcel_Shared_JAMA_QRDecomposition {
/* /*
for($i = 0; $i < count($Q); ++$i) { for($i = 0; $i < count($Q); ++$i) {
for($j = 0; $j < count($Q); ++$j) { for($j = 0; $j < count($Q); ++$j) {
if(! isset($Q[$i][$j]) ) { if (! isset($Q[$i][$j]) ) {
$Q[$i][$j] = 0; $Q[$i][$j] = 0;
} }
} }

View File

@ -74,7 +74,7 @@ class SingularValueDecomposition {
// Reduce A to bidiagonal form, storing the diagonal elements // Reduce A to bidiagonal form, storing the diagonal elements
// in s and the super-diagonal elements in e. // in s and the super-diagonal elements in e.
for ($k = 0; $k < max($nct,$nrt); ++$k) { for ($k = 0; $k < max($nct, $nrt); ++$k) {
if ($k < $nct) { if ($k < $nct) {
// Compute the transformation for the k-th column and // Compute the transformation for the k-th column and
@ -291,7 +291,7 @@ class SingularValueDecomposition {
$f = $e[$p-2]; $f = $e[$p-2];
$e[$p-2] = 0.0; $e[$p-2] = 0.0;
for ($j = $p - 2; $j >= $k; --$j) { for ($j = $p - 2; $j >= $k; --$j) {
$t = hypo($this->s[$j],$f); $t = hypo($this->s[$j], $f);
$cs = $this->s[$j] / $t; $cs = $this->s[$j] / $t;
$sn = $f / $t; $sn = $f / $t;
$this->s[$j] = $t; $this->s[$j] = $t;
@ -353,7 +353,7 @@ class SingularValueDecomposition {
$g = $sk * $ek; $g = $sk * $ek;
// Chase zeros. // Chase zeros.
for ($j = $k; $j < $p-1; ++$j) { for ($j = $k; $j < $p-1; ++$j) {
$t = hypo($f,$g); $t = hypo($f, $g);
$cs = $f/$t; $cs = $f/$t;
$sn = $g/$t; $sn = $g/$t;
if ($j != $k) { if ($j != $k) {
@ -370,7 +370,7 @@ class SingularValueDecomposition {
$this->V[$i][$j] = $t; $this->V[$i][$j] = $t;
} }
} }
$t = hypo($f,$g); $t = hypo($f, $g);
$cs = $f/$t; $cs = $f/$t;
$sn = $g/$t; $sn = $g/$t;
$this->s[$j] = $t; $this->s[$j] = $t;

View File

@ -473,8 +473,8 @@ class PHPExcel_Shared_OLE
// days from 1-1-1601 until the beggining of UNIX era // days from 1-1-1601 until the beggining of UNIX era
$days = 134774; $days = 134774;
// calculate seconds // calculate seconds
$big_date = $days*24*3600 + gmmktime(date("H",$date),date("i",$date),date("s",$date), $big_date = $days*24*3600 + gmmktime(date("H", $date),date("i", $date),date("s", $date),
date("m",$date),date("d",$date),date("Y",$date)); date("m", $date),date("d", $date),date("Y", $date));
// multiply just to make MS happy // multiply just to make MS happy
$big_date *= 10000000; $big_date *= 10000000;

View File

@ -204,7 +204,7 @@ class PHPExcel_Shared_OLE_PPS
{ {
if ( !is_array($to_save) || (empty($to_save)) ) { if ( !is_array($to_save) || (empty($to_save)) ) {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} elseif( count($to_save) == 1 ) { } elseif ( count($to_save) == 1 ) {
$cnt = count($raList); $cnt = count($raList);
// If the first entry, it's the root... Don't clone it! // If the first entry, it's the root... Don't clone it!
$raList[$cnt] = ( $depth == 0 ) ? $to_save[0] : clone $to_save[0]; $raList[$cnt] = ( $depth == 0 ) ? $to_save[0] : clone $to_save[0];

View File

@ -271,7 +271,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
//if (isset($raList[$i]->_PPS_FILE)) { //if (isset($raList[$i]->_PPS_FILE)) {
// $iLen = 0; // $iLen = 0;
// fseek($raList[$i]->_PPS_FILE, 0); // To The Top // fseek($raList[$i]->_PPS_FILE, 0); // To The Top
// while($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) { // while ($sBuff = fread($raList[$i]->_PPS_FILE, 4096)) {
// $iLen += strlen($sBuff); // $iLen += strlen($sBuff);
// fwrite($FILE, $sBuff); // fwrite($FILE, $sBuff);
// } // }
@ -337,7 +337,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
$sRes .= $raList[$i]->_data; $sRes .= $raList[$i]->_data;
//} //}
if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) { if ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) {
$sRes .= str_repeat("\x00",$this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)); $sRes .= str_repeat("\x00", $this->_SMALL_BLOCK_SIZE - ($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE));
} }
// Set for PPS // Set for PPS
$raList[$i]->_StartBlock = $iSmBlk; $raList[$i]->_StartBlock = $iSmBlk;

View File

@ -76,7 +76,7 @@ class PHPExcel_Shared_OLERead {
public function read($sFileName) public function read($sFileName)
{ {
// Check if file exists and is readable // Check if file exists and is readable
if(!is_readable($sFileName)) { if (!is_readable($sFileName)) {
throw new PHPExcel_Reader_Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable."); throw new PHPExcel_Reader_Exception("Could not open " . $sFileName . " for reading! File does not exist, or it is not readable.");
} }
@ -254,7 +254,7 @@ class PHPExcel_Shared_OLERead {
$size = self::_GetInt4d($d, self::SIZE_POS); $size = self::_GetInt4d($d, self::SIZE_POS);
$name = str_replace("\x00", "", substr($d,0,$nameSize)); $name = str_replace("\x00", "", substr($d,0, $nameSize));
$this->props[] = array ( $this->props[] = array (

View File

@ -1837,13 +1837,13 @@
$v_memory_limit = trim($v_memory_limit); $v_memory_limit = trim($v_memory_limit);
$last = strtolower(substr($v_memory_limit, -1)); $last = strtolower(substr($v_memory_limit, -1));
if($last == 'g') if ($last == 'g')
//$v_memory_limit = $v_memory_limit*1024*1024*1024; //$v_memory_limit = $v_memory_limit*1024*1024*1024;
$v_memory_limit = $v_memory_limit*1073741824; $v_memory_limit = $v_memory_limit*1073741824;
if($last == 'm') if ($last == 'm')
//$v_memory_limit = $v_memory_limit*1024*1024; //$v_memory_limit = $v_memory_limit*1024*1024;
$v_memory_limit = $v_memory_limit*1048576; $v_memory_limit = $v_memory_limit*1048576;
if($last == 'k') if ($last == 'k')
$v_memory_limit = $v_memory_limit*1024; $v_memory_limit = $v_memory_limit*1024;
$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO); $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
@ -2412,7 +2412,7 @@
$v_offset = @ftell($this->zip_fd); $v_offset = @ftell($this->zip_fd);
// ----- Create the Central Dir files header // ----- Create the Central Dir files header
for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++) for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
{ {
// ----- Create the file header // ----- Create the file header
if ($v_header_list[$i]['status'] == 'ok') { if ($v_header_list[$i]['status'] == 'ok') {

View File

@ -330,10 +330,10 @@ class PHPExcel_Shared_String
} }
public static function buildCharacterSets() { public static function buildCharacterSets() {
if(empty(self::$_controlCharacters)) { if (empty(self::$_controlCharacters)) {
self::_buildControlCharacters(); self::_buildControlCharacters();
} }
if(empty(self::$_SYLKCharacters)) { if (empty(self::$_SYLKCharacters)) {
self::_buildSYLKCharacters(); self::_buildSYLKCharacters();
} }
} }
@ -436,19 +436,18 @@ class PHPExcel_Shared_String
// character count // character count
$ln = self::CountCharacters($value, 'UTF-8'); $ln = self::CountCharacters($value, 'UTF-8');
// option flags // option flags
if(empty($arrcRuns)){ if (empty($arrcRuns)) {
$opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ? $opt = (self::getIsIconvEnabled() || self::getIsMbstringEnabled()) ?
0x0001 : 0x0000; 0x0001 : 0x0000;
$data = pack('CC', $ln, $opt); $data = pack('CC', $ln, $opt);
// characters // characters
$data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
} } else {
else {
$data = pack('vC', $ln, 0x09); $data = pack('vC', $ln, 0x09);
$data .= pack('v', count($arrcRuns)); $data .= pack('v', count($arrcRuns));
// characters // characters
$data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8'); $data .= self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
foreach ($arrcRuns as $cRun){ foreach ($arrcRuns as $cRun) {
$data .= pack('v', $cRun['strlen']); $data .= pack('v', $cRun['strlen']);
$data .= pack('v', $cRun['fontidx']); $data .= pack('v', $cRun['fontidx']);
} }
@ -500,9 +499,9 @@ class PHPExcel_Shared_String
return mb_convert_encoding($value, $to, $from); return mb_convert_encoding($value, $to, $from);
} }
if($from == 'UTF-16LE'){ if ($from == 'UTF-16LE') {
return self::utf16_decode($value, false); return self::utf16_decode($value, false);
}else if($from == 'UTF-16BE'){ } else if ($from == 'UTF-16BE') {
return self::utf16_decode($value); return self::utf16_decode($value);
} }
// else, no conversion // else, no conversion
@ -525,15 +524,15 @@ class PHPExcel_Shared_String
* @author vadik56 * @author vadik56
*/ */
public static function utf16_decode($str, $bom_be = TRUE) { public static function utf16_decode($str, $bom_be = TRUE) {
if( strlen($str) < 2 ) return $str; if ( strlen($str) < 2 ) return $str;
$c0 = ord($str{0}); $c0 = ord($str{0});
$c1 = ord($str{1}); $c1 = ord($str{1});
if( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); } if ( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); }
elseif( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; } elseif ( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; }
$len = strlen($str); $len = strlen($str);
$newstr = ''; $newstr = '';
for($i=0;$i<$len;$i+=2) { for($i=0;$i<$len;$i+=2) {
if( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); } if ( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); }
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); } else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); }
$newstr .= ($val == 0x228) ? "\n" : chr($val); $newstr .= ($val == 0x228) ? "\n" : chr($val);
} }
@ -649,8 +648,8 @@ class PHPExcel_Shared_String
{ {
if (self::getIsMbstringEnabled()) { if (self::getIsMbstringEnabled()) {
$characters = self::mb_str_split($pValue); $characters = self::mb_str_split($pValue);
foreach($characters as &$character) { foreach ($characters as &$character) {
if(self::mb_is_upper($character)) { if (self::mb_is_upper($character)) {
$character = mb_strtolower($character, 'UTF-8'); $character = mb_strtolower($character, 'UTF-8');
} else { } else {
$character = mb_strtoupper($character, 'UTF-8'); $character = mb_strtoupper($character, 'UTF-8');

View File

@ -129,7 +129,7 @@ class PHPExcel_Shared_TimeZone
$objTimezone = new DateTimeZone($timezone); $objTimezone = new DateTimeZone($timezone);
if (version_compare(PHP_VERSION, '5.3.0') >= 0) { if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$transitions = $objTimezone->getTransitions($timestamp,$timestamp); $transitions = $objTimezone->getTransitions($timestamp, $timestamp);
} else { } else {
$transitions = self::_getTimezoneTransitions($objTimezone, $timestamp); $transitions = self::_getTimezoneTransitions($objTimezone, $timestamp);
} }

View File

@ -115,7 +115,7 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
public function writeRawData($text) public function writeRawData($text)
{ {
if (is_array($text)) { if (is_array($text)) {
$text = implode("\n",$text); $text = implode("\n", $text);
} }
if (method_exists($this, 'writeRaw')) { if (method_exists($this, 'writeRaw')) {

View File

@ -174,7 +174,7 @@ class PHPExcel_Best_Fit
*/ */
public function getSlope($dp=0) { public function getSlope($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_slope,$dp); return round($this->_slope, $dp);
} }
return $this->_slope; return $this->_slope;
} // function getSlope() } // function getSlope()
@ -188,7 +188,7 @@ class PHPExcel_Best_Fit
*/ */
public function getSlopeSE($dp=0) { public function getSlopeSE($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_slopeSE,$dp); return round($this->_slopeSE, $dp);
} }
return $this->_slopeSE; return $this->_slopeSE;
} // function getSlopeSE() } // function getSlopeSE()
@ -202,7 +202,7 @@ class PHPExcel_Best_Fit
*/ */
public function getIntersect($dp=0) { public function getIntersect($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_intersect,$dp); return round($this->_intersect, $dp);
} }
return $this->_intersect; return $this->_intersect;
} // function getIntersect() } // function getIntersect()
@ -216,7 +216,7 @@ class PHPExcel_Best_Fit
*/ */
public function getIntersectSE($dp=0) { public function getIntersectSE($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_intersectSE,$dp); return round($this->_intersectSE, $dp);
} }
return $this->_intersectSE; return $this->_intersectSE;
} // function getIntersectSE() } // function getIntersectSE()
@ -230,7 +230,7 @@ class PHPExcel_Best_Fit
*/ */
public function getGoodnessOfFit($dp=0) { public function getGoodnessOfFit($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_goodnessOfFit,$dp); return round($this->_goodnessOfFit, $dp);
} }
return $this->_goodnessOfFit; return $this->_goodnessOfFit;
} // function getGoodnessOfFit() } // function getGoodnessOfFit()
@ -238,7 +238,7 @@ class PHPExcel_Best_Fit
public function getGoodnessOfFitPercent($dp=0) { public function getGoodnessOfFitPercent($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_goodnessOfFit * 100,$dp); return round($this->_goodnessOfFit * 100, $dp);
} }
return $this->_goodnessOfFit * 100; return $this->_goodnessOfFit * 100;
} // function getGoodnessOfFitPercent() } // function getGoodnessOfFitPercent()
@ -252,7 +252,7 @@ class PHPExcel_Best_Fit
*/ */
public function getStdevOfResiduals($dp=0) { public function getStdevOfResiduals($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_stdevOfResiduals,$dp); return round($this->_stdevOfResiduals, $dp);
} }
return $this->_stdevOfResiduals; return $this->_stdevOfResiduals;
} // function getStdevOfResiduals() } // function getStdevOfResiduals()
@ -260,7 +260,7 @@ class PHPExcel_Best_Fit
public function getSSRegression($dp=0) { public function getSSRegression($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_SSRegression,$dp); return round($this->_SSRegression, $dp);
} }
return $this->_SSRegression; return $this->_SSRegression;
} // function getSSRegression() } // function getSSRegression()
@ -268,7 +268,7 @@ class PHPExcel_Best_Fit
public function getSSResiduals($dp=0) { public function getSSResiduals($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_SSResiduals,$dp); return round($this->_SSResiduals, $dp);
} }
return $this->_SSResiduals; return $this->_SSResiduals;
} // function getSSResiduals() } // function getSSResiduals()
@ -276,7 +276,7 @@ class PHPExcel_Best_Fit
public function getDFResiduals($dp=0) { public function getDFResiduals($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_DFResiduals,$dp); return round($this->_DFResiduals, $dp);
} }
return $this->_DFResiduals; return $this->_DFResiduals;
} // function getDFResiduals() } // function getDFResiduals()
@ -284,7 +284,7 @@ class PHPExcel_Best_Fit
public function getF($dp=0) { public function getF($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_F,$dp); return round($this->_F, $dp);
} }
return $this->_F; return $this->_F;
} // function getF() } // function getF()
@ -292,7 +292,7 @@ class PHPExcel_Best_Fit
public function getCovariance($dp=0) { public function getCovariance($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_covariance,$dp); return round($this->_covariance, $dp);
} }
return $this->_covariance; return $this->_covariance;
} // function getCovariance() } // function getCovariance()
@ -300,7 +300,7 @@ class PHPExcel_Best_Fit
public function getCorrelation($dp=0) { public function getCorrelation($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round($this->_correlation,$dp); return round($this->_correlation, $dp);
} }
return $this->_correlation; return $this->_correlation;
} // function getCorrelation() } // function getCorrelation()
@ -311,9 +311,9 @@ class PHPExcel_Best_Fit
} // function getYBestFitValues() } // function getYBestFitValues()
protected function _calculateGoodnessOfFit($sumX,$sumY,$sumX2,$sumY2,$sumXY,$meanX,$meanY, $const) { protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const) {
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0; $SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
foreach($this->_xValues as $xKey => $xValue) { foreach ($this->_xValues as $xKey => $xValue) {
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue); $bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
$SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY); $SSres += ($this->_yValues[$xKey] - $bestFitY) * ($this->_yValues[$xKey] - $bestFitY);
@ -398,7 +398,7 @@ class PHPExcel_Best_Fit
$this->_intersect = 0; $this->_intersect = 0;
} }
$this->_calculateGoodnessOfFit($x_sum,$y_sum,$xx_sum,$yy_sum,$xy_sum,$meanX,$meanY,$const); $this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
} // function _leastSquareFit() } // function _leastSquareFit()
@ -416,7 +416,7 @@ class PHPExcel_Best_Fit
// Define X Values if necessary // Define X Values if necessary
if ($nX == 0) { if ($nX == 0) {
$xValues = range(1,$nY); $xValues = range(1, $nY);
$nX = $nY; $nX = $nY;
} elseif ($nY != $nX) { } elseif ($nY != $nX) {
// Ensure both arrays of points are the same size // Ensure both arrays of points are the same size

View File

@ -91,7 +91,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
**/ **/
public function getSlope($dp=0) { public function getSlope($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_slope),$dp); return round(exp($this->_slope), $dp);
} }
return exp($this->_slope); return exp($this->_slope);
} // function getSlope() } // function getSlope()
@ -105,7 +105,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
**/ **/
public function getIntersect($dp=0) { public function getIntersect($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_intersect),$dp); return round(exp($this->_intersect), $dp);
} }
return exp($this->_intersect); return exp($this->_intersect);
} // function getIntersect() } // function getIntersect()
@ -119,7 +119,7 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _exponential_regression($yValues, $xValues, $const) { private function _exponential_regression($yValues, $xValues, $const) {
foreach($yValues as &$value) { foreach ($yValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {

View File

@ -91,7 +91,7 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _linear_regression($yValues, $xValues, $const) { private function _linear_regression($yValues, $xValues, $const) {
$this->_leastSquareFit($yValues, $xValues,$const); $this->_leastSquareFit($yValues, $xValues, $const);
} // function _linear_regression() } // function _linear_regression()

View File

@ -91,7 +91,7 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _logarithmic_regression($yValues, $xValues, $const) { private function _logarithmic_regression($yValues, $xValues, $const) {
foreach($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {

View File

@ -75,7 +75,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue) {
$retVal = $this->getIntersect(); $retVal = $this->getIntersect();
$slope = $this->getSlope(); $slope = $this->getSlope();
foreach($slope as $key => $value) { foreach ($slope as $key => $value) {
if ($value != 0.0) { if ($value != 0.0) {
$retVal += $value * pow($xValue, $key + 1); $retVal += $value * pow($xValue, $key + 1);
} }
@ -106,7 +106,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
$equation = 'Y = '.$intersect; $equation = 'Y = '.$intersect;
foreach($slope as $key => $value) { foreach ($slope as $key => $value) {
if ($value != 0.0) { if ($value != 0.0) {
$equation .= ' + '.$value.' * X'; $equation .= ' + '.$value.' * X';
if ($key > 0) { if ($key > 0) {
@ -127,8 +127,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
public function getSlope($dp=0) { public function getSlope($dp=0) {
if ($dp != 0) { if ($dp != 0) {
$coefficients = array(); $coefficients = array();
foreach($this->_slope as $coefficient) { foreach ($this->_slope as $coefficient) {
$coefficients[] = round($coefficient,$dp); $coefficients[] = round($coefficient, $dp);
} }
return $coefficients; return $coefficients;
} }
@ -137,7 +137,7 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
public function getCoefficients($dp=0) { public function getCoefficients($dp=0) {
return array_merge(array($this->getIntersect($dp)),$this->getSlope($dp)); return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
} // function getCoefficients() } // function getCoefficients()
@ -191,8 +191,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
$this->_intersect = array_shift($coefficients); $this->_intersect = array_shift($coefficients);
$this->_slope = $coefficients; $this->_slope = $coefficients;
$this->_calculateGoodnessOfFit($x_sum,$y_sum,$xx_sum,$yy_sum,$xy_sum); $this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum);
foreach($this->_xValues as $xKey => $xValue) { foreach ($this->_xValues as $xKey => $xValue) {
$this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue); $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
} }
} // function _polynomial_regression() } // function _polynomial_regression()

View File

@ -54,7 +54,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @return float Y-Value * @return float Y-Value
**/ **/
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue) {
return $this->getIntersect() * pow(($xValue - $this->_Xoffset),$this->getSlope()); return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope());
} // function getValueOfYForX() } // function getValueOfYForX()
@ -91,7 +91,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
**/ **/
public function getIntersect($dp=0) { public function getIntersect($dp=0) {
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_intersect),$dp); return round(exp($this->_intersect), $dp);
} }
return exp($this->_intersect); return exp($this->_intersect);
} // function getIntersect() } // function getIntersect()
@ -105,7 +105,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param boolean $const * @param boolean $const
*/ */
private function _power_regression($yValues, $xValues, $const) { private function _power_regression($yValues, $xValues, $const) {
foreach($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {
@ -113,7 +113,7 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
} }
} }
unset($value); unset($value);
foreach($yValues as &$value) { foreach ($yValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
} elseif ($value > 0.0) { } elseif ($value > 0.0) {

View File

@ -91,7 +91,7 @@ class trendClass
// Define X Values if necessary // Define X Values if necessary
if ($nX == 0) { if ($nX == 0) {
$xValues = range(1,$nY); $xValues = range(1, $nY);
$nX = $nY; $nX = $nY;
} elseif ($nY != $nX) { } elseif ($nY != $nX) {
// Ensure both arrays of points are the same size // Ensure both arrays of points are the same size
@ -108,7 +108,7 @@ class trendClass
case self::TREND_POWER : case self::TREND_POWER :
if (!isset(self::$_trendCache[$key])) { if (!isset(self::$_trendCache[$key])) {
$className = 'PHPExcel_'.$trendType.'_Best_Fit'; $className = 'PHPExcel_'.$trendType.'_Best_Fit';
self::$_trendCache[$key] = new $className($yValues,$xValues,$const); self::$_trendCache[$key] = new $className($yValues, $xValues, $const);
} }
return self::$_trendCache[$key]; return self::$_trendCache[$key];
break; break;
@ -119,7 +119,7 @@ class trendClass
case self::TREND_POLYNOMIAL_6 : case self::TREND_POLYNOMIAL_6 :
if (!isset(self::$_trendCache[$key])) { if (!isset(self::$_trendCache[$key])) {
$order = substr($trendType,-1); $order = substr($trendType,-1);
self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order,$yValues,$xValues,$const); self::$_trendCache[$key] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
} }
return self::$_trendCache[$key]; return self::$_trendCache[$key];
break; break;
@ -127,15 +127,15 @@ class trendClass
case self::TREND_BEST_FIT_NO_POLY : case self::TREND_BEST_FIT_NO_POLY :
// If the request is to determine the best fit regression, then we test each trend line in turn // If the request is to determine the best fit regression, then we test each trend line in turn
// Start by generating an instance of each available trend method // Start by generating an instance of each available trend method
foreach(self::$_trendTypes as $trendMethod) { foreach (self::$_trendTypes as $trendMethod) {
$className = 'PHPExcel_'.$trendMethod.'BestFit'; $className = 'PHPExcel_'.$trendMethod.'BestFit';
$bestFit[$trendMethod] = new $className($yValues,$xValues,$const); $bestFit[$trendMethod] = new $className($yValues, $xValues, $const);
$bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit(); $bestFitValue[$trendMethod] = $bestFit[$trendMethod]->getGoodnessOfFit();
} }
if ($trendType != self::TREND_BEST_FIT_NO_POLY) { if ($trendType != self::TREND_BEST_FIT_NO_POLY) {
foreach(self::$_trendTypePolyOrders as $trendMethod) { foreach (self::$_trendTypePolyOrders as $trendMethod) {
$order = substr($trendMethod,-1); $order = substr($trendMethod,-1);
$bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order,$yValues,$xValues,$const); $bestFit[$trendMethod] = new PHPExcel_Polynomial_Best_Fit($order, $yValues, $xValues, $const);
if ($bestFit[$trendMethod]->getError()) { if ($bestFit[$trendMethod]->getError()) {
unset($bestFit[$trendMethod]); unset($bestFit[$trendMethod]);
} else { } else {

View File

@ -378,7 +378,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
*/ */
public function disconnectCells() { public function disconnectCells() {
if ( $this->_cellCollection !== NULL){ if ( $this->_cellCollection !== NULL) {
$this->_cellCollection->unsetWorksheetCells(); $this->_cellCollection->unsetWorksheetCells();
$this->_cellCollection = NULL; $this->_cellCollection = NULL;
} }
@ -620,7 +620,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getChartNames() public function getChartNames()
{ {
$chartNames = array(); $chartNames = array();
foreach($this->_chartCollection as $chart) { foreach ($this->_chartCollection as $chart) {
$chartNames[] = $chart->getName(); $chartNames[] = $chart->getName();
} }
return $chartNames; return $chartNames;
@ -639,7 +639,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ($chartCount == 0) { if ($chartCount == 0) {
return false; return false;
} }
foreach($this->_chartCollection as $index => $chart) { foreach ($this->_chartCollection as $index => $chart) {
if ($chart->getName() == $chartName) { if ($chart->getName() == $chartName) {
return $this->_chartCollection[$index]; return $this->_chartCollection[$index];
} }
@ -858,7 +858,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
} }
$altTitle = $pValue . ' ' . $i; $altTitle = $pValue . ' ' . $i;
return $this->setTitle($altTitle,$updateFormulaCellReferences); return $this->setTitle($altTitle, $updateFormulaCellReferences);
} }
} }
@ -1314,7 +1314,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
return NULL; return NULL;
$this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow); $this->_rowDimensions[$pRow] = new PHPExcel_Worksheet_RowDimension($pRow);
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow); $this->_cachedHighestRow = max($this->_cachedHighestRow, $pRow);
} }
return $this->_rowDimensions[$pRow]; return $this->_rowDimensions[$pRow];
} }
@ -1571,7 +1571,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '') public function duplicateConditionalStyle(array $pCellStyle = null, $pRange = '')
{ {
foreach($pCellStyle as $cellStyle) { foreach ($pCellStyle as $cellStyle) {
if (!($cellStyle instanceof PHPExcel_Style_Conditional)) { if (!($cellStyle instanceof PHPExcel_Style_Conditional)) {
throw new PHPExcel_Exception('Style is not a conditional style'); throw new PHPExcel_Exception('Style is not a conditional style');
} }
@ -1899,7 +1899,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if (is_string($pValue)) { if (is_string($pValue)) {
$this->_autoFilter->setRange($pValue); $this->_autoFilter->setRange($pValue);
} elseif(is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) { } elseif (is_object($pValue) && ($pValue instanceof PHPExcel_Worksheet_AutoFilter)) {
$this->_autoFilter = $pValue; $this->_autoFilter = $pValue;
} }
return $this; return $this;
@ -2406,7 +2406,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Loop through $source // Loop through $source
foreach ($source as $rowData) { foreach ($source as $rowData) {
$currentColumn = $startColumn; $currentColumn = $startColumn;
foreach($rowData as $cellValue) { foreach ($rowData as $cellValue) {
if ($strictNullComparison) { if ($strictNullComparison) {
if ($cellValue !== $nullValue) { if ($cellValue !== $nullValue) {
// Set cell value // Set cell value
@ -2600,7 +2600,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Loop through row dimensions // Loop through row dimensions
foreach ($this->_rowDimensions as $dimension) { foreach ($this->_rowDimensions as $dimension) {
$highestRow = max($highestRow,$dimension->getRowIndex()); $highestRow = max($highestRow, $dimension->getRowIndex());
} }
// Cache values // Cache values
@ -2779,7 +2779,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$maxRow = $this->getHighestRow(); $maxRow = $this->getHighestRow();
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol); $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
$rangeBlocks = explode(' ',$range); $rangeBlocks = explode(' ', $range);
foreach ($rangeBlocks as &$rangeSet) { foreach ($rangeBlocks as &$rangeSet) {
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet); $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
@ -2790,7 +2790,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1]; $rangeSet = $rangeBoundaries[0][0].$rangeBoundaries[0][1].':'.$rangeBoundaries[1][0].$rangeBoundaries[1][1];
} }
unset($rangeSet); unset($rangeSet);
$stRange = implode(' ',$rangeBlocks); $stRange = implode(' ', $rangeBlocks);
return $stRange; return $stRange;
} }
@ -2876,7 +2876,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return objWorksheet * @return objWorksheet
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function setCodeName($pValue=null){ public function setCodeName($pValue=null) {
// Is this a 'rename' or not? // Is this a 'rename' or not?
if ($this->getCodeName() == $pValue) { if ($this->getCodeName() == $pValue) {
return $this; return $this;
@ -2912,7 +2912,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$pValue = $pValue . '_' . $i;// ok, we have a valid name $pValue = $pValue . '_' . $i;// ok, we have a valid name
//codeName is'nt used in formula : no need to call for an update //codeName is'nt used in formula : no need to call for an update
//return $this->setTitle($altTitle,$updateFormulaCellReferences); //return $this->setTitle($altTitle, $updateFormulaCellReferences);
} }
} }
@ -2924,14 +2924,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return null|string * @return null|string
*/ */
public function getCodeName(){ public function getCodeName() {
return $this->_codeName; return $this->_codeName;
} }
/** /**
* Sheet has a code name ? * Sheet has a code name ?
* @return boolean * @return boolean
*/ */
public function hasCodeName(){ public function hasCodeName() {
return !(is_null($this->_codeName)); return !(is_null($this->_codeName));
} }
} }

View File

@ -112,12 +112,12 @@ class PHPExcel_Worksheet_AutoFilter
// Uppercase coordinate // Uppercase coordinate
$cellAddress = explode('!',strtoupper($pRange)); $cellAddress = explode('!',strtoupper($pRange));
if (count($cellAddress) > 1) { if (count($cellAddress) > 1) {
list($worksheet,$pRange) = $cellAddress; list($worksheet, $pRange) = $cellAddress;
} }
if (strpos($pRange,':') !== FALSE) { if (strpos($pRange,':') !== FALSE) {
$this->_range = $pRange; $this->_range = $pRange;
} elseif(empty($pRange)) { } elseif (empty($pRange)) {
$this->_range = ''; $this->_range = '';
} else { } else {
throw new PHPExcel_Exception('Autofilter must be set on a range of cells.'); throw new PHPExcel_Exception('Autofilter must be set on a range of cells.');
@ -128,8 +128,8 @@ class PHPExcel_Worksheet_AutoFilter
$this->_columns = array(); $this->_columns = array();
} else { } else {
// Discard any column rules that are no longer valid within this range // Discard any column rules that are no longer valid within this range
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
foreach($this->_columns as $key => $value) { foreach ($this->_columns as $key => $value) {
$colIndex = PHPExcel_Cell::columnIndexFromString($key); $colIndex = PHPExcel_Cell::columnIndexFromString($key);
if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) { if (($rangeStart[0] > $colIndex) || ($rangeEnd[0] < $colIndex)) {
unset($this->_columns[$key]); unset($this->_columns[$key]);
@ -163,7 +163,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
$columnIndex = PHPExcel_Cell::columnIndexFromString($column); $columnIndex = PHPExcel_Cell::columnIndexFromString($column);
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) { if (($rangeStart[0] > $columnIndex) || ($rangeEnd[0] < $columnIndex)) {
throw new PHPExcel_Exception("Column is outside of current autofilter range."); throw new PHPExcel_Exception("Column is outside of current autofilter range.");
} }
@ -207,7 +207,7 @@ class PHPExcel_Worksheet_AutoFilter
* @return PHPExcel_Worksheet_AutoFilter_Column * @return PHPExcel_Worksheet_AutoFilter_Column
*/ */
public function getColumnByOffset($pColumnOffset = 0) { public function getColumnByOffset($pColumnOffset = 0) {
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
$pColumn = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1); $pColumn = PHPExcel_Cell::stringFromColumnIndex($rangeStart[0] + $pColumnOffset - 1);
return $this->getColumn($pColumn); return $this->getColumn($pColumn);
@ -225,7 +225,7 @@ class PHPExcel_Worksheet_AutoFilter
{ {
if ((is_string($pColumn)) && (!empty($pColumn))) { if ((is_string($pColumn)) && (!empty($pColumn))) {
$column = $pColumn; $column = $pColumn;
} elseif(is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) { } elseif (is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) {
$column = $pColumn->getColumnIndex(); $column = $pColumn->getColumnIndex();
} else { } else {
throw new PHPExcel_Exception("Column is not within the autofilter range."); throw new PHPExcel_Exception("Column is not within the autofilter range.");
@ -234,7 +234,7 @@ class PHPExcel_Worksheet_AutoFilter
if (is_string($pColumn)) { if (is_string($pColumn)) {
$this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this); $this->_columns[$pColumn] = new PHPExcel_Worksheet_AutoFilter_Column($pColumn, $this);
} elseif(is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) { } elseif (is_object($pColumn) && ($pColumn instanceof PHPExcel_Worksheet_AutoFilter_Column)) {
$pColumn->setParent($this); $pColumn->setParent($this);
$this->_columns[$column] = $pColumn; $this->_columns[$column] = $pColumn;
} }
@ -271,7 +271,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param string $toColumn Column name (e.g. B) * @param string $toColumn Column name (e.g. B)
* @return PHPExcel_Worksheet_AutoFilter * @return PHPExcel_Worksheet_AutoFilter
*/ */
public function shiftColumn($fromColumn=NULL,$toColumn=NULL) { public function shiftColumn($fromColumn=NULL, $toColumn=NULL) {
$fromColumn = strtoupper($fromColumn); $fromColumn = strtoupper($fromColumn);
$toColumn = strtoupper($toColumn); $toColumn = strtoupper($toColumn);
@ -296,14 +296,14 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $dataSet * @param mixed[] $dataSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInSimpleDataSet($cellValue,$dataSet) private static function _filterTestInSimpleDataSet($cellValue, $dataSet)
{ {
$dataSetValues = $dataSet['filterValues']; $dataSetValues = $dataSet['filterValues'];
$blanks = $dataSet['blanks']; $blanks = $dataSet['blanks'];
if (($cellValue == '') || ($cellValue === NULL)) { if (($cellValue == '') || ($cellValue === NULL)) {
return $blanks; return $blanks;
} }
return in_array($cellValue,$dataSetValues); return in_array($cellValue, $dataSetValues);
} }
/** /**
@ -313,7 +313,7 @@ class PHPExcel_Worksheet_AutoFilter
* @param mixed[] $dataSet * @param mixed[] $dataSet
* @return boolean * @return boolean
*/ */
private static function _filterTestInDateGroupSet($cellValue,$dataSet) private static function _filterTestInDateGroupSet($cellValue, $dataSet)
{ {
$dateSet = $dataSet['filterValues']; $dateSet = $dataSet['filterValues'];
$blanks = $dataSet['blanks']; $blanks = $dataSet['blanks'];
@ -325,18 +325,18 @@ class PHPExcel_Worksheet_AutoFilter
$dateValue = PHPExcel_Shared_Date::ExcelToPHP($cellValue); $dateValue = PHPExcel_Shared_Date::ExcelToPHP($cellValue);
if ($cellValue < 1) { if ($cellValue < 1) {
// Just the time part // Just the time part
$dtVal = date('His',$dateValue); $dtVal = date('His', $dateValue);
$dateSet = $dateSet['time']; $dateSet = $dateSet['time'];
} elseif($cellValue == floor($cellValue)) { } elseif ($cellValue == floor($cellValue)) {
// Just the date part // Just the date part
$dtVal = date('Ymd',$dateValue); $dtVal = date('Ymd', $dateValue);
$dateSet = $dateSet['date']; $dateSet = $dateSet['date'];
} else { } else {
// date and time parts // date and time parts
$dtVal = date('YmdHis',$dateValue); $dtVal = date('YmdHis', $dateValue);
$dateSet = $dateSet['dateTime']; $dateSet = $dateSet['dateTime'];
} }
foreach($dateSet as $dateValue) { foreach ($dateSet as $dateValue) {
// Use of substr to extract value at the appropriate group level // Use of substr to extract value at the appropriate group level
if (substr($dtVal,0,strlen($dateValue)) == $dateValue) if (substr($dtVal,0,strlen($dateValue)) == $dateValue)
return TRUE; return TRUE;
@ -366,7 +366,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
} }
$returnVal = ($join == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND); $returnVal = ($join == PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_COLUMN_JOIN_AND);
foreach($dataSet as $rule) { foreach ($dataSet as $rule) {
if (is_numeric($rule['value'])) { if (is_numeric($rule['value'])) {
// Numeric values are tested using the appropriate operator // Numeric values are tested using the appropriate operator
switch ($rule['operator']) { switch ($rule['operator']) {
@ -389,7 +389,7 @@ class PHPExcel_Worksheet_AutoFilter
$retVal = ($cellValue <= $rule['value']); $retVal = ($cellValue <= $rule['value']);
break; break;
} }
} elseif($rule['value'] == '') { } elseif ($rule['value'] == '') {
switch ($rule['operator']) { switch ($rule['operator']) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_EQUAL :
$retVal = (($cellValue == '') || ($cellValue === NULL)); $retVal = (($cellValue == '') || ($cellValue === NULL));
@ -403,7 +403,7 @@ class PHPExcel_Worksheet_AutoFilter
} }
} else { } else {
// String values are always tested for equality, factoring in for wildcards (hence a regexp test) // String values are always tested for equality, factoring in for wildcards (hence a regexp test)
$retVal = preg_match('/^'.$rule['value'].'$/i',$cellValue); $retVal = preg_match('/^'.$rule['value'].'$/i', $cellValue);
} }
// If there are multiple conditions, then we need to test both using the appropriate join operator // If there are multiple conditions, then we need to test both using the appropriate join operator
switch ($join) { switch ($join) {
@ -439,7 +439,7 @@ class PHPExcel_Worksheet_AutoFilter
if (is_numeric($cellValue)) { if (is_numeric($cellValue)) {
$dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue)); $dateValue = date('m',PHPExcel_Shared_Date::ExcelToPHP($cellValue));
if (in_array($dateValue,$monthSet)) { if (in_array($dateValue, $monthSet)) {
return TRUE; return TRUE;
} }
} }
@ -474,28 +474,28 @@ class PHPExcel_Worksheet_AutoFilter
// Calculate start/end dates for the required date range based on current date // Calculate start/end dates for the required date range based on current date
switch ($dynamicRuleType) { switch ($dynamicRuleType) {
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
$baseDate = strtotime('-7 days',$baseDate); $baseDate = strtotime('-7 days', $baseDate);
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
$baseDate = strtotime('-7 days',$baseDate); $baseDate = strtotime('-7 days', $baseDate);
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
$baseDate = strtotime('-1 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('-1 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
$baseDate = strtotime('+1 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('+1 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
$baseDate = strtotime('-3 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('-3 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
$baseDate = strtotime('+3 month',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('+3 month',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
$baseDate = strtotime('-1 year',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('-1 year',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
$baseDate = strtotime('+1 year',gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $baseDate = strtotime('+1 year',gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
} }
@ -503,40 +503,40 @@ class PHPExcel_Worksheet_AutoFilter
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TODAY :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YESTERDAY :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_TOMORROW :
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day',$baseDate)); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate); $val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate);
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE :
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day',$baseDate)); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(strtotime('+1 day', $baseDate));
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISYEAR :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTYEAR :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTYEAR :
$maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,31,12,date('Y',$baseDate))); $maxVal = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,31,12,date('Y', $baseDate)));
++$maxVal; ++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1,date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISQUARTER :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTQUARTER :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTQUARTER :
$thisMonth = date('m',$baseDate); $thisMonth = date('m', $baseDate);
$thisQuarter = floor(--$thisMonth / 3); $thisQuarter = floor(--$thisMonth / 3);
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t',$baseDate),(1+$thisQuarter)*3,date('Y',$baseDate))); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t', $baseDate),(1+$thisQuarter)*3,date('Y', $baseDate)));
++$maxVal; ++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1+$thisQuarter*3,date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,1+$thisQuarter*3,date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISMONTH :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTMONTH :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTMONTH :
$maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t',$baseDate),date('m',$baseDate),date('Y',$baseDate))); $maxVal = (int) PHPExcel_Shared_Date::PHPtoExcel(gmmktime(0,0,0,date('t', $baseDate),date('m', $baseDate),date('Y', $baseDate)));
++$maxVal; ++$maxVal;
$val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,date('m',$baseDate),date('Y',$baseDate))); $val = (int) PHPExcel_Shared_Date::PHPToExcel(gmmktime(0,0,0,1,date('m', $baseDate),date('Y', $baseDate)));
break; break;
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_THISWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_LASTWEEK :
case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK : case PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_NEXTWEEK :
$dayOfWeek = date('w',$baseDate); $dayOfWeek = date('w', $baseDate);
$val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek; $val = (int) PHPExcel_Shared_Date::PHPToExcel($baseDate) - $dayOfWeek;
$maxVal = $val + 7; $maxVal = $val + 7;
break; break;
@ -577,7 +577,7 @@ class PHPExcel_Worksheet_AutoFilter
); );
} }
private function _calculateTopTenValue($columnID,$startRow,$endRow,$ruleType,$ruleValue) { private function _calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue) {
$range = $columnID.$startRow.':'.$columnID.$endRow; $range = $columnID.$startRow.':'.$columnID.$endRow;
$dataValues = PHPExcel_Calculation_Functions::flattenArray( $dataValues = PHPExcel_Calculation_Functions::flattenArray(
$this->_workSheet->rangeToArray($range,NULL,TRUE,FALSE) $this->_workSheet->rangeToArray($range,NULL,TRUE,FALSE)
@ -590,7 +590,7 @@ class PHPExcel_Worksheet_AutoFilter
sort($dataValues); sort($dataValues);
} }
return array_pop(array_slice($dataValues,0,$ruleValue)); return array_pop(array_slice($dataValues,0, $ruleValue));
} }
/** /**
@ -601,20 +601,20 @@ class PHPExcel_Worksheet_AutoFilter
*/ */
public function showHideRows() public function showHideRows()
{ {
list($rangeStart,$rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range); list($rangeStart, $rangeEnd) = PHPExcel_Cell::rangeBoundaries($this->_range);
// The heading row should always be visible // The heading row should always be visible
// echo 'AutoFilter Heading Row ',$rangeStart[1],' is always SHOWN',PHP_EOL; // echo 'AutoFilter Heading Row ', $rangeStart[1],' is always SHOWN',PHP_EOL;
$this->_workSheet->getRowDimension($rangeStart[1])->setVisible(TRUE); $this->_workSheet->getRowDimension($rangeStart[1])->setVisible(TRUE);
$columnFilterTests = array(); $columnFilterTests = array();
foreach($this->_columns as $columnID => $filterColumn) { foreach ($this->_columns as $columnID => $filterColumn) {
$rules = $filterColumn->getRules(); $rules = $filterColumn->getRules();
switch ($filterColumn->getFilterType()) { switch ($filterColumn->getFilterType()) {
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER : case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_FILTER :
$ruleValues = array(); $ruleValues = array();
// Build a list of the filter value selections // Build a list of the filter value selections
foreach($rules as $rule) { foreach ($rules as $rule) {
$ruleType = $rule->getRuleType(); $ruleType = $rule->getRuleType();
$ruleValues[] = $rule->getValue(); $ruleValues[] = $rule->getValue();
} }
@ -638,26 +638,26 @@ class PHPExcel_Worksheet_AutoFilter
'time' => array(), 'time' => array(),
'dateTime' => array(), 'dateTime' => array(),
); );
foreach($ruleDataSet as $ruleValue) { foreach ($ruleDataSet as $ruleValue) {
$date = $time = ''; $date = $time = '';
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== ''))
$date .= sprintf('%04d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]); $date .= sprintf('%04d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != ''))
$date .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]); $date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== ''))
$date .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]); $date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== ''))
$time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== ''))
$time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]);
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== ''))
$time .= sprintf('%02d',$ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]);
$dateTime = $date . $time; $dateTime = $date . $time;
$arguments['date'][] = $date; $arguments['date'][] = $date;
$arguments['time'][] = $time; $arguments['time'][] = $time;
@ -679,13 +679,13 @@ class PHPExcel_Worksheet_AutoFilter
$customRuleForBlanks = FALSE; $customRuleForBlanks = FALSE;
$ruleValues = array(); $ruleValues = array();
// Build a list of the filter value selections // Build a list of the filter value selections
foreach($rules as $rule) { foreach ($rules as $rule) {
$ruleType = $rule->getRuleType(); $ruleType = $rule->getRuleType();
$ruleValue = $rule->getValue(); $ruleValue = $rule->getValue();
if (!is_numeric($ruleValue)) { if (!is_numeric($ruleValue)) {
// Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards // Convert to a regexp allowing for regexp reserved characters, wildcards and escaped wildcards
$ruleValue = preg_quote($ruleValue); $ruleValue = preg_quote($ruleValue);
$ruleValue = str_replace(self::$_fromReplace,self::$_toReplace,$ruleValue); $ruleValue = str_replace(self::$_fromReplace,self::$_toReplace, $ruleValue);
if (trim($ruleValue) == '') { if (trim($ruleValue) == '') {
$customRuleForBlanks = TRUE; $customRuleForBlanks = TRUE;
$ruleValue = trim($ruleValue); $ruleValue = trim($ruleValue);
@ -706,7 +706,7 @@ class PHPExcel_Worksheet_AutoFilter
break; break;
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER : case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER :
$ruleValues = array(); $ruleValues = array();
foreach($rules as $rule) { foreach ($rules as $rule) {
// We should only ever have one Dynamic Filter Rule anyway // We should only ever have one Dynamic Filter Rule anyway
$dynamicRuleType = $rule->getGrouping(); $dynamicRuleType = $rule->getGrouping();
if (($dynamicRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) || if (($dynamicRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) ||
@ -714,7 +714,7 @@ class PHPExcel_Worksheet_AutoFilter
// Number (Average) based // Number (Average) based
// Calculate the average // Calculate the average
$averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')'; $averageFormula = '=AVERAGE('.$columnID.($rangeStart[1]+1).':'.$columnID.$rangeEnd[1].')';
$average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula,NULL,$this->_workSheet->getCell('A1')); $average = PHPExcel_Calculation::getInstance()->calculateFormula($averageFormula,NULL, $this->_workSheet->getCell('A1'));
// Set above/below rule based on greaterThan or LessTan // Set above/below rule based on greaterThan or LessTan
$operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) $operator = ($dynamicRuleType === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE)
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHAN
@ -757,7 +757,7 @@ class PHPExcel_Worksheet_AutoFilter
case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER : case PHPExcel_Worksheet_AutoFilter_Column::AUTOFILTER_FILTERTYPE_TOPTENFILTER :
$ruleValues = array(); $ruleValues = array();
$dataRowCount = $rangeEnd[1] - $rangeStart[1]; $dataRowCount = $rangeEnd[1] - $rangeStart[1];
foreach($rules as $rule) { foreach ($rules as $rule) {
// We should only ever have one Dynamic Filter Rule anyway // We should only ever have one Dynamic Filter Rule anyway
$toptenRuleType = $rule->getGrouping(); $toptenRuleType = $rule->getGrouping();
$ruleValue = $rule->getValue(); $ruleValue = $rule->getValue();
@ -769,7 +769,7 @@ class PHPExcel_Worksheet_AutoFilter
if ($ruleValue < 1) $ruleValue = 1; if ($ruleValue < 1) $ruleValue = 1;
if ($ruleValue > 500) $ruleValue = 500; if ($ruleValue > 500) $ruleValue = 500;
$maxVal = $this->_calculateTopTenValue($columnID,$rangeStart[1]+1,$rangeEnd[1],$toptenRuleType,$ruleValue); $maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue);
$operator = ($toptenRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) $operator = ($toptenRuleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP)
? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL ? PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_GREATERTHANOREQUAL
@ -795,16 +795,16 @@ class PHPExcel_Worksheet_AutoFilter
// //
// Execute the column tests for each row in the autoFilter range to determine show/hide, // Execute the column tests for each row in the autoFilter range to determine show/hide,
for ($row = $rangeStart[1]+1; $row <= $rangeEnd[1]; ++$row) { for ($row = $rangeStart[1]+1; $row <= $rangeEnd[1]; ++$row) {
// echo 'Testing Row = ',$row,PHP_EOL; // echo 'Testing Row = ', $row,PHP_EOL;
$result = TRUE; $result = TRUE;
foreach($columnFilterTests as $columnID => $columnFilterTest) { foreach ($columnFilterTests as $columnID => $columnFilterTest) {
// echo 'Testing cell ',$columnID.$row,PHP_EOL; // echo 'Testing cell ', $columnID.$row,PHP_EOL;
$cellValue = $this->_workSheet->getCell($columnID.$row)->getCalculatedValue(); $cellValue = $this->_workSheet->getCell($columnID.$row)->getCalculatedValue();
// echo 'Value is ',$cellValue,PHP_EOL; // echo 'Value is ', $cellValue,PHP_EOL;
// Execute the filter test // Execute the filter test
$result = $result && $result = $result &&
call_user_func_array( call_user_func_array(
array('PHPExcel_Worksheet_AutoFilter',$columnFilterTest['method']), array('PHPExcel_Worksheet_AutoFilter', $columnFilterTest['method']),
array( array(
$cellValue, $cellValue,
$columnFilterTest['arguments'] $columnFilterTest['arguments']

View File

@ -322,7 +322,7 @@ class PHPExcel_Worksheet_AutoFilter_Column_Rule
public function setValue($pValue = '') { public function setValue($pValue = '') {
if (is_array($pValue)) { if (is_array($pValue)) {
$grouping = -1; $grouping = -1;
foreach($pValue as $key => $value) { foreach ($pValue as $key => $value) {
// Validate array entries // Validate array entries
if (!in_array($key,self::$_dateTimeGroups)) { if (!in_array($key,self::$_dateTimeGroups)) {
// Remove any invalid entries from the value array // Remove any invalid entries from the value array

View File

@ -575,7 +575,7 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
return $this->_printArea; return $this->_printArea;
} }
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if (isset($printAreas[$index-1])) { if (isset($printAreas[$index-1])) {
return $printAreas[$index-1]; return $printAreas[$index-1];
} }
@ -595,7 +595,7 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
return !is_null($this->_printArea); return !is_null($this->_printArea);
} }
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
return isset($printAreas[$index-1]); return isset($printAreas[$index-1]);
} }
@ -612,10 +612,10 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
$this->_printArea = NULL; $this->_printArea = NULL;
} else { } else {
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if (isset($printAreas[$index-1])) { if (isset($printAreas[$index-1])) {
unset($printAreas[$index-1]); unset($printAreas[$index-1]);
$this->_printArea = implode(',',$printAreas); $this->_printArea = implode(',', $printAreas);
} }
} }
@ -656,29 +656,29 @@ class PHPExcel_Worksheet_PageSetup
if ($index == 0) { if ($index == 0) {
$this->_printArea = $value; $this->_printArea = $value;
} else { } else {
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if($index < 0) { if ($index < 0) {
$index = count($printAreas) - abs($index) + 1; $index = count($printAreas) - abs($index) + 1;
} }
if (($index <= 0) || ($index > count($printAreas))) { if (($index <= 0) || ($index > count($printAreas))) {
throw new PHPExcel_Exception('Invalid index for setting print range.'); throw new PHPExcel_Exception('Invalid index for setting print range.');
} }
$printAreas[$index-1] = $value; $printAreas[$index-1] = $value;
$this->_printArea = implode(',',$printAreas); $this->_printArea = implode(',', $printAreas);
} }
} elseif($method == self::SETPRINTRANGE_INSERT) { } elseif ($method == self::SETPRINTRANGE_INSERT) {
if ($index == 0) { if ($index == 0) {
$this->_printArea .= ($this->_printArea == '') ? $value : ','.$value; $this->_printArea .= ($this->_printArea == '') ? $value : ','.$value;
} else { } else {
$printAreas = explode(',',$this->_printArea); $printAreas = explode(',', $this->_printArea);
if($index < 0) { if ($index < 0) {
$index = abs($index) - 1; $index = abs($index) - 1;
} }
if ($index > count($printAreas)) { if ($index > count($printAreas)) {
throw new PHPExcel_Exception('Invalid index for setting print range.'); throw new PHPExcel_Exception('Invalid index for setting print range.');
} }
$printAreas = array_merge(array_slice($printAreas,0,$index),array($value),array_slice($printAreas,$index)); $printAreas = array_merge(array_slice($printAreas,0, $index),array($value),array_slice($printAreas, $index));
$this->_printArea = implode(',',$printAreas); $this->_printArea = implode(',', $printAreas);
} }
} else { } else {
throw new PHPExcel_Exception('Invalid method for setting print range.'); throw new PHPExcel_Exception('Invalid method for setting print range.');

View File

@ -98,7 +98,7 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
$sheet = $this->_phpExcel->getSheet($this->_sheetIndex); $sheet = $this->_phpExcel->getSheet($this->_sheetIndex);
$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);
@ -124,9 +124,9 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
$maxRow = $sheet->getHighestDataRow(); $maxRow = $sheet->getHighestDataRow();
// Write rows to file // Write rows to file
for($row = 1; $row <= $maxRow; ++$row) { for ($row = 1; $row <= $maxRow; ++$row) {
// Convert the row to an array... // Convert the row to an array...
$cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row,'', $this->_preCalculateFormulas); $cellsArray = $sheet->rangeToArray('A'.$row.':'.$maxCol.$row, '', $this->_preCalculateFormulas);
// ... and write to the file // ... and write to the file
$this->_writeLine($fileHandle, $cellsArray[0]); $this->_writeLine($fileHandle, $cellsArray[0]);
} }
@ -143,7 +143,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return string * @return string
*/ */
public function getDelimiter() { public function getDelimiter()
{
return $this->_delimiter; return $this->_delimiter;
} }
@ -153,7 +154,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param string $pValue Delimiter, defaults to , * @param string $pValue Delimiter, defaults to ,
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setDelimiter($pValue = ',') { public function setDelimiter($pValue = ',')
{
$this->_delimiter = $pValue; $this->_delimiter = $pValue;
return $this; return $this;
} }
@ -163,7 +165,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return string * @return string
*/ */
public function getEnclosure() { public function getEnclosure()
{
return $this->_enclosure; return $this->_enclosure;
} }
@ -173,7 +176,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param string $pValue Enclosure, defaults to " * @param string $pValue Enclosure, defaults to "
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setEnclosure($pValue = '"') { public function setEnclosure($pValue = '"')
{
if ($pValue == '') { if ($pValue == '') {
$pValue = null; $pValue = null;
} }
@ -186,7 +190,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return string * @return string
*/ */
public function getLineEnding() { public function getLineEnding()
{
return $this->_lineEnding; return $this->_lineEnding;
} }
@ -196,7 +201,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param string $pValue Line ending, defaults to OS line ending (PHP_EOL) * @param string $pValue Line ending, defaults to OS line ending (PHP_EOL)
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setLineEnding($pValue = PHP_EOL) { public function setLineEnding($pValue = PHP_EOL)
{
$this->_lineEnding = $pValue; $this->_lineEnding = $pValue;
return $this; return $this;
} }
@ -206,7 +212,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return boolean * @return boolean
*/ */
public function getUseBOM() { public function getUseBOM()
{
return $this->_useBOM; return $this->_useBOM;
} }
@ -216,7 +223,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false * @param boolean $pValue Use UTF-8 byte-order mark? Defaults to false
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setUseBOM($pValue = false) { public function setUseBOM($pValue = false)
{
$this->_useBOM = $pValue; $this->_useBOM = $pValue;
return $this; return $this;
} }
@ -226,7 +234,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return boolean * @return boolean
*/ */
public function getExcelCompatibility() { public function getExcelCompatibility()
{
return $this->_excelCompatibility; return $this->_excelCompatibility;
} }
@ -237,7 +246,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* Note that this overrides other settings such as useBOM, enclosure and delimiter * Note that this overrides other settings such as useBOM, enclosure and delimiter
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setExcelCompatibility($pValue = false) { public function setExcelCompatibility($pValue = false)
{
$this->_excelCompatibility = $pValue; $this->_excelCompatibility = $pValue;
return $this; return $this;
} }
@ -247,7 +257,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* *
* @return int * @return int
*/ */
public function getSheetIndex() { public function getSheetIndex()
{
return $this->_sheetIndex; return $this->_sheetIndex;
} }
@ -257,7 +268,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param int $pValue Sheet index * @param int $pValue Sheet index
* @return PHPExcel_Writer_CSV * @return PHPExcel_Writer_CSV
*/ */
public function setSheetIndex($pValue = 0) { public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue; $this->_sheetIndex = $pValue;
return $this; return $this;
} }
@ -269,7 +281,8 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
* @param array $pValues Array containing values in a row * @param array $pValues Array containing values in a row
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeLine($pFileHandle = null, $pValues = null) { private function _writeLine($pFileHandle = null, $pValues = null)
{
if (is_array($pValues)) { if (is_array($pValues)) {
// No leading delimiter // No leading delimiter
$writeDelimiter = false; $writeDelimiter = false;
@ -301,5 +314,4 @@ class PHPExcel_Writer_CSV extends PHPExcel_Writer_Abstract implements PHPExcel_W
throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer."); throw new PHPExcel_Writer_Exception("Invalid data row passed to CSV writer.");
} }
} }
} }

View File

@ -125,18 +125,18 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
// Assign PHPExcel // Assign PHPExcel
$this->setPHPExcel($pPHPExcel); $this->setPHPExcel($pPHPExcel);
$writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable', $writerPartsArray = array( 'stringtable' => 'PHPExcel_Writer_Excel2007_StringTable',
'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes', 'contenttypes' => 'PHPExcel_Writer_Excel2007_ContentTypes',
'docprops' => 'PHPExcel_Writer_Excel2007_DocProps', 'docprops' => 'PHPExcel_Writer_Excel2007_DocProps',
'rels' => 'PHPExcel_Writer_Excel2007_Rels', 'rels' => 'PHPExcel_Writer_Excel2007_Rels',
'theme' => 'PHPExcel_Writer_Excel2007_Theme', 'theme' => 'PHPExcel_Writer_Excel2007_Theme',
'style' => 'PHPExcel_Writer_Excel2007_Style', 'style' => 'PHPExcel_Writer_Excel2007_Style',
'workbook' => 'PHPExcel_Writer_Excel2007_Workbook', 'workbook' => 'PHPExcel_Writer_Excel2007_Workbook',
'worksheet' => 'PHPExcel_Writer_Excel2007_Worksheet', 'worksheet' => 'PHPExcel_Writer_Excel2007_Worksheet',
'drawing' => 'PHPExcel_Writer_Excel2007_Drawing', 'drawing' => 'PHPExcel_Writer_Excel2007_Drawing',
'comments' => 'PHPExcel_Writer_Excel2007_Comments', 'comments' => 'PHPExcel_Writer_Excel2007_Comments',
'chart' => 'PHPExcel_Writer_Excel2007_Chart', 'chart' => 'PHPExcel_Writer_Excel2007_Chart',
'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA', 'relsvba' => 'PHPExcel_Writer_Excel2007_RelsVBA',
'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon' 'relsribbonobjects' => 'PHPExcel_Writer_Excel2007_RelsRibbon'
); );
@ -163,7 +163,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @param string $pPartName Writer part name * @param string $pPartName Writer part name
* @return PHPExcel_Writer_Excel2007_WriterPart * @return PHPExcel_Writer_Excel2007_WriterPart
*/ */
public function getWriterPart($pPartName = '') { public function getWriterPart($pPartName = '')
{
if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) {
return $this->_writerParts[strtolower($pPartName)]; return $this->_writerParts[strtolower($pPartName)];
} else { } else {
@ -179,7 +180,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
*/ */
public function save($pFilename = null) public function save($pFilename = null)
{ {
if ($this->_spreadSheet !== NULL) { if ($this->_spreadSheet !== null) {
// garbage collect // garbage collect
$this->_spreadSheet->garbageCollect(); $this->_spreadSheet->garbageCollect();
@ -193,7 +194,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
} }
$saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog(); $saveDebugLog = PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->getWriteDebugLog();
PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(FALSE); PHPExcel_Calculation::getInstance($this->_spreadSheet)->getDebugLog()->setWriteDebugLog(false);
$saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType(); $saveDateReturnType = PHPExcel_Calculation_Functions::getReturnDateType();
PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL); PHPExcel_Calculation_Functions::setReturnDateType(PHPExcel_Calculation_Functions::RETURNDATE_EXCEL);
@ -204,15 +205,15 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
} }
// Create styles dictionaries // Create styles dictionaries
$this->_styleHashTable->addFromSource( $this->getWriterPart('Style')->allStyles($this->_spreadSheet) ); $this->_styleHashTable->addFromSource($this->getWriterPart('Style')->allStyles($this->_spreadSheet));
$this->_stylesConditionalHashTable->addFromSource( $this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet) ); $this->_stylesConditionalHashTable->addFromSource($this->getWriterPart('Style')->allConditionalStyles($this->_spreadSheet));
$this->_fillHashTable->addFromSource( $this->getWriterPart('Style')->allFills($this->_spreadSheet) ); $this->_fillHashTable->addFromSource($this->getWriterPart('Style')->allFills($this->_spreadSheet));
$this->_fontHashTable->addFromSource( $this->getWriterPart('Style')->allFonts($this->_spreadSheet) ); $this->_fontHashTable->addFromSource($this->getWriterPart('Style')->allFonts($this->_spreadSheet));
$this->_bordersHashTable->addFromSource( $this->getWriterPart('Style')->allBorders($this->_spreadSheet) ); $this->_bordersHashTable->addFromSource($this->getWriterPart('Style')->allBorders($this->_spreadSheet));
$this->_numFmtHashTable->addFromSource( $this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet) ); $this->_numFmtHashTable->addFromSource($this->getWriterPart('Style')->allNumberFormats($this->_spreadSheet));
// Create drawing dictionary // Create drawing dictionary
$this->_drawingHashTable->addFromSource( $this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet) ); $this->_drawingHashTable->addFromSource($this->getWriterPart('Drawing')->allDrawings($this->_spreadSheet));
// Create new ZIP file and open it for writing // Create new ZIP file and open it for writing
$zipClass = PHPExcel_Settings::getZipClass(); $zipClass = PHPExcel_Settings::getZipClass();
@ -235,60 +236,58 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
} }
// Add [Content_Types].xml to ZIP file // Add [Content_Types].xml to ZIP file
$objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->_includeCharts)); $objZip->addFromString('[Content_Types].xml', $this->getWriterPart('ContentTypes')->writeContentTypes($this->_spreadSheet, $this->_includeCharts));
//if hasMacros, add the vbaProject.bin file, Certificate file(if exists) //if hasMacros, add the vbaProject.bin file, Certificate file(if exists)
if($this->_spreadSheet->hasMacros()){ if ($this->_spreadSheet->hasMacros()) {
$macrosCode=$this->_spreadSheet->getMacrosCode(); $macrosCode=$this->_spreadSheet->getMacrosCode();
if(!is_null($macrosCode)){// we have the code ? if (!is_null($macrosCode)) {// we have the code ?
$objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin $objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin
if($this->_spreadSheet->hasMacrosCertificate()){//signed macros ? if ($this->_spreadSheet->hasMacrosCertificate()) {//signed macros ?
// Yes : add the certificate file and the related rels file // Yes : add the certificate file and the related rels file
$objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate()); $objZip->addFromString('xl/vbaProjectSignature.bin', $this->_spreadSheet->getMacrosCertificate());
$objZip->addFromString('xl/_rels/vbaProject.bin.rels', $objZip->addFromString('xl/_rels/vbaProject.bin.rels', $this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet));
$this->getWriterPart('RelsVBA')->writeVBARelationships($this->_spreadSheet));
} }
} }
} }
//a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels) //a custom UI in this workbook ? add it ("base" xml and additional objects (pictures) and rels)
if($this->_spreadSheet->hasRibbon()){ if ($this->_spreadSheet->hasRibbon()) {
$tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target'); $tmpRibbonTarget=$this->_spreadSheet->getRibbonXMLData('target');
$objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data')); $objZip->addFromString($tmpRibbonTarget, $this->_spreadSheet->getRibbonXMLData('data'));
if($this->_spreadSheet->hasRibbonBinObjects()){ if ($this->_spreadSheet->hasRibbonBinObjects()) {
$tmpRootPath=dirname($tmpRibbonTarget).'/'; $tmpRootPath=dirname($tmpRibbonTarget).'/';
$ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write $ribbonBinObjects=$this->_spreadSheet->getRibbonBinObjects('data');//the files to write
foreach($ribbonBinObjects as $aPath=>$aContent){ foreach ($ribbonBinObjects as $aPath=>$aContent) {
$objZip->addFromString($tmpRootPath.$aPath, $aContent); $objZip->addFromString($tmpRootPath.$aPath, $aContent);
} }
//the rels for files //the rels for files
$objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels', $objZip->addFromString($tmpRootPath.'_rels/'.basename($tmpRibbonTarget).'.rels', $this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->_spreadSheet));
$this->getWriterPart('RelsRibbonObjects')->writeRibbonRelationships($this->_spreadSheet));
} }
} }
// Add relationships to ZIP file // Add relationships to ZIP file
$objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet)); $objZip->addFromString('_rels/.rels', $this->getWriterPart('Rels')->writeRelationships($this->_spreadSheet));
$objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet)); $objZip->addFromString('xl/_rels/workbook.xml.rels', $this->getWriterPart('Rels')->writeWorkbookRelationships($this->_spreadSheet));
// Add document properties to ZIP file // Add document properties to ZIP file
$objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet)); $objZip->addFromString('docProps/app.xml', $this->getWriterPart('DocProps')->writeDocPropsApp($this->_spreadSheet));
$objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet)); $objZip->addFromString('docProps/core.xml', $this->getWriterPart('DocProps')->writeDocPropsCore($this->_spreadSheet));
$customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet); $customPropertiesPart = $this->getWriterPart('DocProps')->writeDocPropsCustom($this->_spreadSheet);
if ($customPropertiesPart !== NULL) { if ($customPropertiesPart !== null) {
$objZip->addFromString('docProps/custom.xml', $customPropertiesPart); $objZip->addFromString('docProps/custom.xml', $customPropertiesPart);
} }
// Add theme to ZIP file // Add theme to ZIP file
$objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet)); $objZip->addFromString('xl/theme/theme1.xml', $this->getWriterPart('Theme')->writeTheme($this->_spreadSheet));
// Add string table to ZIP file // Add string table to ZIP file
$objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable)); $objZip->addFromString('xl/sharedStrings.xml', $this->getWriterPart('StringTable')->writeStringTable($this->_stringTable));
// Add styles to ZIP file // Add styles to ZIP file
$objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet)); $objZip->addFromString('xl/styles.xml', $this->getWriterPart('Style')->writeStyles($this->_spreadSheet));
// Add workbook to ZIP file // Add workbook to ZIP file
$objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet, $this->_preCalculateFormulas)); $objZip->addFromString('xl/workbook.xml', $this->getWriterPart('Workbook')->writeWorkbook($this->_spreadSheet, $this->_preCalculateFormulas));
$chartCount = 0; $chartCount = 0;
// Add worksheets // Add worksheets
@ -297,7 +296,7 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
if ($this->_includeCharts) { if ($this->_includeCharts) {
$charts = $this->_spreadSheet->getSheet($i)->getChartCollection(); $charts = $this->_spreadSheet->getSheet($i)->getChartCollection();
if (count($charts) > 0) { if (count($charts) > 0) {
foreach($charts as $chart) { foreach ($charts as $chart) {
$objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart)); $objZip->addFromString('xl/charts/chart' . ($chartCount + 1) . '.xml', $this->getWriterPart('Chart')->writeChart($chart));
$chartCount++; $chartCount++;
} }
@ -308,9 +307,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
$chartRef1 = $chartRef2 = 0; $chartRef1 = $chartRef2 = 0;
// Add worksheet relationships (drawings, ...) // Add worksheet relationships (drawings, ...)
for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) { for ($i = 0; $i < $this->_spreadSheet->getSheetCount(); ++$i) {
// Add relationships // Add relationships
$objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->_includeCharts)); $objZip->addFromString('xl/worksheets/_rels/sheet' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeWorksheetRelationships($this->_spreadSheet->getSheet($i), ($i + 1), $this->_includeCharts));
$drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection(); $drawings = $this->_spreadSheet->getSheet($i)->getDrawingCollection();
$drawingCount = count($drawings); $drawingCount = count($drawings);
@ -321,10 +319,10 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
// Add drawing and image relationship parts // Add drawing and image relationship parts
if (($drawingCount > 0) || ($chartCount > 0)) { if (($drawingCount > 0) || ($chartCount > 0)) {
// Drawing relationships // Drawing relationships
$objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i),$chartRef1, $this->_includeCharts)); $objZip->addFromString('xl/drawings/_rels/drawing' . ($i + 1) . '.xml.rels', $this->getWriterPart('Rels')->writeDrawingRelationships($this->_spreadSheet->getSheet($i), $chartRef1, $this->_includeCharts));
// Drawings // Drawings
$objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i),$chartRef2,$this->_includeCharts)); $objZip->addFromString('xl/drawings/drawing' . ($i + 1) . '.xml', $this->getWriterPart('Drawing')->writeDrawings($this->_spreadSheet->getSheet($i), $chartRef2, $this->_includeCharts));
} }
// Add comment relationship parts // Add comment relationship parts
@ -409,7 +407,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @return PHPExcel * @return PHPExcel
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function getPHPExcel() { public function getPHPExcel()
{
if ($this->_spreadSheet !== null) { if ($this->_spreadSheet !== null) {
return $this->_spreadSheet; return $this->_spreadSheet;
} else { } else {
@ -424,7 +423,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
* @return PHPExcel_Writer_Excel2007 * @return PHPExcel_Writer_Excel2007
*/ */
public function setPHPExcel(PHPExcel $pPHPExcel = null) { public function setPHPExcel(PHPExcel $pPHPExcel = null)
{
$this->_spreadSheet = $pPHPExcel; $this->_spreadSheet = $pPHPExcel;
return $this; return $this;
} }
@ -434,7 +434,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return string[] * @return string[]
*/ */
public function getStringTable() { public function getStringTable()
{
return $this->_stringTable; return $this->_stringTable;
} }
@ -443,7 +444,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getStyleHashTable() { public function getStyleHashTable()
{
return $this->_styleHashTable; return $this->_styleHashTable;
} }
@ -452,7 +454,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getStylesConditionalHashTable() { public function getStylesConditionalHashTable()
{
return $this->_stylesConditionalHashTable; return $this->_stylesConditionalHashTable;
} }
@ -461,7 +464,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getFillHashTable() { public function getFillHashTable()
{
return $this->_fillHashTable; return $this->_fillHashTable;
} }
@ -470,7 +474,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getFontHashTable() { public function getFontHashTable()
{
return $this->_fontHashTable; return $this->_fontHashTable;
} }
@ -479,7 +484,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getBordersHashTable() { public function getBordersHashTable()
{
return $this->_bordersHashTable; return $this->_bordersHashTable;
} }
@ -488,7 +494,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getNumFmtHashTable() { public function getNumFmtHashTable()
{
return $this->_numFmtHashTable; return $this->_numFmtHashTable;
} }
@ -497,7 +504,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return PHPExcel_HashTable * @return PHPExcel_HashTable
*/ */
public function getDrawingHashTable() { public function getDrawingHashTable()
{
return $this->_drawingHashTable; return $this->_drawingHashTable;
} }
@ -506,7 +514,8 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* *
* @return boolean * @return boolean
*/ */
public function getOffice2003Compatibility() { public function getOffice2003Compatibility()
{
return $this->_office2003compatibility; return $this->_office2003compatibility;
} }
@ -516,9 +525,9 @@ class PHPExcel_Writer_Excel2007 extends PHPExcel_Writer_Abstract implements PHPE
* @param boolean $pValue Office2003 compatibility? * @param boolean $pValue Office2003 compatibility?
* @return PHPExcel_Writer_Excel2007 * @return PHPExcel_Writer_Excel2007
*/ */
public function setOffice2003Compatibility($pValue = false) { public function setOffice2003Compatibility($pValue = false)
{
$this->_office2003compatibility = $pValue; $this->_office2003compatibility = $pValue;
return $this; return $this;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Comments cache // Comments cache
$comments = $pWorksheet->getComments(); $comments = $pWorksheet->getComments();
@ -133,7 +133,7 @@ class PHPExcel_Writer_Excel2007_Comments extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Comments cache // Comments cache
$comments = $pWorksheet->getComments(); $comments = $pWorksheet->getComments();

View File

@ -43,7 +43,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = FALSE) public function writeContentTypes(PHPExcel $pPHPExcel = null, $includeCharts = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -54,87 +54,59 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Types // Types
$objWriter->startElement('Types'); $objWriter->startElement('Types');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/content-types');
// Theme // Theme
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml');
$objWriter, '/xl/theme/theme1.xml', 'application/vnd.openxmlformats-officedocument.theme+xml'
);
// Styles // Styles
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml');
$objWriter, '/xl/styles.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml'
);
// Rels // Rels
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml');
$objWriter, 'rels', 'application/vnd.openxmlformats-package.relationships+xml'
);
// XML // XML
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'xml', 'application/xml');
$objWriter, 'xml', 'application/xml'
);
// VML // VML
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing');
$objWriter, 'vml', 'application/vnd.openxmlformats-officedocument.vmlDrawing'
);
// Workbook // Workbook
if($pPHPExcel->hasMacros()){ //Macros in workbook ? if ($pPHPExcel->hasMacros()) { //Macros in workbook ?
// Yes : not standard content but "macroEnabled" // Yes : not standard content but "macroEnabled"
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml');
$objWriter, '/xl/workbook.xml', 'application/vnd.ms-excel.sheet.macroEnabled.main+xml'
);
//... and define a new type for the VBA project //... and define a new type for the VBA project
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, 'bin', 'application/vnd.ms-office.vbaProject');
$objWriter, 'bin', 'application/vnd.ms-office.vbaProject' if ($pPHPExcel->hasMacrosCertificate()) {// signed macros ?
);
if($pPHPExcel->hasMacrosCertificate()){// signed macros ?
// Yes : add needed information // Yes : add needed information
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature');
$objWriter, '/xl/vbaProjectSignature.bin', 'application/vnd.ms-office.vbaProjectSignature'
);
} }
}else{// no macros in workbook, so standard type } else {// no macros in workbook, so standard type
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml');
$objWriter, '/xl/workbook.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
);
} }
// DocProps // DocProps
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml');
$objWriter, '/docProps/app.xml', 'application/vnd.openxmlformats-officedocument.extended-properties+xml'
);
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml');
$objWriter, '/docProps/core.xml', 'application/vnd.openxmlformats-package.core-properties+xml'
);
$customPropertyList = $pPHPExcel->getProperties()->getCustomProperties(); $customPropertyList = $pPHPExcel->getProperties()->getCustomProperties();
if (!empty($customPropertyList)) { if (!empty($customPropertyList)) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml');
$objWriter, '/docProps/custom.xml', 'application/vnd.openxmlformats-officedocument.custom-properties+xml'
);
} }
// Worksheets // Worksheets
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml');
$objWriter, '/xl/worksheets/sheet' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
);
} }
// Shared strings // Shared strings
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml');
$objWriter, '/xl/sharedStrings.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml'
);
// Add worksheet relationship content types // Add worksheet relationship content types
$chart = 1; $chart = 1;
@ -145,17 +117,13 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
// We need a drawing relationship for the worksheet if we have either drawings or charts // We need a drawing relationship for the worksheet if we have either drawings or charts
if (($drawingCount > 0) || ($chartCount > 0)) { if (($drawingCount > 0) || ($chartCount > 0)) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml');
$objWriter, '/xl/drawings/drawing' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.drawing+xml'
);
} }
// If we have charts, then we need a chart relationship for every individual chart // If we have charts, then we need a chart relationship for every individual chart
if ($chartCount > 0) { if ($chartCount > 0) {
for ($c = 0; $c < $chartCount; ++$c) { for ($c = 0; $c < $chartCount; ++$c) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml');
$objWriter, '/xl/charts/chart' . $chart++ . '.xml', 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml'
);
} }
} }
} }
@ -163,9 +131,7 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
// Comments // Comments
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
if (count($pPHPExcel->getSheet($i)->getComments()) > 0) { if (count($pPHPExcel->getSheet($i)->getComments()) > 0) {
$this->_writeOverrideContentType( $this->_writeOverrideContentType($objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml');
$objWriter, '/xl/comments' . ($i + 1) . '.xml', 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
);
} }
} }
@ -188,33 +154,27 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
} }
if (!isset( $aMediaContentTypes[$extension]) ) { if (!isset( $aMediaContentTypes[$extension]) ) {
$aMediaContentTypes[$extension] = $mimeType; $aMediaContentTypes[$extension] = $mimeType;
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, $extension, $mimeType);
$objWriter, $extension, $mimeType
);
} }
} }
if($pPHPExcel->hasRibbonBinObjects()){//Some additional objects in the ribbon ? if ($pPHPExcel->hasRibbonBinObjects()) {//Some additional objects in the ribbon ?
//we need to write "Extension" but not already write for media content //we need to write "Extension" but not already write for media content
$tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes)); $tabRibbonTypes=array_diff($pPHPExcel->getRibbonBinObjects('types'), array_keys($aMediaContentTypes));
foreach($tabRibbonTypes as $aRibbonType){ foreach ($tabRibbonTypes as $aRibbonType) {
$mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor $mimeType='image/.'.$aRibbonType;//we wrote $mimeType like customUI Editor
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, $aRibbonType, $mimeType);
$objWriter, $aRibbonType, $mimeType }
);
}
} }
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) { if (count($pPHPExcel->getSheet()->getHeaderFooter()->getImages()) > 0) {
foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) { foreach ($pPHPExcel->getSheet()->getHeaderFooter()->getImages() as $image) {
if (!isset( $aMediaContentTypes[strtolower($image->getExtension())]) ) { if (!isset( $aMediaContentTypes[strtolower($image->getExtension())])) {
$aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType( $image->getPath() ); $aMediaContentTypes[strtolower($image->getExtension())] = $this->_getImageMimeType($image->getPath());
$this->_writeDefaultContentType( $this->_writeDefaultContentType($objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]);
$objWriter, strtolower($image->getExtension()), $aMediaContentTypes[strtolower($image->getExtension())]
);
} }
} }
} }
@ -256,8 +216,8 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
if ($pPartname != '' && $pContentType != '') { if ($pPartname != '' && $pContentType != '') {
// Write content type // Write content type
$objWriter->startElement('Default'); $objWriter->startElement('Default');
$objWriter->writeAttribute('Extension', $pPartname); $objWriter->writeAttribute('Extension', $pPartname);
$objWriter->writeAttribute('ContentType', $pContentType); $objWriter->writeAttribute('ContentType', $pContentType);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
throw new PHPExcel_Writer_Exception("Invalid parameters passed."); throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
@ -277,8 +237,8 @@ class PHPExcel_Writer_Excel2007_ContentTypes extends PHPExcel_Writer_Excel2007_W
if ($pPartname != '' && $pContentType != '') { if ($pPartname != '' && $pContentType != '') {
// Write content type // Write content type
$objWriter->startElement('Override'); $objWriter->startElement('Override');
$objWriter->writeAttribute('PartName', $pPartname); $objWriter->writeAttribute('PartName', $pPartname);
$objWriter->writeAttribute('ContentType', $pContentType); $objWriter->writeAttribute('ContentType', $pContentType);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
throw new PHPExcel_Writer_Exception("Invalid parameters passed."); throw new PHPExcel_Writer_Exception("Invalid parameters passed.");

View File

@ -35,7 +35,7 @@
*/ */
class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_WriterPart
{ {
/** /**
* Write docProps/app.xml to XML format * Write docProps/app.xml to XML format
* *
* @param PHPExcel $pPHPExcel * @param PHPExcel $pPHPExcel
@ -53,78 +53,78 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Properties // Properties
$objWriter->startElement('Properties'); $objWriter->startElement('Properties');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/extended-properties');
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
// Application // Application
$objWriter->writeElement('Application', 'Microsoft Excel'); $objWriter->writeElement('Application', 'Microsoft Excel');
// DocSecurity // DocSecurity
$objWriter->writeElement('DocSecurity', '0'); $objWriter->writeElement('DocSecurity', '0');
// ScaleCrop // ScaleCrop
$objWriter->writeElement('ScaleCrop', 'false'); $objWriter->writeElement('ScaleCrop', 'false');
// HeadingPairs // HeadingPairs
$objWriter->startElement('HeadingPairs'); $objWriter->startElement('HeadingPairs');
// Vector // Vector
$objWriter->startElement('vt:vector'); $objWriter->startElement('vt:vector');
$objWriter->writeAttribute('size', '2'); $objWriter->writeAttribute('size', '2');
$objWriter->writeAttribute('baseType', 'variant'); $objWriter->writeAttribute('baseType', 'variant');
// Variant // Variant
$objWriter->startElement('vt:variant'); $objWriter->startElement('vt:variant');
$objWriter->writeElement('vt:lpstr', 'Worksheets'); $objWriter->writeElement('vt:lpstr', 'Worksheets');
$objWriter->endElement(); $objWriter->endElement();
// Variant // Variant
$objWriter->startElement('vt:variant'); $objWriter->startElement('vt:variant');
$objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount()); $objWriter->writeElement('vt:i4', $pPHPExcel->getSheetCount());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// TitlesOfParts // TitlesOfParts
$objWriter->startElement('TitlesOfParts'); $objWriter->startElement('TitlesOfParts');
// Vector // Vector
$objWriter->startElement('vt:vector'); $objWriter->startElement('vt:vector');
$objWriter->writeAttribute('size', $pPHPExcel->getSheetCount()); $objWriter->writeAttribute('size', $pPHPExcel->getSheetCount());
$objWriter->writeAttribute('baseType', 'lpstr'); $objWriter->writeAttribute('baseType', 'lpstr');
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
$objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle()); $objWriter->writeElement('vt:lpstr', $pPHPExcel->getSheet($i)->getTitle());
} }
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// Company // Company
$objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany()); $objWriter->writeElement('Company', $pPHPExcel->getProperties()->getCompany());
// Company // Company
$objWriter->writeElement('Manager', $pPHPExcel->getProperties()->getManager()); $objWriter->writeElement('Manager', $pPHPExcel->getProperties()->getManager());
// LinksUpToDate // LinksUpToDate
$objWriter->writeElement('LinksUpToDate', 'false'); $objWriter->writeElement('LinksUpToDate', 'false');
// SharedDoc // SharedDoc
$objWriter->writeElement('SharedDoc', 'false'); $objWriter->writeElement('SharedDoc', 'false');
// HyperlinksChanged // HyperlinksChanged
$objWriter->writeElement('HyperlinksChanged', 'false'); $objWriter->writeElement('HyperlinksChanged', 'false');
// AppVersion // AppVersion
$objWriter->writeElement('AppVersion', '12.0000'); $objWriter->writeElement('AppVersion', '12.0000');
$objWriter->endElement(); $objWriter->endElement();
@ -150,48 +150,48 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// cp:coreProperties // cp:coreProperties
$objWriter->startElement('cp:coreProperties'); $objWriter->startElement('cp:coreProperties');
$objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'); $objWriter->writeAttribute('xmlns:cp', 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/'); $objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/'); $objWriter->writeAttribute('xmlns:dcterms', 'http://purl.org/dc/terms/');
$objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/'); $objWriter->writeAttribute('xmlns:dcmitype', 'http://purl.org/dc/dcmitype/');
$objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $objWriter->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
// dc:creator // dc:creator
$objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator()); $objWriter->writeElement('dc:creator', $pPHPExcel->getProperties()->getCreator());
// cp:lastModifiedBy // cp:lastModifiedBy
$objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy()); $objWriter->writeElement('cp:lastModifiedBy', $pPHPExcel->getProperties()->getLastModifiedBy());
// dcterms:created // dcterms:created
$objWriter->startElement('dcterms:created'); $objWriter->startElement('dcterms:created');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated())); $objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getCreated()));
$objWriter->endElement(); $objWriter->endElement();
// dcterms:modified // dcterms:modified
$objWriter->startElement('dcterms:modified'); $objWriter->startElement('dcterms:modified');
$objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF'); $objWriter->writeAttribute('xsi:type', 'dcterms:W3CDTF');
$objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getModified())); $objWriter->writeRawData(date(DATE_W3C, $pPHPExcel->getProperties()->getModified()));
$objWriter->endElement(); $objWriter->endElement();
// dc:title // dc:title
$objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle()); $objWriter->writeElement('dc:title', $pPHPExcel->getProperties()->getTitle());
// dc:description // dc:description
$objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription()); $objWriter->writeElement('dc:description', $pPHPExcel->getProperties()->getDescription());
// dc:subject // dc:subject
$objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject()); $objWriter->writeElement('dc:subject', $pPHPExcel->getProperties()->getSubject());
// cp:keywords // cp:keywords
$objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords()); $objWriter->writeElement('cp:keywords', $pPHPExcel->getProperties()->getKeywords());
// cp:category // cp:category
$objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory()); $objWriter->writeElement('cp:category', $pPHPExcel->getProperties()->getCategory());
$objWriter->endElement(); $objWriter->endElement();
@ -222,51 +222,50 @@ class PHPExcel_Writer_Excel2007_DocProps extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// cp:coreProperties // cp:coreProperties
$objWriter->startElement('Properties'); $objWriter->startElement('Properties');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/officeDocument/2006/custom-properties');
$objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes'); $objWriter->writeAttribute('xmlns:vt', 'http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes');
foreach($customPropertyList as $key => $customProperty) { foreach ($customPropertyList as $key => $customProperty) {
$propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty); $propertyValue = $pPHPExcel->getProperties()->getCustomPropertyValue($customProperty);
$propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty); $propertyType = $pPHPExcel->getProperties()->getCustomPropertyType($customProperty);
$objWriter->startElement('property'); $objWriter->startElement('property');
$objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}'); $objWriter->writeAttribute('fmtid', '{D5CDD505-2E9C-101B-9397-08002B2CF9AE}');
$objWriter->writeAttribute('pid', $key+2); $objWriter->writeAttribute('pid', $key+2);
$objWriter->writeAttribute('name', $customProperty); $objWriter->writeAttribute('name', $customProperty);
switch($propertyType) { switch ($propertyType) {
case 'i' : case 'i' :
$objWriter->writeElement('vt:i4', $propertyValue); $objWriter->writeElement('vt:i4', $propertyValue);
break; break;
case 'f' : case 'f' :
$objWriter->writeElement('vt:r8', $propertyValue); $objWriter->writeElement('vt:r8', $propertyValue);
break; break;
case 'b' : case 'b' :
$objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false'); $objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false');
break; break;
case 'd' : case 'd' :
$objWriter->startElement('vt:filetime'); $objWriter->startElement('vt:filetime');
$objWriter->writeRawData(date(DATE_W3C, $propertyValue)); $objWriter->writeRawData(date(DATE_W3C, $propertyValue));
$objWriter->endElement(); $objWriter->endElement();
break; break;
default : default :
$objWriter->writeElement('vt:lpwstr', $propertyValue); $objWriter->writeElement('vt:lpwstr', $propertyValue);
break; break;
}
$objWriter->endElement();
} }
$objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();
// Return // Return
return $objWriter->getData(); return $objWriter->getData();
} }
} }

View File

@ -55,7 +55,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// xdr:wsDr // xdr:wsDr
$objWriter->startElement('xdr:wsDr'); $objWriter->startElement('xdr:wsDr');
@ -397,7 +397,7 @@ class PHPExcel_Writer_Excel2007_Drawing extends PHPExcel_Writer_Excel2007_Writer
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Header/footer images // Header/footer images
$images = $pWorksheet->getHeaderFooter()->getImages(); $images = $pWorksheet->getHeaderFooter()->getImages();

View File

@ -53,7 +53,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
@ -95,7 +95,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
'xl/workbook.xml' 'xl/workbook.xml'
); );
// a custom UI in workbook ? // a custom UI in workbook ?
if($pPHPExcel->hasRibbon()){ if ($pPHPExcel->hasRibbon()) {
$this->_writeRelationShip( $this->_writeRelationShip(
$objWriter, $objWriter,
5, 5,
@ -128,7 +128,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
@ -170,7 +170,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// Relationships for vbaProject if needed // Relationships for vbaProject if needed
// id : just after the last sheet // id : just after the last sheet
if($pPHPExcel->hasMacros()){ if ($pPHPExcel->hasMacros()) {
$this->_writeRelationShip( $this->_writeRelationShip(
$objWriter, $objWriter,
($i + 1 + 3), ($i + 1 + 3),
@ -210,7 +210,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
@ -238,7 +238,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
// $charts = $pWorksheet->getChartCollection(); // $charts = $pWorksheet->getChartCollection();
// echo 'Chart Rels: ' , count($charts) , '<br />'; // echo 'Chart Rels: ' , count($charts) , '<br />';
// if (count($charts) > 0) { // if (count($charts) > 0) {
// foreach($charts as $chart) { // foreach ($charts as $chart) {
// $this->_writeRelationship( // $this->_writeRelationship(
// $objWriter, // $objWriter,
// ++$d, // ++$d,
@ -319,7 +319,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
@ -383,7 +383,7 @@ class PHPExcel_Writer_Excel2007_Rels extends PHPExcel_Writer_Excel2007_WriterPar
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');

View File

@ -42,7 +42,7 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeRibbonRelationships(PHPExcel $pPHPExcel = null){ public function writeRibbonRelationships(PHPExcel $pPHPExcel = null) {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -52,14 +52,14 @@ class PHPExcel_Writer_Excel2007_RelsRibbon extends PHPExcel_Writer_Excel2007_Wri
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$localRels=$pPHPExcel->getRibbonBinObjects('names'); $localRels=$pPHPExcel->getRibbonBinObjects('names');
if(is_array($localRels)){ if (is_array($localRels)) {
foreach($localRels as $aId=>$aTarget){ foreach ($localRels as $aId=>$aTarget) {
$objWriter->startElement('Relationship'); $objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', $aId); $objWriter->writeAttribute('Id', $aId);
$objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'); $objWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image');

View File

@ -42,7 +42,7 @@ class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_Writer
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeVBARelationships(PHPExcel $pPHPExcel = null){ public function writeVBARelationships(PHPExcel $pPHPExcel = null) {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) { if ($this->getParentWriter()->getUseDiskCaching()) {
@ -52,7 +52,7 @@ class PHPExcel_Writer_Excel2007_RelsVBA extends PHPExcel_Writer_Excel2007_Writer
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Relationships // Relationships
$objWriter->startElement('Relationships'); $objWriter->startElement('Relationships');

View File

@ -104,7 +104,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// String table // String table
$objWriter->startElement('sst'); $objWriter->startElement('sst');
@ -254,7 +254,7 @@ class PHPExcel_Writer_Excel2007_StringTable extends PHPExcel_Writer_Excel2007_Wr
$objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0)); $objWriter->writeAttribute('i', ($element->getFont()->getItalic() ? 1 : 0));
// Underline // Underline
$underlineType = $element->getFont()->getUnderline(); $underlineType = $element->getFont()->getUnderline();
switch($underlineType) { switch ($underlineType) {
case 'single' : case 'single' :
$underlineType = 'sng'; $underlineType = 'sng';
break; break;

View File

@ -53,111 +53,111 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// styleSheet // styleSheet
$objWriter->startElement('styleSheet'); $objWriter->startElement('styleSheet');
$objWriter->writeAttribute('xml:space', 'preserve'); $objWriter->writeAttribute('xml:space', 'preserve');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
// numFmts // numFmts
$objWriter->startElement('numFmts'); $objWriter->startElement('numFmts');
$objWriter->writeAttribute('count', $this->getParentWriter()->getNumFmtHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getNumFmtHashTable()->count());
// numFmt // numFmt
for ($i = 0; $i < $this->getParentWriter()->getNumFmtHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getNumFmtHashTable()->count(); ++$i) {
$this->_writeNumFmt($objWriter, $this->getParentWriter()->getNumFmtHashTable()->getByIndex($i), $i); $this->_writeNumFmt($objWriter, $this->getParentWriter()->getNumFmtHashTable()->getByIndex($i), $i);
} }
$objWriter->endElement(); $objWriter->endElement();
// fonts // fonts
$objWriter->startElement('fonts'); $objWriter->startElement('fonts');
$objWriter->writeAttribute('count', $this->getParentWriter()->getFontHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getFontHashTable()->count());
// font // font
for ($i = 0; $i < $this->getParentWriter()->getFontHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getFontHashTable()->count(); ++$i) {
$this->_writeFont($objWriter, $this->getParentWriter()->getFontHashTable()->getByIndex($i)); $this->_writeFont($objWriter, $this->getParentWriter()->getFontHashTable()->getByIndex($i));
} }
$objWriter->endElement(); $objWriter->endElement();
// fills // fills
$objWriter->startElement('fills'); $objWriter->startElement('fills');
$objWriter->writeAttribute('count', $this->getParentWriter()->getFillHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getFillHashTable()->count());
// fill // fill
for ($i = 0; $i < $this->getParentWriter()->getFillHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getFillHashTable()->count(); ++$i) {
$this->_writeFill($objWriter, $this->getParentWriter()->getFillHashTable()->getByIndex($i)); $this->_writeFill($objWriter, $this->getParentWriter()->getFillHashTable()->getByIndex($i));
} }
$objWriter->endElement(); $objWriter->endElement();
// borders // borders
$objWriter->startElement('borders'); $objWriter->startElement('borders');
$objWriter->writeAttribute('count', $this->getParentWriter()->getBordersHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getBordersHashTable()->count());
// border // border
for ($i = 0; $i < $this->getParentWriter()->getBordersHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getBordersHashTable()->count(); ++$i) {
$this->_writeBorder($objWriter, $this->getParentWriter()->getBordersHashTable()->getByIndex($i)); $this->_writeBorder($objWriter, $this->getParentWriter()->getBordersHashTable()->getByIndex($i));
} }
$objWriter->endElement(); $objWriter->endElement();
// cellStyleXfs // cellStyleXfs
$objWriter->startElement('cellStyleXfs'); $objWriter->startElement('cellStyleXfs');
$objWriter->writeAttribute('count', 1); $objWriter->writeAttribute('count', 1);
// xf // xf
$objWriter->startElement('xf'); $objWriter->startElement('xf');
$objWriter->writeAttribute('numFmtId', 0); $objWriter->writeAttribute('numFmtId', 0);
$objWriter->writeAttribute('fontId', 0); $objWriter->writeAttribute('fontId', 0);
$objWriter->writeAttribute('fillId', 0); $objWriter->writeAttribute('fillId', 0);
$objWriter->writeAttribute('borderId', 0); $objWriter->writeAttribute('borderId', 0);
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// cellXfs // cellXfs
$objWriter->startElement('cellXfs'); $objWriter->startElement('cellXfs');
$objWriter->writeAttribute('count', count($pPHPExcel->getCellXfCollection())); $objWriter->writeAttribute('count', count($pPHPExcel->getCellXfCollection()));
// xf // xf
foreach ($pPHPExcel->getCellXfCollection() as $cellXf) { foreach ($pPHPExcel->getCellXfCollection() as $cellXf) {
$this->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel); $this->_writeCellStyleXf($objWriter, $cellXf, $pPHPExcel);
} }
$objWriter->endElement(); $objWriter->endElement();
// cellStyles // cellStyles
$objWriter->startElement('cellStyles'); $objWriter->startElement('cellStyles');
$objWriter->writeAttribute('count', 1); $objWriter->writeAttribute('count', 1);
// cellStyle // cellStyle
$objWriter->startElement('cellStyle'); $objWriter->startElement('cellStyle');
$objWriter->writeAttribute('name', 'Normal'); $objWriter->writeAttribute('name', 'Normal');
$objWriter->writeAttribute('xfId', 0); $objWriter->writeAttribute('xfId', 0);
$objWriter->writeAttribute('builtinId', 0); $objWriter->writeAttribute('builtinId', 0);
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// dxfs // dxfs
$objWriter->startElement('dxfs'); $objWriter->startElement('dxfs');
$objWriter->writeAttribute('count', $this->getParentWriter()->getStylesConditionalHashTable()->count()); $objWriter->writeAttribute('count', $this->getParentWriter()->getStylesConditionalHashTable()->count());
// dxf // dxf
for ($i = 0; $i < $this->getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) { for ($i = 0; $i < $this->getParentWriter()->getStylesConditionalHashTable()->count(); ++$i) {
$this->_writeCellStyleDxf($objWriter, $this->getParentWriter()->getStylesConditionalHashTable()->getByIndex($i)->getStyle()); $this->_writeCellStyleDxf($objWriter, $this->getParentWriter()->getStylesConditionalHashTable()->getByIndex($i)->getStyle());
} }
$objWriter->endElement(); $objWriter->endElement();
// tableStyles // tableStyles
$objWriter->startElement('tableStyles'); $objWriter->startElement('tableStyles');
$objWriter->writeAttribute('defaultTableStyle', 'TableStyleMedium9'); $objWriter->writeAttribute('defaultTableStyle', 'TableStyleMedium9');
$objWriter->writeAttribute('defaultPivotStyle', 'PivotTableStyle1'); $objWriter->writeAttribute('defaultPivotStyle', 'PivotTableStyle1');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
@ -179,7 +179,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$pFill->getFillType() === PHPExcel_Style_Fill::FILL_GRADIENT_PATH) { $pFill->getFillType() === PHPExcel_Style_Fill::FILL_GRADIENT_PATH) {
// Gradient fill // Gradient fill
$this->_writeGradientFill($objWriter, $pFill); $this->_writeGradientFill($objWriter, $pFill);
} elseif($pFill->getFillType() !== NULL) { } elseif ($pFill->getFillType() !== null) {
// Pattern fill // Pattern fill
$this->_writePatternFill($objWriter, $pFill); $this->_writePatternFill($objWriter, $pFill);
} }
@ -197,34 +197,34 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// fill // fill
$objWriter->startElement('fill'); $objWriter->startElement('fill');
// gradientFill // gradientFill
$objWriter->startElement('gradientFill'); $objWriter->startElement('gradientFill');
$objWriter->writeAttribute('type', $pFill->getFillType()); $objWriter->writeAttribute('type', $pFill->getFillType());
$objWriter->writeAttribute('degree', $pFill->getRotation()); $objWriter->writeAttribute('degree', $pFill->getRotation());
// stop // stop
$objWriter->startElement('stop'); $objWriter->startElement('stop');
$objWriter->writeAttribute('position', '0'); $objWriter->writeAttribute('position', '0');
// color // color
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
// stop // stop
$objWriter->startElement('stop'); $objWriter->startElement('stop');
$objWriter->writeAttribute('position', '1'); $objWriter->writeAttribute('position', '1');
// color // color
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -241,28 +241,28 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// fill // fill
$objWriter->startElement('fill'); $objWriter->startElement('fill');
// patternFill // patternFill
$objWriter->startElement('patternFill'); $objWriter->startElement('patternFill');
$objWriter->writeAttribute('patternType', $pFill->getFillType()); $objWriter->writeAttribute('patternType', $pFill->getFillType());
if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) { if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
// fgColor // fgColor
if ($pFill->getStartColor()->getARGB()) { if ($pFill->getStartColor()->getARGB()) {
$objWriter->startElement('fgColor'); $objWriter->startElement('fgColor');
$objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getStartColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
} }
} }
if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) { if ($pFill->getFillType() !== PHPExcel_Style_Fill::FILL_NONE) {
// bgColor // bgColor
if ($pFill->getEndColor()->getARGB()) { if ($pFill->getEndColor()->getARGB()) {
$objWriter->startElement('bgColor'); $objWriter->startElement('bgColor');
$objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFill->getEndColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
} }
} }
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -278,71 +278,71 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
{ {
// font // font
$objWriter->startElement('font'); $objWriter->startElement('font');
// Weird! The order of these elements actually makes a difference when opening Excel2007 // Weird! The order of these elements actually makes a difference when opening Excel2007
// files in Excel2003 with the compatibility pack. It's not documented behaviour, // files in Excel2003 with the compatibility pack. It's not documented behaviour,
// and makes for a real WTF! // and makes for a real WTF!
// Bold. We explicitly write this element also when false (like MS Office Excel 2007 does // Bold. We explicitly write this element also when false (like MS Office Excel 2007 does
// for conditional formatting). Otherwise it will apparently not be picked up in conditional // for conditional formatting). Otherwise it will apparently not be picked up in conditional
// formatting style dialog // formatting style dialog
if ($pFont->getBold() !== NULL) { if ($pFont->getBold() !== null) {
$objWriter->startElement('b'); $objWriter->startElement('b');
$objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0'); $objWriter->writeAttribute('val', $pFont->getBold() ? '1' : '0');
$objWriter->endElement(); $objWriter->endElement();
} }
// Italic // Italic
if ($pFont->getItalic() !== NULL) { if ($pFont->getItalic() !== null) {
$objWriter->startElement('i'); $objWriter->startElement('i');
$objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0'); $objWriter->writeAttribute('val', $pFont->getItalic() ? '1' : '0');
$objWriter->endElement(); $objWriter->endElement();
} }
// Strikethrough // Strikethrough
if ($pFont->getStrikethrough() !== NULL) { if ($pFont->getStrikethrough() !== null) {
$objWriter->startElement('strike'); $objWriter->startElement('strike');
$objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0'); $objWriter->writeAttribute('val', $pFont->getStrikethrough() ? '1' : '0');
$objWriter->endElement(); $objWriter->endElement();
} }
// Underline // Underline
if ($pFont->getUnderline() !== NULL) { if ($pFont->getUnderline() !== null) {
$objWriter->startElement('u'); $objWriter->startElement('u');
$objWriter->writeAttribute('val', $pFont->getUnderline()); $objWriter->writeAttribute('val', $pFont->getUnderline());
$objWriter->endElement(); $objWriter->endElement();
} }
// Superscript / subscript // Superscript / subscript
if ($pFont->getSuperScript() === TRUE || $pFont->getSubScript() === TRUE) { if ($pFont->getSuperScript() === true || $pFont->getSubScript() === true) {
$objWriter->startElement('vertAlign'); $objWriter->startElement('vertAlign');
if ($pFont->getSuperScript() === TRUE) { if ($pFont->getSuperScript() === true) {
$objWriter->writeAttribute('val', 'superscript'); $objWriter->writeAttribute('val', 'superscript');
} else if ($pFont->getSubScript() === TRUE) { } else if ($pFont->getSubScript() === true) {
$objWriter->writeAttribute('val', 'subscript'); $objWriter->writeAttribute('val', 'subscript');
}
$objWriter->endElement();
} }
$objWriter->endElement();
}
// Size // Size
if ($pFont->getSize() !== NULL) { if ($pFont->getSize() !== null) {
$objWriter->startElement('sz'); $objWriter->startElement('sz');
$objWriter->writeAttribute('val', $pFont->getSize()); $objWriter->writeAttribute('val', $pFont->getSize());
$objWriter->endElement(); $objWriter->endElement();
} }
// Foreground color // Foreground color
if ($pFont->getColor()->getARGB() !== NULL) { if ($pFont->getColor()->getARGB() !== null) {
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB()); $objWriter->writeAttribute('rgb', $pFont->getColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
} }
// Name // Name
if ($pFont->getName() !== NULL) { if ($pFont->getName() !== null) {
$objWriter->startElement('name'); $objWriter->startElement('name');
$objWriter->writeAttribute('val', $pFont->getName()); $objWriter->writeAttribute('val', $pFont->getName());
$objWriter->endElement(); $objWriter->endElement();
} }
$objWriter->endElement(); $objWriter->endElement();
} }
@ -358,28 +358,28 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
{ {
// Write border // Write border
$objWriter->startElement('border'); $objWriter->startElement('border');
// Diagonal? // Diagonal?
switch ($pBorders->getDiagonalDirection()) { switch ($pBorders->getDiagonalDirection()) {
case PHPExcel_Style_Borders::DIAGONAL_UP: case PHPExcel_Style_Borders::DIAGONAL_UP:
$objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'false'); $objWriter->writeAttribute('diagonalDown', 'false');
break; break;
case PHPExcel_Style_Borders::DIAGONAL_DOWN: case PHPExcel_Style_Borders::DIAGONAL_DOWN:
$objWriter->writeAttribute('diagonalUp', 'false'); $objWriter->writeAttribute('diagonalUp', 'false');
$objWriter->writeAttribute('diagonalDown', 'true'); $objWriter->writeAttribute('diagonalDown', 'true');
break; break;
case PHPExcel_Style_Borders::DIAGONAL_BOTH: case PHPExcel_Style_Borders::DIAGONAL_BOTH:
$objWriter->writeAttribute('diagonalUp', 'true'); $objWriter->writeAttribute('diagonalUp', 'true');
$objWriter->writeAttribute('diagonalDown', 'true'); $objWriter->writeAttribute('diagonalDown', 'true');
break; break;
} }
// BorderPr // BorderPr
$this->_writeBorderPr($objWriter, 'left', $pBorders->getLeft()); $this->_writeBorderPr($objWriter, 'left', $pBorders->getLeft());
$this->_writeBorderPr($objWriter, 'right', $pBorders->getRight()); $this->_writeBorderPr($objWriter, 'right', $pBorders->getRight());
$this->_writeBorderPr($objWriter, 'top', $pBorders->getTop()); $this->_writeBorderPr($objWriter, 'top', $pBorders->getTop());
$this->_writeBorderPr($objWriter, 'bottom', $pBorders->getBottom()); $this->_writeBorderPr($objWriter, 'bottom', $pBorders->getBottom());
$this->_writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal()); $this->_writeBorderPr($objWriter, 'diagonal', $pBorders->getDiagonal());
$objWriter->endElement(); $objWriter->endElement();
} }
@ -395,66 +395,66 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
{ {
// xf // xf
$objWriter->startElement('xf'); $objWriter->startElement('xf');
$objWriter->writeAttribute('xfId', 0); $objWriter->writeAttribute('xfId', 0);
$objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode())); $objWriter->writeAttribute('fontId', (int)$this->getParentWriter()->getFontHashTable()->getIndexForHashCode($pStyle->getFont()->getHashCode()));
if ($pStyle->getQuotePrefix()) { if ($pStyle->getQuotePrefix()) {
$objWriter->writeAttribute('quotePrefix', 1); $objWriter->writeAttribute('quotePrefix', 1);
}
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) {
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
} else {
$objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
}
$objWriter->writeAttribute('fillId', (int)$this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
$objWriter->writeAttribute('borderId', (int)$this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
// Apply styles?
$objWriter->writeAttribute('applyFont', ($pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyNumberFormat', ($pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyFill', ($pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyBorder', ($pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyAlignment', ($pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('applyProtection', 'true');
}
// alignment
$objWriter->startElement('alignment');
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} else if ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
$objWriter->writeAttribute('wrapText', ($pStyle->getAlignment()->getWrapText() ? 'true' : 'false'));
$objWriter->writeAttribute('shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
if ($pStyle->getAlignment()->getIndent() > 0) {
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
}
if ($pStyle->getAlignment()->getReadorder() > 0) {
$objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder());
}
$objWriter->endElement();
// protection
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
} }
if ($pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
if ($pStyle->getNumberFormat()->getBuiltInFormatCode() === false) { $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
$objWriter->writeAttribute('numFmtId', (int)($this->getParentWriter()->getNumFmtHashTable()->getIndexForHashCode($pStyle->getNumberFormat()->getHashCode()) + 164) );
} else {
$objWriter->writeAttribute('numFmtId', (int)$pStyle->getNumberFormat()->getBuiltInFormatCode());
} }
$objWriter->writeAttribute('fillId', (int)$this->getParentWriter()->getFillHashTable()->getIndexForHashCode($pStyle->getFill()->getHashCode()));
$objWriter->writeAttribute('borderId', (int)$this->getParentWriter()->getBordersHashTable()->getIndexForHashCode($pStyle->getBorders()->getHashCode()));
// Apply styles?
$objWriter->writeAttribute('applyFont', ($pPHPExcel->getDefaultStyle()->getFont()->getHashCode() != $pStyle->getFont()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyNumberFormat', ($pPHPExcel->getDefaultStyle()->getNumberFormat()->getHashCode() != $pStyle->getNumberFormat()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyFill', ($pPHPExcel->getDefaultStyle()->getFill()->getHashCode() != $pStyle->getFill()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyBorder', ($pPHPExcel->getDefaultStyle()->getBorders()->getHashCode() != $pStyle->getBorders()->getHashCode()) ? '1' : '0');
$objWriter->writeAttribute('applyAlignment', ($pPHPExcel->getDefaultStyle()->getAlignment()->getHashCode() != $pStyle->getAlignment()->getHashCode()) ? '1' : '0');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('applyProtection', 'true');
}
// alignment
$objWriter->startElement('alignment');
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
$textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation();
} else if ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
$objWriter->writeAttribute('wrapText', ($pStyle->getAlignment()->getWrapText() ? 'true' : 'false'));
$objWriter->writeAttribute('shrinkToFit', ($pStyle->getAlignment()->getShrinkToFit() ? 'true' : 'false'));
if ($pStyle->getAlignment()->getIndent() > 0) {
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
}
if ($pStyle->getAlignment()->getReadorder() > 0) {
$objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder());
}
$objWriter->endElement(); $objWriter->endElement();
}
// protection
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT || $pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if ($pStyle->getProtection()->getLocked() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if ($pStyle->getProtection()->getHidden() != PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
$objWriter->endElement(); $objWriter->endElement();
} }
@ -471,55 +471,54 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// dxf // dxf
$objWriter->startElement('dxf'); $objWriter->startElement('dxf');
// font // font
$this->_writeFont($objWriter, $pStyle->getFont()); $this->_writeFont($objWriter, $pStyle->getFont());
// numFmt // numFmt
$this->_writeNumFmt($objWriter, $pStyle->getNumberFormat()); $this->_writeNumFmt($objWriter, $pStyle->getNumberFormat());
// fill // fill
$this->_writeFill($objWriter, $pStyle->getFill()); $this->_writeFill($objWriter, $pStyle->getFill());
// alignment // alignment
$objWriter->startElement('alignment'); $objWriter->startElement('alignment');
if ($pStyle->getAlignment()->getHorizontal() !== NULL) { if ($pStyle->getAlignment()->getHorizontal() !== null) {
$objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal()); $objWriter->writeAttribute('horizontal', $pStyle->getAlignment()->getHorizontal());
} }
if ($pStyle->getAlignment()->getVertical() !== NULL) { if ($pStyle->getAlignment()->getVertical() !== null) {
$objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical()); $objWriter->writeAttribute('vertical', $pStyle->getAlignment()->getVertical());
} }
if ($pStyle->getAlignment()->getTextRotation() !== NULL) { if ($pStyle->getAlignment()->getTextRotation() !== null) {
$textRotation = 0; $textRotation = 0;
if ($pStyle->getAlignment()->getTextRotation() >= 0) { if ($pStyle->getAlignment()->getTextRotation() >= 0) {
$textRotation = $pStyle->getAlignment()->getTextRotation(); $textRotation = $pStyle->getAlignment()->getTextRotation();
} else if ($pStyle->getAlignment()->getTextRotation() < 0) { } else if ($pStyle->getAlignment()->getTextRotation() < 0) {
$textRotation = 90 - $pStyle->getAlignment()->getTextRotation(); $textRotation = 90 - $pStyle->getAlignment()->getTextRotation();
}
$objWriter->writeAttribute('textRotation', $textRotation);
}
$objWriter->endElement();
// border
$this->_writeBorder($objWriter, $pStyle->getBorders());
// protection
if (($pStyle->getProtection()->getLocked() !== NULL) ||
($pStyle->getProtection()->getHidden() !== NULL)) {
if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
$pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if (($pStyle->getProtection()->getLocked() !== NULL) &&
($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if (($pStyle->getProtection()->getHidden() !== NULL) &&
($pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
} }
$objWriter->writeAttribute('textRotation', $textRotation);
}
$objWriter->endElement();
// border
$this->_writeBorder($objWriter, $pStyle->getBorders());
// protection
if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) {
if ($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT ||
$pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT) {
$objWriter->startElement('protection');
if (($pStyle->getProtection()->getLocked() !== null) &&
($pStyle->getProtection()->getLocked() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
if (($pStyle->getProtection()->getHidden() !== null) &&
($pStyle->getProtection()->getHidden() !== PHPExcel_Style_Protection::PROTECTION_INHERIT)) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == PHPExcel_Style_Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
}
$objWriter->endElement();
}
}
$objWriter->endElement(); $objWriter->endElement();
} }
@ -537,12 +536,12 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
// Write BorderPr // Write BorderPr
if ($pBorder->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) { if ($pBorder->getBorderStyle() != PHPExcel_Style_Border::BORDER_NONE) {
$objWriter->startElement($pName); $objWriter->startElement($pName);
$objWriter->writeAttribute('style', $pBorder->getBorderStyle()); $objWriter->writeAttribute('style', $pBorder->getBorderStyle());
// color // color
$objWriter->startElement('color'); $objWriter->startElement('color');
$objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB()); $objWriter->writeAttribute('rgb', $pBorder->getColor()->getARGB());
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -562,10 +561,10 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$formatCode = $pNumberFormat->getFormatCode(); $formatCode = $pNumberFormat->getFormatCode();
// numFmt // numFmt
if ($formatCode !== NULL) { if ($formatCode !== null) {
$objWriter->startElement('numFmt'); $objWriter->startElement('numFmt');
$objWriter->writeAttribute('numFmtId', ($pId + 164)); $objWriter->writeAttribute('numFmtId', ($pId + 164));
$objWriter->writeAttribute('formatCode', $formatCode); $objWriter->writeAttribute('formatCode', $formatCode);
$objWriter->endElement(); $objWriter->endElement();
} }
} }
@ -579,9 +578,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
*/ */
public function allStyles(PHPExcel $pPHPExcel = null) public function allStyles(PHPExcel $pPHPExcel = null)
{ {
$aStyles = $pPHPExcel->getCellXfCollection(); return $pPHPExcel->getCellXfCollection();
return $aStyles;
} }
/** /**
@ -594,7 +591,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allConditionalStyles(PHPExcel $pPHPExcel = null) public function allConditionalStyles(PHPExcel $pPHPExcel = null)
{ {
// Get an array of all styles // Get an array of all styles
$aStyles = array(); $aStyles = array();
$sheetCount = $pPHPExcel->getSheetCount(); $sheetCount = $pPHPExcel->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) { for ($i = 0; $i < $sheetCount; ++$i) {
@ -618,7 +615,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allFills(PHPExcel $pPHPExcel = null) public function allFills(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique fills // Get an array of unique fills
$aFills = array(); $aFills = array();
// Two first fills are predefined // Two first fills are predefined
$fill0 = new PHPExcel_Style_Fill(); $fill0 = new PHPExcel_Style_Fill();
@ -629,7 +626,7 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
$fill1->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_GRAY125); $fill1->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_GRAY125);
$aFills[] = $fill1; $aFills[] = $fill1;
// The remaining fills // The remaining fills
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) { if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) {
$aFills[ $style->getFill()->getHashCode() ] = $style->getFill(); $aFills[ $style->getFill()->getHashCode() ] = $style->getFill();
@ -649,8 +646,8 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allFonts(PHPExcel $pPHPExcel = null) public function allFonts(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique fonts // Get an array of unique fonts
$aFonts = array(); $aFonts = array();
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) { if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) {
@ -671,8 +668,8 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allBorders(PHPExcel $pPHPExcel = null) public function allBorders(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique borders // Get an array of unique borders
$aBorders = array(); $aBorders = array();
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) { if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) {
@ -693,8 +690,8 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
public function allNumberFormats(PHPExcel $pPHPExcel = null) public function allNumberFormats(PHPExcel $pPHPExcel = null)
{ {
// Get an array of unique number formats // Get an array of unique number formats
$aNumFmts = array(); $aNumFmts = array();
$aStyles = $this->allStyles($pPHPExcel); $aStyles = $this->allStyles($pPHPExcel);
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) { if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) {

View File

@ -41,37 +41,37 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
* *
*/ */
private static $_majorFonts = array( private static $_majorFonts = array(
'Jpan' => ' Pゴシック', 'Jpan' => ' Pゴシック',
'Hang' => '맑은 고딕', 'Hang' => '맑은 고딕',
'Hans' => '宋体', 'Hans' => '宋体',
'Hant' => '新細明體', 'Hant' => '新細明體',
'Arab' => 'Times New Roman', 'Arab' => 'Times New Roman',
'Hebr' => 'Times New Roman', 'Hebr' => 'Times New Roman',
'Thai' => 'Tahoma', 'Thai' => 'Tahoma',
'Ethi' => 'Nyala', 'Ethi' => 'Nyala',
'Beng' => 'Vrinda', 'Beng' => 'Vrinda',
'Gujr' => 'Shruti', 'Gujr' => 'Shruti',
'Khmr' => 'MoolBoran', 'Khmr' => 'MoolBoran',
'Knda' => 'Tunga', 'Knda' => 'Tunga',
'Guru' => 'Raavi', 'Guru' => 'Raavi',
'Cans' => 'Euphemia', 'Cans' => 'Euphemia',
'Cher' => 'Plantagenet Cherokee', 'Cher' => 'Plantagenet Cherokee',
'Yiii' => 'Microsoft Yi Baiti', 'Yiii' => 'Microsoft Yi Baiti',
'Tibt' => 'Microsoft Himalaya', 'Tibt' => 'Microsoft Himalaya',
'Thaa' => 'MV Boli', 'Thaa' => 'MV Boli',
'Deva' => 'Mangal', 'Deva' => 'Mangal',
'Telu' => 'Gautami', 'Telu' => 'Gautami',
'Taml' => 'Latha', 'Taml' => 'Latha',
'Syrc' => 'Estrangelo Edessa', 'Syrc' => 'Estrangelo Edessa',
'Orya' => 'Kalinga', 'Orya' => 'Kalinga',
'Mlym' => 'Kartika', 'Mlym' => 'Kartika',
'Laoo' => 'DokChampa', 'Laoo' => 'DokChampa',
'Sinh' => 'Iskoola Pota', 'Sinh' => 'Iskoola Pota',
'Mong' => 'Mongolian Baiti', 'Mong' => 'Mongolian Baiti',
'Viet' => 'Times New Roman', 'Viet' => 'Times New Roman',
'Uigh' => 'Microsoft Uighur', 'Uigh' => 'Microsoft Uighur',
'Geor' => 'Sylfaen', 'Geor' => 'Sylfaen',
); );
/** /**
* Map of Minor fonts to write * Map of Minor fonts to write
@ -79,55 +79,55 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
* *
*/ */
private static $_minorFonts = array( private static $_minorFonts = array(
'Jpan' => ' Pゴシック', 'Jpan' => ' Pゴシック',
'Hang' => '맑은 고딕', 'Hang' => '맑은 고딕',
'Hans' => '宋体', 'Hans' => '宋体',
'Hant' => '新細明體', 'Hant' => '新細明體',
'Arab' => 'Arial', 'Arab' => 'Arial',
'Hebr' => 'Arial', 'Hebr' => 'Arial',
'Thai' => 'Tahoma', 'Thai' => 'Tahoma',
'Ethi' => 'Nyala', 'Ethi' => 'Nyala',
'Beng' => 'Vrinda', 'Beng' => 'Vrinda',
'Gujr' => 'Shruti', 'Gujr' => 'Shruti',
'Khmr' => 'DaunPenh', 'Khmr' => 'DaunPenh',
'Knda' => 'Tunga', 'Knda' => 'Tunga',
'Guru' => 'Raavi', 'Guru' => 'Raavi',
'Cans' => 'Euphemia', 'Cans' => 'Euphemia',
'Cher' => 'Plantagenet Cherokee', 'Cher' => 'Plantagenet Cherokee',
'Yiii' => 'Microsoft Yi Baiti', 'Yiii' => 'Microsoft Yi Baiti',
'Tibt' => 'Microsoft Himalaya', 'Tibt' => 'Microsoft Himalaya',
'Thaa' => 'MV Boli', 'Thaa' => 'MV Boli',
'Deva' => 'Mangal', 'Deva' => 'Mangal',
'Telu' => 'Gautami', 'Telu' => 'Gautami',
'Taml' => 'Latha', 'Taml' => 'Latha',
'Syrc' => 'Estrangelo Edessa', 'Syrc' => 'Estrangelo Edessa',
'Orya' => 'Kalinga', 'Orya' => 'Kalinga',
'Mlym' => 'Kartika', 'Mlym' => 'Kartika',
'Laoo' => 'DokChampa', 'Laoo' => 'DokChampa',
'Sinh' => 'Iskoola Pota', 'Sinh' => 'Iskoola Pota',
'Mong' => 'Mongolian Baiti', 'Mong' => 'Mongolian Baiti',
'Viet' => 'Arial', 'Viet' => 'Arial',
'Uigh' => 'Microsoft Uighur', 'Uigh' => 'Microsoft Uighur',
'Geor' => 'Sylfaen', 'Geor' => 'Sylfaen',
); );
/** /**
* Map of core colours * Map of core colours
* @static array of string * @static array of string
* *
*/ */
private static $_colourScheme = array( private static $_colourScheme = array(
'dk2' => '1F497D', 'dk2' => '1F497D',
'lt2' => 'EEECE1', 'lt2' => 'EEECE1',
'accent1' => '4F81BD', 'accent1' => '4F81BD',
'accent2' => 'C0504D', 'accent2' => 'C0504D',
'accent3' => '9BBB59', 'accent3' => '9BBB59',
'accent4' => '8064A2', 'accent4' => '8064A2',
'accent5' => '4BACC6', 'accent5' => '4BACC6',
'accent6' => 'F79646', 'accent6' => 'F79646',
'hlink' => '0000FF', 'hlink' => '0000FF',
'folHlink' => '800080', 'folHlink' => '800080',
); );
/** /**
* Write theme to XML format * Write theme to XML format
@ -147,7 +147,7 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// a:theme // a:theme
$objWriter->startElement('a:theme'); $objWriter->startElement('a:theme');
@ -839,13 +839,12 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->writeAttribute('typeface', ''); $objWriter->writeAttribute('typeface', '');
$objWriter->endElement(); $objWriter->endElement();
foreach($fontSet as $fontScript => $typeface) { foreach ($fontSet as $fontScript => $typeface) {
$objWriter->startElement('a:font'); $objWriter->startElement('a:font');
$objWriter->writeAttribute('script', $fontScript); $objWriter->writeAttribute('script', $fontScript);
$objWriter->writeAttribute('typeface', $typeface); $objWriter->writeAttribute('typeface', $typeface);
$objWriter->endElement(); $objWriter->endElement();
} }
} }
/** /**
@ -857,7 +856,7 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
*/ */
private function _writeColourScheme($objWriter) private function _writeColourScheme($objWriter)
{ {
foreach(self::$_colourScheme as $colourName => $colourValue) { foreach (self::$_colourScheme as $colourName => $colourValue) {
$objWriter->startElement('a:'.$colourName); $objWriter->startElement('a:'.$colourName);
$objWriter->startElement('a:srgbClr'); $objWriter->startElement('a:srgbClr');
@ -866,6 +865,5 @@ class PHPExcel_Writer_Excel2007_Theme extends PHPExcel_Writer_Excel2007_WriterPa
$objWriter->endElement(); $objWriter->endElement();
} }
} }
} }

View File

@ -43,7 +43,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
* @return string XML Output * @return string XML Output
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = FALSE) public function writeWorkbook(PHPExcel $pPHPExcel = null, $recalcRequired = false)
{ {
// Create XML writer // Create XML writer
$objWriter = null; $objWriter = null;
@ -54,7 +54,7 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// workbook // workbook
$objWriter->startElement('workbook'); $objWriter->startElement('workbook');
@ -62,28 +62,28 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/spreadsheetml/2006/main');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'); $objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
// fileVersion // fileVersion
$this->_writeFileVersion($objWriter); $this->_writeFileVersion($objWriter);
// workbookPr // workbookPr
$this->_writeWorkbookPr($objWriter); $this->_writeWorkbookPr($objWriter);
// workbookProtection // workbookProtection
$this->_writeWorkbookProtection($objWriter, $pPHPExcel); $this->_writeWorkbookProtection($objWriter, $pPHPExcel);
// bookViews // bookViews
if ($this->getParentWriter()->getOffice2003Compatibility() === false) { if ($this->getParentWriter()->getOffice2003Compatibility() === false) {
$this->_writeBookViews($objWriter, $pPHPExcel); $this->_writeBookViews($objWriter, $pPHPExcel);
} }
// sheets // sheets
$this->_writeSheets($objWriter, $pPHPExcel); $this->_writeSheets($objWriter, $pPHPExcel);
// definedNames // definedNames
$this->_writeDefinedNames($objWriter, $pPHPExcel); $this->_writeDefinedNames($objWriter, $pPHPExcel);
// calcPr // calcPr
$this->_writeCalcPr($objWriter,$recalcRequired); $this->_writeCalcPr($objWriter, $recalcRequired);
$objWriter->endElement(); $objWriter->endElement();
@ -138,20 +138,20 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
// bookViews // bookViews
$objWriter->startElement('bookViews'); $objWriter->startElement('bookViews');
// workbookView // workbookView
$objWriter->startElement('workbookView'); $objWriter->startElement('workbookView');
$objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex()); $objWriter->writeAttribute('activeTab', $pPHPExcel->getActiveSheetIndex());
$objWriter->writeAttribute('autoFilterDateGrouping', '1'); $objWriter->writeAttribute('autoFilterDateGrouping', '1');
$objWriter->writeAttribute('firstSheet', '0'); $objWriter->writeAttribute('firstSheet', '0');
$objWriter->writeAttribute('minimized', '0'); $objWriter->writeAttribute('minimized', '0');
$objWriter->writeAttribute('showHorizontalScroll', '1'); $objWriter->writeAttribute('showHorizontalScroll', '1');
$objWriter->writeAttribute('showSheetTabs', '1'); $objWriter->writeAttribute('showSheetTabs', '1');
$objWriter->writeAttribute('showVerticalScroll', '1'); $objWriter->writeAttribute('showVerticalScroll', '1');
$objWriter->writeAttribute('tabRatio', '600'); $objWriter->writeAttribute('tabRatio', '600');
$objWriter->writeAttribute('visibility', 'visible'); $objWriter->writeAttribute('visibility', 'visible');
$objWriter->endElement(); $objWriter->endElement();
$objWriter->endElement(); $objWriter->endElement();
} }
@ -167,16 +167,16 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
{ {
if ($pPHPExcel->getSecurity()->isSecurityEnabled()) { if ($pPHPExcel->getSecurity()->isSecurityEnabled()) {
$objWriter->startElement('workbookProtection'); $objWriter->startElement('workbookProtection');
$objWriter->writeAttribute('lockRevision', ($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false')); $objWriter->writeAttribute('lockRevision', ($pPHPExcel->getSecurity()->getLockRevision() ? 'true' : 'false'));
$objWriter->writeAttribute('lockStructure', ($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false')); $objWriter->writeAttribute('lockStructure', ($pPHPExcel->getSecurity()->getLockStructure() ? 'true' : 'false'));
$objWriter->writeAttribute('lockWindows', ($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false')); $objWriter->writeAttribute('lockWindows', ($pPHPExcel->getSecurity()->getLockWindows() ? 'true' : 'false'));
if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') { if ($pPHPExcel->getSecurity()->getRevisionsPassword() != '') {
$objWriter->writeAttribute('revisionsPassword', $pPHPExcel->getSecurity()->getRevisionsPassword()); $objWriter->writeAttribute('revisionsPassword', $pPHPExcel->getSecurity()->getRevisionsPassword());
} }
if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') { if ($pPHPExcel->getSecurity()->getWorkbookPassword() != '') {
$objWriter->writeAttribute('workbookPassword', $pPHPExcel->getSecurity()->getWorkbookPassword()); $objWriter->writeAttribute('workbookPassword', $pPHPExcel->getSecurity()->getWorkbookPassword());
} }
$objWriter->endElement(); $objWriter->endElement();
@ -190,18 +190,18 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
* @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing * @param boolean $recalcRequired Indicate whether formulas should be recalculated before writing
* @throws PHPExcel_Writer_Exception * @throws PHPExcel_Writer_Exception
*/ */
private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = TRUE) private function _writeCalcPr(PHPExcel_Shared_XMLWriter $objWriter = null, $recalcRequired = true)
{ {
$objWriter->startElement('calcPr'); $objWriter->startElement('calcPr');
// Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc // Set the calcid to a higher value than Excel itself will use, otherwise Excel will always recalc
// If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit // If MS Excel does do a recalc, then users opening a file in MS Excel will be prompted to save on exit
// because the file has changed // because the file has changed
$objWriter->writeAttribute('calcId', '999999'); $objWriter->writeAttribute('calcId', '999999');
$objWriter->writeAttribute('calcMode', 'auto'); $objWriter->writeAttribute('calcMode', 'auto');
// fullCalcOnLoad isn't needed if we've recalculating for the save // fullCalcOnLoad isn't needed if we've recalculating for the save
$objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0); $objWriter->writeAttribute('calcCompleted', ($recalcRequired) ? 1 : 0);
$objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1); $objWriter->writeAttribute('fullCalcOnLoad', ($recalcRequired) ? 0 : 1);
$objWriter->endElement(); $objWriter->endElement();
} }
@ -247,12 +247,12 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
if ($pSheetname != '') { if ($pSheetname != '') {
// Write sheet // Write sheet
$objWriter->startElement('sheet'); $objWriter->startElement('sheet');
$objWriter->writeAttribute('name', $pSheetname); $objWriter->writeAttribute('name', $pSheetname);
$objWriter->writeAttribute('sheetId', $pSheetId); $objWriter->writeAttribute('sheetId', $pSheetId);
if ($sheetState != 'visible' && $sheetState != '') { if ($sheetState != 'visible' && $sheetState != '') {
$objWriter->writeAttribute('state', $sheetState); $objWriter->writeAttribute('state', $sheetState);
} }
$objWriter->writeAttribute('r:id', 'rId' . $pRelId); $objWriter->writeAttribute('r:id', 'rId' . $pRelId);
$objWriter->endElement(); $objWriter->endElement();
} else { } else {
throw new PHPExcel_Writer_Exception("Invalid parameters passed."); throw new PHPExcel_Writer_Exception("Invalid parameters passed.");
@ -320,9 +320,9 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
{ {
// definedName for named range // definedName for named range
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', $pNamedRange->getName()); $objWriter->writeAttribute('name', $pNamedRange->getName());
if ($pNamedRange->getLocalOnly()) { if ($pNamedRange->getLocalOnly()) {
$objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope())); $objWriter->writeAttribute('localSheetId', $pNamedRange->getScope()->getParent()->getIndex($pNamedRange->getScope()));
} }
// Create absolute coordinate and write as raw text // Create absolute coordinate and write as raw text
@ -354,16 +354,16 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
$autoFilterRange = $pSheet->getAutoFilter()->getRange(); $autoFilterRange = $pSheet->getAutoFilter()->getRange();
if (!empty($autoFilterRange)) { if (!empty($autoFilterRange)) {
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', '_xlnm._FilterDatabase'); $objWriter->writeAttribute('name', '_xlnm._FilterDatabase');
$objWriter->writeAttribute('localSheetId', $pSheetId); $objWriter->writeAttribute('localSheetId', $pSheetId);
$objWriter->writeAttribute('hidden', '1'); $objWriter->writeAttribute('hidden', '1');
// Create absolute coordinate and write as raw text // Create absolute coordinate and write as raw text
$range = PHPExcel_Cell::splitRange($autoFilterRange); $range = PHPExcel_Cell::splitRange($autoFilterRange);
$range = $range[0]; $range = $range[0];
// Strip any worksheet ref so we can make the cell ref absolute // Strip any worksheet ref so we can make the cell ref absolute
if (strpos($range[0],'!') !== false) { if (strpos($range[0],'!') !== false) {
list($ws,$range[0]) = explode('!',$range[0]); list($ws, $range[0]) = explode('!', $range[0]);
} }
$range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]); $range[0] = PHPExcel_Cell::absoluteCoordinate($range[0]);
@ -389,8 +389,8 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
// definedName for PrintTitles // definedName for PrintTitles
if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) { if ($pSheet->getPageSetup()->isColumnsToRepeatAtLeftSet() || $pSheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', '_xlnm.Print_Titles'); $objWriter->writeAttribute('name', '_xlnm.Print_Titles');
$objWriter->writeAttribute('localSheetId', $pSheetId); $objWriter->writeAttribute('localSheetId', $pSheetId);
// Setting string // Setting string
$settingString = ''; $settingString = '';
@ -432,8 +432,8 @@ class PHPExcel_Writer_Excel2007_Workbook extends PHPExcel_Writer_Excel2007_Write
// definedName for PrintArea // definedName for PrintArea
if ($pSheet->getPageSetup()->isPrintAreaSet()) { if ($pSheet->getPageSetup()->isPrintAreaSet()) {
$objWriter->startElement('definedName'); $objWriter->startElement('definedName');
$objWriter->writeAttribute('name', '_xlnm.Print_Area'); $objWriter->writeAttribute('name', '_xlnm.Print_Area');
$objWriter->writeAttribute('localSheetId', $pSheetId); $objWriter->writeAttribute('localSheetId', $pSheetId);
// Setting string // Setting string
$settingString = ''; $settingString = '';

View File

@ -56,7 +56,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
} }
// XML header // XML header
$objWriter->startDocument('1.0','UTF-8','yes'); $objWriter->startDocument('1.0', 'UTF-8', 'yes');
// Worksheet // Worksheet
$objWriter->startElement('worksheet'); $objWriter->startElement('worksheet');
@ -148,8 +148,8 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// sheetPr // sheetPr
$objWriter->startElement('sheetPr'); $objWriter->startElement('sheetPr');
//$objWriter->writeAttribute('codeName', $pSheet->getTitle()); //$objWriter->writeAttribute('codeName', $pSheet->getTitle());
if($pSheet->getParent()->hasMacros()){//if the workbook have macros, we need to have codeName for the sheet if ($pSheet->getParent()->hasMacros()) {//if the workbook have macros, we need to have codeName for the sheet
if($pSheet->hasCodeName()==false){ if ($pSheet->hasCodeName()==false) {
$pSheet->setCodeName($pSheet->getTitle()); $pSheet->setCodeName($pSheet->getTitle());
} }
$objWriter->writeAttribute('codeName', $pSheet->getCodeName()); $objWriter->writeAttribute('codeName', $pSheet->getCodeName());
@ -758,15 +758,15 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
$range = $range[0]; $range = $range[0];
// Strip any worksheet ref // Strip any worksheet ref
if (strpos($range[0],'!') !== false) { if (strpos($range[0],'!') !== false) {
list($ws,$range[0]) = explode('!',$range[0]); list($ws, $range[0]) = explode('!', $range[0]);
} }
$range = implode(':', $range); $range = implode(':', $range);
$objWriter->writeAttribute('ref', str_replace('$','',$range)); $objWriter->writeAttribute('ref', str_replace('$','', $range));
$columns = $pSheet->getAutoFilter()->getColumns(); $columns = $pSheet->getAutoFilter()->getColumns();
if (count($columns > 0)) { if (count($columns > 0)) {
foreach($columns as $columnID => $column) { foreach ($columns as $columnID => $column) {
$rules = $column->getRules(); $rules = $column->getRules();
if (count($rules > 0)) { if (count($rules > 0)) {
$objWriter->startElement('filterColumn'); $objWriter->startElement('filterColumn');
@ -783,7 +783,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
($rule->getValue() === '')) { ($rule->getValue() === '')) {
// Filter rule for Blanks // Filter rule for Blanks
$objWriter->writeAttribute('blank', 1); $objWriter->writeAttribute('blank', 1);
} elseif($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { } elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) {
// Dynamic Filter Rule // Dynamic Filter Rule
$objWriter->writeAttribute('type', $rule->getGrouping()); $objWriter->writeAttribute('type', $rule->getGrouping());
$val = $column->getAttribute('val'); $val = $column->getAttribute('val');
@ -794,7 +794,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
if ($maxVal !== NULL) { if ($maxVal !== NULL) {
$objWriter->writeAttribute('maxVal', $maxVal); $objWriter->writeAttribute('maxVal', $maxVal);
} }
} elseif($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) { } elseif ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_TOPTENFILTER) {
// Top 10 Filter Rule // Top 10 Filter Rule
$objWriter->writeAttribute('val', $rule->getValue()); $objWriter->writeAttribute('val', $rule->getValue());
$objWriter->writeAttribute('percent', (($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0')); $objWriter->writeAttribute('percent', (($rule->getOperator() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0'));
@ -808,7 +808,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
} }
if ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP) { if ($rule->getRuleType() === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP) {
// Date Group filters // Date Group filters
foreach($rule->getValue() as $key => $value) { foreach ($rule->getValue() as $key => $value) {
if ($value > '') $objWriter->writeAttribute($key, $value); if ($value > '') $objWriter->writeAttribute($key, $value);
} }
$objWriter->writeAttribute('dateTimeGrouping', $rule->getGrouping()); $objWriter->writeAttribute('dateTimeGrouping', $rule->getGrouping());
@ -979,7 +979,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
} }
$currentRow = 0; $currentRow = 0;
while($currentRow++ < $highestRow) { while ($currentRow++ < $highestRow) {
// Get row dimension // Get row dimension
$rowDimension = $pSheet->getRowDimension($currentRow); $rowDimension = $pSheet->getRowDimension($currentRow);
@ -1026,7 +1026,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
// Write cells // Write cells
if (isset($cellsByRow[$currentRow])) { if (isset($cellsByRow[$currentRow])) {
foreach($cellsByRow[$currentRow] as $cellAddress) { foreach ($cellsByRow[$currentRow] as $cellAddress) {
// Write cell // Write cell
$this->_writeCell($objWriter, $pSheet, $cellAddress, $pStringTable, $aFlippedStringTable); $this->_writeCell($objWriter, $pSheet, $cellAddress, $pStringTable, $aFlippedStringTable);
} }
@ -1115,7 +1115,7 @@ class PHPExcel_Writer_Excel2007_Worksheet extends PHPExcel_Writer_Excel2007_Writ
break; break;
case 'f': // Formula case 'f': // Formula
$attributes = $pCell->getFormulaAttributes(); $attributes = $pCell->getFormulaAttributes();
if($attributes['t'] == 'array') { if ($attributes['t'] == 'array') {
$objWriter->startElement('f'); $objWriter->startElement('f');
$objWriter->writeAttribute('t', 'array'); $objWriter->writeAttribute('t', 'array');
$objWriter->writeAttribute('ref', $pCellAddress); $objWriter->writeAttribute('ref', $pCellAddress);

View File

@ -333,7 +333,7 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$iNumColEnd = $rangeBounds[1][0]; $iNumColEnd = $rangeBounds[1][0];
$iInc = $iNumColStart; $iInc = $iNumColStart;
while($iInc <= $iNumColEnd) { while ($iInc <= $iNumColEnd) {
++$countShapes[$sheetIndex]; ++$countShapes[$sheetIndex];
// create an Drawing Object for the dropdown // create an Drawing Object for the dropdown
@ -679,21 +679,18 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x0B) { // Boolean
elseif ($dataProp['type']['data'] == 0x0B) { // Boolean
if ($dataProp['data']['data'] == false) { if ($dataProp['data']['data'] == false) {
$dataSection_Content .= pack('V', 0x0000); $dataSection_Content .= pack('V', 0x0000);
} else { } else {
$dataSection_Content .= pack('V', 0x0001); $dataSection_Content .= pack('V', 0x0001);
} }
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
// Null-terminated string // Null-terminated string
$dataProp['data']['data'] .= chr(0); $dataProp['data']['data'] .= chr(0);
$dataProp['data']['length'] += 1; $dataProp['data']['length'] += 1;
@ -705,13 +702,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
} } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 8; $dataSection_Content_Offset += 4 + 8;
} } else {
else {
// Data Type Not Used at the moment // Data Type Not Used at the moment
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
@ -867,13 +862,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
elseif ($dataProp['type']['data'] == 0x03) { // 4 byte signed integer
$dataSection_Content .= pack('V', $dataProp['data']['data']); $dataSection_Content .= pack('V', $dataProp['data']['data']);
$dataSection_Content_Offset += 4 + 4; $dataSection_Content_Offset += 4 + 4;
} } elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
elseif ($dataProp['type']['data'] == 0x1E) { // null-terminated string prepended by dword string length
// Null-terminated string // Null-terminated string
$dataProp['data']['data'] .= chr(0); $dataProp['data']['data'] .= chr(0);
$dataProp['data']['length'] += 1; $dataProp['data']['length'] += 1;
@ -885,13 +878,11 @@ class PHPExcel_Writer_Excel5 extends PHPExcel_Writer_Abstract implements PHPExce
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']);
} } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601)
$dataSection_Content .= $dataProp['data']['data']; $dataSection_Content .= $dataProp['data']['data'];
$dataSection_Content_Offset += 4 + 8; $dataSection_Content_Offset += 4 + 8;
} } else {
else {
// Data Type Not Used at the moment // Data Type Not Used at the moment
} }
} }

View File

@ -1097,7 +1097,7 @@ class PHPExcel_Writer_Excel5_Parser
*/ */
private function _match($token) private function _match($token)
{ {
switch($token) { switch ($token) {
case "+": case "+":
case "-": case "-":
case "*": case "*":
@ -1183,7 +1183,7 @@ class PHPExcel_Writer_Excel5_Parser
} }
// It's an argument of some description (e.g. a named range), // It's an argument of some description (e.g. a named range),
// precise nature yet to be determined // precise nature yet to be determined
elseif(substr($token,-1) == ')') { elseif (substr($token,-1) == ')') {
return $token; return $token;
} }
return ''; return '';
@ -1425,7 +1425,7 @@ class PHPExcel_Writer_Excel5_Parser
// If it's a number or a percent // If it's a number or a percent
elseif (is_numeric($this->_current_token)) elseif (is_numeric($this->_current_token))
{ {
if($this->_lookahead == '%'){ if ($this->_lookahead == '%') {
$result = $this->_createTree('ptgPercent', $this->_current_token, ''); $result = $this->_createTree('ptgPercent', $this->_current_token, '');
$this->_advance(); // Skip the percentage operator once we've pre-built that tree $this->_advance(); // Skip the percentage operator once we've pre-built that tree
} else { } else {

View File

@ -1275,7 +1275,7 @@ class PHPExcel_Writer_Excel5_Workbook extends PHPExcel_Writer_Excel5_BIFFwriter
// Pack the RGB data // Pack the RGB data
foreach ($aref as $color) { foreach ($aref as $color) {
foreach ($color as $byte) { foreach ($color as $byte) {
$data .= pack("C",$byte); $data .= pack("C", $byte);
} }
} }