Merge branch 'psr2' into develop

This commit is contained in:
MarkBaker 2015-05-17 00:48:21 +01:00
commit 4a6686e2dd
44 changed files with 6389 additions and 6747 deletions

View File

@ -1703,7 +1703,6 @@ class PHPExcel_Calculation
) )
); );
// Internal functions used for special control purposes // Internal functions used for special control purposes
private static $controlFunctions = array( private static $controlFunctions = array(
'MKMATRIX' => array( 'MKMATRIX' => array(
@ -1739,7 +1738,7 @@ class PHPExcel_Calculation
} }
} }
private static function _loadLocales() private static function loadLocales()
{ {
$localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/'; $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
foreach (glob($localeFileDirectory.'/*', GLOB_ONLYDIR) as $filename) { foreach (glob($localeFileDirectory.'/*', GLOB_ONLYDIR) as $filename) {
@ -1981,7 +1980,7 @@ class PHPExcel_Calculation
} }
if (count(self::$validLocaleLanguages) == 1) { if (count(self::$validLocaleLanguages) == 1) {
self::_loadLocales(); self::loadLocales();
} }
// Test whether we have any language data for this language (any locale) // Test whether we have any language data for this language (any locale)
if (in_array($language, self::$validLocaleLanguages)) { if (in_array($language, self::$validLocaleLanguages)) {
@ -2439,7 +2438,7 @@ class PHPExcel_Calculation
if (($wsTitle{0} !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) { if (($wsTitle{0} !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) {
if ($this->cyclicFormulaCount <= 0) { if ($this->cyclicFormulaCount <= 0) {
$this->cyclicFormulaCell = ''; $this->cyclicFormulaCell = '';
return $this->_raiseFormulaError('Cyclic Reference in Formula'); return $this->raiseFormulaError('Cyclic Reference in Formula');
} elseif ($this->cyclicFormulaCell === $wsCellReference) { } elseif ($this->cyclicFormulaCell === $wsCellReference) {
++$this->cyclicFormulaCounter; ++$this->cyclicFormulaCounter;
if ($this->cyclicFormulaCounter >= $this->cyclicFormulaCount) { if ($this->cyclicFormulaCounter >= $this->cyclicFormulaCount) {
@ -2736,15 +2735,15 @@ class PHPExcel_Calculation
// Trap for mismatched braces and trigger an appropriate error // Trap for mismatched braces and trigger an appropriate error
if ($openCount < $closeCount) { if ($openCount < $closeCount) {
if ($openCount > 0) { if ($openCount > 0) {
return $this->_raiseFormulaError("Formula Error: Mismatched matrix braces '}'"); return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '}'");
} else { } else {
return $this->_raiseFormulaError("Formula Error: Unexpected '}' encountered"); return $this->raiseFormulaError("Formula Error: Unexpected '}' encountered");
} }
} elseif ($openCount > $closeCount) { } elseif ($openCount > $closeCount) {
if ($closeCount > 0) { if ($closeCount > 0) {
return $this->_raiseFormulaError("Formula Error: Mismatched matrix braces '{'"); return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '{'");
} else { } else {
return $this->_raiseFormulaError("Formula Error: Unexpected '{' encountered"); return $this->raiseFormulaError("Formula Error: Unexpected '{' encountered");
} }
} }
} }
@ -2846,7 +2845,7 @@ class PHPExcel_Calculation
//echo 'Element is a Positive number, not Plus operator', PHP_EOL; //echo 'Element is a Positive number, not Plus operator', PHP_EOL;
++$index; // Drop the redundant plus symbol ++$index; // Drop the redundant plus symbol
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal
return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
} elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? } elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
//echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL; //echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL;
@ -2865,7 +2864,7 @@ class PHPExcel_Calculation
$expectingOperand = false; $expectingOperand = false;
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
if ($o2 === null) { if ($o2 === null) {
return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"'); return $this->raiseFormulaError('Formula Error: Unexpected closing brace ")"');
} else { } else {
$output[] = $o2; $output[] = $o2;
} }
@ -2894,7 +2893,7 @@ class PHPExcel_Calculation
$expectedArgumentCount = self::$PHPExcelFunctions[$functionName]['argumentCount']; $expectedArgumentCount = self::$PHPExcelFunctions[$functionName]['argumentCount'];
$functionCall = self::$PHPExcelFunctions[$functionName]['functionCall']; $functionCall = self::$PHPExcelFunctions[$functionName]['functionCall'];
} else { // did we somehow push a non-function on the stack? this should never happen } else { // did we somehow push a non-function on the stack? this should never happen
return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack"); return $this->raiseFormulaError("Formula Error: Internal error, non-function on stack");
} }
// Check the argument count // Check the argument count
$argumentCountError = false; $argumentCountError = false;
@ -2938,7 +2937,7 @@ class PHPExcel_Calculation
} }
} }
if ($argumentCountError) { if ($argumentCountError) {
return $this->_raiseFormulaError("Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, ".$expectedArgumentCountString." expected"); return $this->raiseFormulaError("Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, ".$expectedArgumentCountString." expected");
} }
} }
++$index; ++$index;
@ -2947,7 +2946,7 @@ class PHPExcel_Calculation
//echo 'Element is a Function argument separator', PHP_EOL; //echo 'Element is a Function argument separator', PHP_EOL;
while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
if ($o2 === null) { if ($o2 === null) {
return $this->_raiseFormulaError("Formula Error: Unexpected ,"); return $this->raiseFormulaError("Formula Error: Unexpected ,");
} else { } else {
$output[] = $o2; // pop the argument expression stuff and push onto the output $output[] = $o2; // pop the argument expression stuff and push onto the output
} }
@ -2960,7 +2959,7 @@ class PHPExcel_Calculation
// make sure there was a function // make sure there was a function
$d = $stack->last(2); $d = $stack->last(2);
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
@ -3016,7 +3015,7 @@ class PHPExcel_Calculation
$val = $startMatches[2].'!'.$val; $val = $startMatches[2].'!'.$val;
} }
} else { } else {
return $this->_raiseFormulaError("3D Range references are not yet supported"); return $this->raiseFormulaError("3D Range references are not yet supported");
} }
} }
@ -3095,19 +3094,19 @@ class PHPExcel_Calculation
$expectingOperand = false; $expectingOperand = false;
$expectingOperator = true; $expectingOperator = true;
} else { } else {
return $this->_raiseFormulaError("Formula Error: Unexpected ')'"); return $this->raiseFormulaError("Formula Error: Unexpected ')'");
} }
} elseif (isset(self::$operators[$opCharacter]) && !$expectingOperator) { } elseif (isset(self::$operators[$opCharacter]) && !$expectingOperator) {
return $this->_raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'"); return $this->raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'");
} else { // I don't even want to know what you did to get here } else { // I don't even want to know what you did to get here
return $this->_raiseFormulaError("Formula Error: An unexpected error occured"); return $this->raiseFormulaError("Formula Error: An unexpected error occured");
} }
// Test for end of formula string // Test for end of formula string
if ($index == strlen($formula)) { if ($index == strlen($formula)) {
// Did we end with an operator?. // Did we end with an operator?.
// Only valid for the % unary operator // Only valid for the % unary operator
if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) { if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) {
return $this->_raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands"); return $this->raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
} else { } else {
break; break;
} }
@ -3140,7 +3139,7 @@ class PHPExcel_Calculation
while (($op = $stack->pop()) !== null) { // pop everything off the stack and push onto output while (($op = $stack->pop()) !== null) { // pop everything off the stack and push onto output
if ((is_array($op) && $op['value'] == '(') || ($op === '(')) { if ((is_array($op) && $op['value'] == '(') || ($op === '(')) {
return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced return $this->raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced
} }
$output[] = $op; $output[] = $op;
} }
@ -3187,10 +3186,10 @@ class PHPExcel_Calculation
// echo 'Token is a binary operator<br />'; // echo 'Token is a binary operator<br />';
// We must have two operands, error if we don't // We must have two operands, error if we don't
if (($operand2Data = $stack->pop()) === null) { if (($operand2Data = $stack->pop()) === null) {
return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); return $this->raiseFormulaError('Internal error - Operand value missing from stack');
} }
if (($operand1Data = $stack->pop()) === null) { if (($operand1Data = $stack->pop()) === null) {
return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); return $this->raiseFormulaError('Internal error - Operand value missing from stack');
} }
$operand1 = self::_dataTestReference($operand1Data); $operand1 = self::_dataTestReference($operand1Data);
@ -3212,7 +3211,7 @@ 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
@ -3258,7 +3257,7 @@ class PHPExcel_Calculation
if ($pCellParent !== null) { if ($pCellParent !== null) {
$cellValue = $this->extractCellRange($cellRef, $this->workbook->getSheetByName($sheet1), false); $cellValue = $this->extractCellRange($cellRef, $this->workbook->getSheetByName($sheet1), false);
} else { } else {
return $this->_raiseFormulaError('Unable to access Cell Reference'); return $this->raiseFormulaError('Unable to access Cell Reference');
} }
$stack->push('Cell Reference', $cellValue, $cellRef); $stack->push('Cell Reference', $cellValue, $cellRef);
} else { } else {
@ -3266,19 +3265,19 @@ class PHPExcel_Calculation
} }
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
@ -3329,7 +3328,7 @@ class PHPExcel_Calculation
} elseif (($token === '~') || ($token === '%')) { } elseif (($token === '~') || ($token === '%')) {
// echo 'Token is a unary operator<br />'; // echo 'Token is a unary operator<br />';
if (($arg = $stack->pop()) === null) { if (($arg = $stack->pop()) === null) {
return $this->_raiseFormulaError('Internal error - Operand value missing from stack'); return $this->raiseFormulaError('Internal error - Operand value missing from stack');
} }
$arg = $arg['value']; $arg = $arg['value'];
if ($token === '~') { if ($token === '~') {
@ -3354,7 +3353,7 @@ class PHPExcel_Calculation
$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)) {
@ -3371,7 +3370,7 @@ class PHPExcel_Calculation
$matches[2] = trim($matches[2], "\"'"); $matches[2] = trim($matches[2], "\"'");
if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) {
// It's a Reference to an external workbook (not currently supported) // It's a Reference to an external workbook (not currently supported)
return $this->_raiseFormulaError('Unable to access External Workbook'); return $this->raiseFormulaError('Unable to access External Workbook');
} }
$matches[2] = trim($matches[2], "\"'"); $matches[2] = trim($matches[2], "\"'");
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />'; // echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
@ -3379,7 +3378,7 @@ class PHPExcel_Calculation
if ($pCellParent !== null) { if ($pCellParent !== null) {
$cellValue = $this->extractCellRange($cellRef, $this->workbook->getSheetByName($matches[2]), false); $cellValue = $this->extractCellRange($cellRef, $this->workbook->getSheetByName($matches[2]), false);
} else { } else {
return $this->_raiseFormulaError('Unable to access Cell Reference'); return $this->raiseFormulaError('Unable to access Cell Reference');
} }
$this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue)); $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue));
// $cellRef = $matches[2].'!'.$cellRef; // $cellRef = $matches[2].'!'.$cellRef;
@ -3389,7 +3388,7 @@ class PHPExcel_Calculation
if ($pCellParent !== null) { if ($pCellParent !== null) {
$cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, false); $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, false);
} else { } else {
return $this->_raiseFormulaError('Unable to access Cell Reference'); return $this->raiseFormulaError('Unable to access Cell Reference');
} }
$this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' is ', $this->_showTypeDetails($cellValue)); $this->_debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' is ', $this->_showTypeDetails($cellValue));
} }
@ -3405,7 +3404,7 @@ class PHPExcel_Calculation
$matches[2] = trim($matches[2], "\"'"); $matches[2] = trim($matches[2], "\"'");
if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) {
// It's a Reference to an external workbook (not currently supported) // It's a Reference to an external workbook (not currently supported)
return $this->_raiseFormulaError('Unable to access External Workbook'); return $this->raiseFormulaError('Unable to access External Workbook');
} }
// echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />'; // echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
$this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in worksheet ', $matches[2]); $this->_debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in worksheet ', $matches[2]);
@ -3418,7 +3417,7 @@ class PHPExcel_Calculation
$cellValue = null; $cellValue = null;
} }
} else { } else {
return $this->_raiseFormulaError('Unable to access Cell Reference'); return $this->raiseFormulaError('Unable to access Cell Reference');
} }
$this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue)); $this->_debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->_showTypeDetails($cellValue));
// $cellRef = $matches[2].'!'.$cellRef; // $cellRef = $matches[2].'!'.$cellRef;
@ -3561,13 +3560,13 @@ class PHPExcel_Calculation
$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'");
} }
} }
} }
// when we're out of tokens, the stack should have a single element, the final result // when we're out of tokens, the stack should have a single element, the final result
if ($stack->count() != 1) { if ($stack->count() != 1) {
return $this->_raiseFormulaError("internal error"); return $this->raiseFormulaError("internal error");
} }
$output = $stack->pop(); $output = $stack->pop();
$output = $output['value']; $output = $output['value'];
@ -3579,7 +3578,7 @@ class PHPExcel_Calculation
} }
private function _validateBinaryOperand($cellID, &$operand, &$stack) private function validateBinaryOperand($cellID, &$operand, &$stack)
{ {
if (is_array($operand)) { if (is_array($operand)) {
if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) { if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) {
@ -3616,7 +3615,7 @@ class PHPExcel_Calculation
} }
private function _executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays = false) private function executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, &$stack, $recursingArrays = false)
{ {
// If we're dealing with matrix operations, we want a matrix result // If we're dealing with matrix operations, we want a matrix result
if ((is_array($operand1)) || (is_array($operand2))) { if ((is_array($operand1)) || (is_array($operand2))) {
@ -3624,14 +3623,14 @@ class PHPExcel_Calculation
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'];
} }
@ -3641,7 +3640,7 @@ class PHPExcel_Calculation
} }
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'];
} }
@ -3750,13 +3749,13 @@ 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)) { if (!$this->validateBinaryOperand($cellID, $operand1, $stack)) {
return false; return false;
} }
if (!$this->_validateBinaryOperand($cellID, $operand2, $stack)) { if (!$this->validateBinaryOperand($cellID, $operand2, $stack)) {
return false; return false;
} }
@ -3825,7 +3824,7 @@ class PHPExcel_Calculation
// trigger an error, but nicely, if need be // trigger an error, but nicely, if need be
protected function _raiseFormulaError($errorMessage) protected function raiseFormulaError($errorMessage)
{ {
$this->formulaError = $errorMessage; $this->formulaError = $errorMessage;
$this->cyclicReferenceStack->clear(); $this->cyclicReferenceStack->clear();

View File

@ -41,7 +41,7 @@ class PHPExcel_Chart_Legend
const POSITION_TOP = 't'; const POSITION_TOP = 't';
const POSITION_TOPRIGHT = 'tr'; const POSITION_TOPRIGHT = 'tr';
private static $_positionXLref = array( private static $positionXLref = array(
self::xlLegendPositionBottom => self::POSITION_BOTTOM, self::xlLegendPositionBottom => self::POSITION_BOTTOM,
self::xlLegendPositionCorner => self::POSITION_TOPRIGHT, self::xlLegendPositionCorner => self::POSITION_TOPRIGHT,
self::xlLegendPositionCustom => '??', self::xlLegendPositionCustom => '??',
@ -99,7 +99,7 @@ class PHPExcel_Chart_Legend
*/ */
public function setPosition($position = self::POSITION_RIGHT) public function setPosition($position = self::POSITION_RIGHT)
{ {
if (!in_array($position, self::$_positionXLref)) { if (!in_array($position, self::$positionXLref)) {
return false; return false;
} }
@ -114,7 +114,7 @@ class PHPExcel_Chart_Legend
*/ */
public function getPositionXL() public function getPositionXL()
{ {
return array_search($this->position, self::$_positionXLref); return array_search($this->position, self::$positionXLref);
} }
/** /**
@ -124,11 +124,11 @@ class PHPExcel_Chart_Legend
*/ */
public function setPositionXL($positionXL = self::xlLegendPositionRight) public function setPositionXL($positionXL = self::xlLegendPositionRight)
{ {
if (!array_key_exists($positionXL, self::$_positionXLref)) { if (!array_key_exists($positionXL, self::$positionXLref)) {
return false; return false;
} }
$this->position = self::$_positionXLref[$positionXL]; $this->position = self::$positionXLref[$positionXL];
return true; return true;
} }

View File

@ -752,16 +752,19 @@ class PHPExcel_Chart_Renderer_jpgraph
switch ($chartType) { switch ($chartType) {
case 'area3DChart': case 'area3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
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';
// no break
case 'barChart': case 'barChart':
$this->renderPlotBar($i, $dimensions); $this->renderPlotBar($i, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'lineChart': case 'lineChart':
$this->renderPlotLine($i, false, true, $dimensions); $this->renderPlotLine($i, false, true, $dimensions);
break; break;
@ -812,26 +815,31 @@ class PHPExcel_Chart_Renderer_jpgraph
switch ($chartType) { switch ($chartType) {
case 'area3DChart': case 'area3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'areaChart': case 'areaChart':
$this->renderAreaChart($groupCount, $dimensions); $this->renderAreaChart($groupCount, $dimensions);
break; break;
case 'bar3DChart': case 'bar3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'barChart': case 'barChart':
$this->renderBarChart($groupCount, $dimensions); $this->renderBarChart($groupCount, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'lineChart': case 'lineChart':
$this->renderLineChart($groupCount, $dimensions); $this->renderLineChart($groupCount, $dimensions);
break; break;
case 'pie3DChart': case 'pie3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
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';
// no break
case 'doughnutChart': case 'doughnutChart':
$this->renderPieChart($groupCount, $dimensions, true, true); $this->renderPieChart($groupCount, $dimensions, true, true);
break; break;
@ -846,6 +854,7 @@ class PHPExcel_Chart_Renderer_jpgraph
break; break;
case 'surface3DChart': case 'surface3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break
case 'surfaceChart': case 'surfaceChart':
$this->renderContourChart($groupCount, $dimensions); $this->renderContourChart($groupCount, $dimensions);
break; break;

View File

@ -535,7 +535,7 @@ class PHPExcel_DocumentProperties
return strtotime($propertyValue); return strtotime($propertyValue);
break; break;
case 'bool': // Boolean case 'bool': // Boolean
return ($propertyValue == 'true') ? True : False; return ($propertyValue == 'true') ? true : false;
break; break;
case 'cy': // Currency case 'cy': // Currency
case 'error': // Error Status Code case 'error': // Error Status Code
@ -556,7 +556,8 @@ class PHPExcel_DocumentProperties
return $propertyValue; return $propertyValue;
} }
public static function convertPropertyType($propertyType) { public static function convertPropertyType($propertyType)
{
switch ($propertyType) { switch ($propertyType) {
case 'i1': // 1-Byte Signed Integer case 'i1': // 1-Byte Signed Integer
case 'i2': // 2-Byte Signed Integer case 'i2': // 2-Byte Signed Integer
@ -607,5 +608,4 @@ class PHPExcel_DocumentProperties
} }
return self::PROPERTY_TYPE_UNKNOWN; return self::PROPERTY_TYPE_UNKNOWN;
} }
} }

View File

@ -32,35 +32,35 @@ class PHPExcel_DocumentSecurity
* *
* @var boolean * @var boolean
*/ */
private $_lockRevision; private $lockRevision;
/** /**
* LockStructure * LockStructure
* *
* @var boolean * @var boolean
*/ */
private $_lockStructure; private $lockStructure;
/** /**
* LockWindows * LockWindows
* *
* @var boolean * @var boolean
*/ */
private $_lockWindows; private $lockWindows;
/** /**
* RevisionsPassword * RevisionsPassword
* *
* @var string * @var string
*/ */
private $_revisionsPassword; private $revisionsPassword;
/** /**
* WorkbookPassword * WorkbookPassword
* *
* @var string * @var string
*/ */
private $_workbookPassword; private $workbookPassword;
/** /**
* Create a new PHPExcel_DocumentSecurity * Create a new PHPExcel_DocumentSecurity
@ -68,11 +68,11 @@ class PHPExcel_DocumentSecurity
public function __construct() public function __construct()
{ {
// Initialise values // Initialise values
$this->_lockRevision = false; $this->lockRevision = false;
$this->_lockStructure = false; $this->lockStructure = false;
$this->_lockWindows = false; $this->lockWindows = false;
$this->_revisionsPassword = ''; $this->revisionsPassword = '';
$this->_workbookPassword = ''; $this->workbookPassword = '';
} }
/** /**
@ -82,9 +82,9 @@ class PHPExcel_DocumentSecurity
*/ */
public function isSecurityEnabled() public function isSecurityEnabled()
{ {
return $this->_lockRevision || return $this->lockRevision ||
$this->_lockStructure || $this->lockStructure ||
$this->_lockWindows; $this->lockWindows;
} }
/** /**
@ -94,7 +94,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function getLockRevision() public function getLockRevision()
{ {
return $this->_lockRevision; return $this->lockRevision;
} }
/** /**
@ -105,7 +105,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function setLockRevision($pValue = false) public function setLockRevision($pValue = false)
{ {
$this->_lockRevision = $pValue; $this->lockRevision = $pValue;
return $this; return $this;
} }
@ -116,7 +116,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function getLockStructure() public function getLockStructure()
{ {
return $this->_lockStructure; return $this->lockStructure;
} }
/** /**
@ -127,7 +127,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function setLockStructure($pValue = false) public function setLockStructure($pValue = false)
{ {
$this->_lockStructure = $pValue; $this->lockStructure = $pValue;
return $this; return $this;
} }
@ -138,7 +138,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function getLockWindows() public function getLockWindows()
{ {
return $this->_lockWindows; return $this->lockWindows;
} }
/** /**
@ -149,7 +149,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function setLockWindows($pValue = false) public function setLockWindows($pValue = false)
{ {
$this->_lockWindows = $pValue; $this->lockWindows = $pValue;
return $this; return $this;
} }
@ -160,7 +160,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function getRevisionsPassword() public function getRevisionsPassword()
{ {
return $this->_revisionsPassword; return $this->revisionsPassword;
} }
/** /**
@ -175,7 +175,7 @@ class PHPExcel_DocumentSecurity
if (!$pAlreadyHashed) { if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue); $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
} }
$this->_revisionsPassword = $pValue; $this->revisionsPassword = $pValue;
return $this; return $this;
} }
@ -186,7 +186,7 @@ class PHPExcel_DocumentSecurity
*/ */
public function getWorkbookPassword() public function getWorkbookPassword()
{ {
return $this->_workbookPassword; return $this->workbookPassword;
} }
/** /**
@ -201,7 +201,7 @@ class PHPExcel_DocumentSecurity
if (!$pAlreadyHashed) { if (!$pAlreadyHashed) {
$pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue); $pValue = PHPExcel_Shared_PasswordHasher::hashPassword($pValue);
} }
$this->_workbookPassword = $pValue; $this->workbookPassword = $pValue;
return $this; return $this;
} }

View File

@ -573,7 +573,8 @@ class PHPExcel_Helper_HTML
protected $richTextObject; protected $richTextObject;
protected function initialise() { protected function initialise()
{
$this->face = $this->size = $this->color = null; $this->face = $this->size = $this->color = null;
$this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false; $this->bold = $this->italic = $this->underline = $this->superscript = $this->subscript = $this->strikethrough = false;
@ -582,7 +583,8 @@ class PHPExcel_Helper_HTML
$this->stringData = ''; $this->stringData = '';
} }
public function toRichTextObject($html) { public function toRichTextObject($html)
{
$this->initialise(); $this->initialise();
// Create a new DOM object // Create a new DOM object
@ -594,15 +596,17 @@ class PHPExcel_Helper_HTML
// Discard excess white space // Discard excess white space
$dom->preserveWhiteSpace = false; $dom->preserveWhiteSpace = false;
$this->richTextObject = new PHPExcel_RichText();; $this->richTextObject = new PHPExcel_RichText();
$this->parseElements($dom); $this->parseElements($dom);
return $this->richTextObject; return $this->richTextObject;
} }
protected function buildTextRun() { protected function buildTextRun()
{
$text = $this->stringData; $text = $this->stringData;
if (trim($text) === '') if (trim($text) === '') {
return; return;
}
$richtextRun = $this->richTextObject->createTextRun($this->stringData); $richtextRun = $this->richTextObject->createTextRun($this->stringData);
if ($this->face) { if ($this->face) {
@ -635,7 +639,8 @@ class PHPExcel_Helper_HTML
$this->stringData = ''; $this->stringData = '';
} }
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);
@ -643,11 +648,13 @@ class PHPExcel_Helper_HTML
return implode($values[0]); return implode($values[0]);
} }
protected function colourNameLookup($rgb) { protected function colourNameLookup($rgb)
{
return self::$colourMap[$rgb]; return self::$colourMap[$rgb];
} }
protected function startFontTag($tag) { protected function startFontTag($tag)
{
foreach ($tag->attributes as $attribute) { foreach ($tag->attributes as $attribute) {
$attributeName = strtolower($attribute->name); $attributeName = strtolower($attribute->name);
$attributeValue = $attribute->value; $attributeValue = $attribute->value;
@ -666,69 +673,85 @@ class PHPExcel_Helper_HTML
} }
} }
protected function endFontTag() { protected function endFontTag()
{
$this->face = $this->size = $this->color = null; $this->face = $this->size = $this->color = null;
} }
protected function startBoldTag() { protected function startBoldTag()
{
$this->bold = true; $this->bold = true;
} }
protected function endBoldTag() { protected function endBoldTag()
{
$this->bold = false; $this->bold = false;
} }
protected function startItalicTag() { protected function startItalicTag()
{
$this->italic = true; $this->italic = true;
} }
protected function endItalicTag() { protected function endItalicTag()
{
$this->italic = false; $this->italic = false;
} }
protected function startUnderlineTag() { protected function startUnderlineTag()
{
$this->underline = true; $this->underline = true;
} }
protected function endUnderlineTag() { protected function endUnderlineTag()
{
$this->underline = false; $this->underline = false;
} }
protected function startSubscriptTag() { protected function startSubscriptTag()
{
$this->subscript = true; $this->subscript = true;
} }
protected function endSubscriptTag() { protected function endSubscriptTag()
{
$this->subscript = false; $this->subscript = false;
} }
protected function startSuperscriptTag() { protected function startSuperscriptTag()
{
$this->superscript = true; $this->superscript = true;
} }
protected function endSuperscriptTag() { protected function endSuperscriptTag()
{
$this->superscript = false; $this->superscript = false;
} }
protected function startStrikethruTag() { protected function startStrikethruTag()
{
$this->strikethrough = true; $this->strikethrough = true;
} }
protected function endStrikethruTag() { protected function endStrikethruTag()
{
$this->strikethrough = false; $this->strikethrough = false;
} }
protected function breakTag() { protected function breakTag()
{
$this->stringData .= PHP_EOL; $this->stringData .= PHP_EOL;
} }
protected function parseTextNode(DOMText $textNode) { protected function parseTextNode(DOMText $textNode)
{
$domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue)); $domText = preg_replace('/\s+/u', ' ', ltrim($textNode->nodeValue));
$this->stringData .= $domText; $this->stringData .= $domText;
$this->buildTextRun(); $this->buildTextRun();
} }
protected function handleCallback($element, $callbackTag, $callbacks) { protected function handleCallback($element, $callbackTag, $callbacks)
{
if (isset($callbacks[$callbackTag])) { if (isset($callbacks[$callbackTag])) {
$elementHandler = $callbacks[$callbackTag]; $elementHandler = $callbacks[$callbackTag];
if (method_exists($this, $elementHandler)) { if (method_exists($this, $elementHandler)) {
@ -737,7 +760,8 @@ class PHPExcel_Helper_HTML
} }
} }
protected function parseElementNode(DOMElement $element) { protected function parseElementNode(DOMElement $element)
{
$callbackTag = strtolower($element->nodeName); $callbackTag = strtolower($element->nodeName);
$this->stack[] = $callbackTag; $this->stack[] = $callbackTag;
@ -750,7 +774,8 @@ class PHPExcel_Helper_HTML
$this->handleCallback($element, $callbackTag, $this->endTagCallbacks); $this->handleCallback($element, $callbackTag, $this->endTagCallbacks);
} }
protected function parseElements(DOMNode $element) { protected function parseElements(DOMNode $element)
{
foreach ($element->childNodes as $child) { foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) { if ($child instanceof DOMText) {
$this->parseTextNode($child); $this->parseTextNode($child);

View File

@ -42,7 +42,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var boolean * @var boolean
*/ */
protected $_readDataOnly = FALSE; protected $_readDataOnly = false;
/** /**
* Read charts that are defined in the workbook? * Read charts that are defined in the workbook?
@ -50,7 +50,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var boolean * @var boolean
*/ */
protected $_includeCharts = FALSE; protected $_includeCharts = false;
/** /**
* Restrict which sheets should be loaded? * Restrict which sheets should be loaded?
@ -58,16 +58,16 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @var array of string * @var array of string
*/ */
protected $_loadSheetsOnly = NULL; protected $_loadSheetsOnly = null;
/** /**
* PHPExcel_Reader_IReadFilter instance * PHPExcel_Reader_IReadFilter instance
* *
* @var PHPExcel_Reader_IReadFilter * @var PHPExcel_Reader_IReadFilter
*/ */
protected $_readFilter = NULL; protected $_readFilter = null;
protected $_fileHandle = NULL; protected $_fileHandle = null;
/** /**
@ -77,7 +77,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return boolean * @return boolean
*/ */
public function getReadDataOnly() { public function getReadDataOnly()
{
return $this->_readDataOnly; return $this->_readDataOnly;
} }
@ -90,7 +91,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setReadDataOnly($pValue = FALSE) { public function setReadDataOnly($pValue = false)
{
$this->_readDataOnly = $pValue; $this->_readDataOnly = $pValue;
return $this; return $this;
} }
@ -103,7 +105,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return boolean * @return boolean
*/ */
public function getIncludeCharts() { public function getIncludeCharts()
{
return $this->_includeCharts; return $this->_includeCharts;
} }
@ -117,7 +120,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setIncludeCharts($pValue = FALSE) { public function setIncludeCharts($pValue = false)
{
$this->_includeCharts = (boolean) $pValue; $this->_includeCharts = (boolean) $pValue;
return $this; return $this;
} }
@ -143,13 +147,13 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setLoadSheetsOnly($value = NULL) public function setLoadSheetsOnly($value = null)
{ {
if ($value === NULL) if ($value === null) {
return $this->setLoadAllSheets(); return $this->setLoadAllSheets();
}
$this->_loadSheetsOnly = is_array($value) ? $this->_loadSheetsOnly = is_array($value) ? $value : array($value);
$value : array($value);
return $this; return $this;
} }
@ -161,7 +165,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
*/ */
public function setLoadAllSheets() public function setLoadAllSheets()
{ {
$this->_loadSheetsOnly = NULL; $this->_loadSheetsOnly = null;
return $this; return $this;
} }
@ -170,7 +174,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* *
* @return PHPExcel_Reader_IReadFilter * @return PHPExcel_Reader_IReadFilter
*/ */
public function getReadFilter() { public function getReadFilter()
{
return $this->_readFilter; return $this->_readFilter;
} }
@ -180,7 +185,8 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
* @param PHPExcel_Reader_IReadFilter $pValue * @param PHPExcel_Reader_IReadFilter $pValue
* @return PHPExcel_Reader_IReader * @return PHPExcel_Reader_IReader
*/ */
public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue) { public function setReadFilter(PHPExcel_Reader_IReadFilter $pValue)
{
$this->_readFilter = $pValue; $this->_readFilter = $pValue;
return $this; return $this;
} }
@ -201,7 +207,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
// Open file // Open file
$this->_fileHandle = fopen($pFilename, 'r'); $this->_fileHandle = fopen($pFilename, 'r');
if ($this->_fileHandle === FALSE) { if ($this->_fileHandle === false) {
throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading."); throw new PHPExcel_Reader_Exception("Could not open file " . $pFilename . " for reading.");
} }
} }
@ -219,7 +225,7 @@ abstract class PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
try { try {
$this->_openFile($pFilename); $this->_openFile($pFilename);
} catch (Exception $e) { } catch (Exception $e) {
return FALSE; return false;
} }
$readable = $this->_isValidFormat(); $readable = $this->_isValidFormat();

View File

@ -62,7 +62,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
/** /**
* Create a new PHPExcel_Reader_Excel2003XML * Create a new PHPExcel_Reader_Excel2003XML
*/ */
public function __construct() { public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter(); $this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
} }
@ -238,8 +239,8 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $this->loadIntoExisting($pFilename, $objPHPExcel); return $this->loadIntoExisting($pFilename, $objPHPExcel);
} }
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)) {
@ -250,13 +251,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return false; return false;
} }
/** /**
* pixel units to excel width units(units of 1/256th of a character width) * pixel units to excel width units(units of 1/256th of a character width)
* @param pxs * @param pxs
* @return * @return
*/ */
protected static function _pixel2WidthUnits($pxs) { protected static function _pixel2WidthUnits($pxs)
{
$UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219); $UNIT_OFFSET_MAP = array(0, 36, 73, 109, 146, 182, 219);
$widthUnits = 256 * ($pxs / 7); $widthUnits = 256 * ($pxs / 7);
@ -264,25 +265,24 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
return $widthUnits; return $widthUnits;
} }
/** /**
* excel width units(units of 1/256th of a character width) to pixel units * excel width units(units of 1/256th of a character width) to pixel units
* @param widthUnits * @param widthUnits
* @return * @return
*/ */
protected static function _widthUnits2Pixel($widthUnits) { protected static function _widthUnits2Pixel($widthUnits)
{
$pixels = ($widthUnits / 256) * 7; $pixels = ($widthUnits / 256) * 7;
$offsetWidthUnits = $widthUnits % 256; $offsetWidthUnits = $widthUnits % 256;
$pixels += round($offsetWidthUnits / (256 / 7)); $pixels += round($offsetWidthUnits / (256 / 7));
return $pixels; return $pixels;
} }
protected static function _hex2str($hex)
protected static function _hex2str($hex) { {
return chr(hexdec($hex[1])); return chr(hexdec($hex[1]));
} }
/** /**
* Loads PHPExcel from file into PHPExcel instance * Loads PHPExcel from file into PHPExcel instance
* *
@ -321,7 +321,6 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$timezoneObj = new DateTimeZone('Europe/London'); $timezoneObj = new DateTimeZone('Europe/London');
$GMT = new DateTimeZone('UTC'); $GMT = new DateTimeZone('UTC');
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!file_exists($pFilename)) {
throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist."); throw new PHPExcel_Reader_Exception("Could not open " . $pFilename . " for reading! File does not exist.");
@ -588,14 +587,13 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
$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'])) {
$columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1); $columnID = PHPExcel_Cell::stringFromColumnIndex($cell_ss['Index']-1);
} }
$cellRange = $columnID.$rowID; $cellRange = $columnID.$rowID;
if ($this->getReadFilter() !== NULL) { if ($this->getReadFilter() !== null) {
if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) { if (!$this->getReadFilter()->readCell($columnID, $rowID, $worksheetName)) {
continue; continue;
} }
@ -700,14 +698,22 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
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;
}
// Bracketed R references are relative to the current row // Bracketed R references are relative to the current row
if ($rowReference{0} == '[') $rowReference = $rowID + trim($rowReference,'[]'); if ($rowReference{0} == '[') {
$rowReference = $rowID + trim($rowReference,'[]');
}
$columnReference = $cellReference[4][0]; $columnReference = $cellReference[4][0];
// Empty C reference is the current column // Empty C reference is the current column
if ($columnReference == '') $columnReference = $columnNumber; if ($columnReference == '') {
$columnReference = $columnNumber;
}
// 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]));
} }
@ -743,9 +749,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// 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))->setText($this->_parseRichText($annotation) );
->setAuthor(self::_convertStringEncoding($author , $this->_charSet))
->setText($this->_parseRichText($annotation) );
} }
if (($cellIsSet) && (isset($cell_ss['StyleID']))) { if (($cellIsSet) && (isset($cell_ss['StyleID']))) {
@ -756,7 +760,7 @@ class PHPExcel_Reader_Excel2003XML extends PHPExcel_Reader_Abstract implements P
// print_r($this->_styles[$style]); // print_r($this->_styles[$style]);
// echo '<br />'; // echo '<br />';
if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) { if (!$objPHPExcel->getActiveSheet()->cellExists($columnID.$rowID)) {
$objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(NULL); $objPHPExcel->getActiveSheet()->getCell($columnID.$rowID)->setValue(null);
} }
$objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]); $objPHPExcel->getActiveSheet()->getStyle($cellRange)->applyFromArray($this->_styles[$style]);
} }
@ -790,7 +794,8 @@ 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);
} }
@ -798,12 +803,12 @@ 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

@ -1,7 +1,15 @@
<?php <?php
if (!defined('PHPEXCEL_ROOT')) {
/** /**
* PHPExcel * @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_HTML
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -26,21 +34,6 @@
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** PHPExcel root directory */ /** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_HTML
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{ {
@ -120,12 +113,12 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
{ {
// Reading 2048 bytes should be enough to validate that the format is HTML // Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->_fileHandle, 2048); $data = fread($this->_fileHandle, 2048);
if ((strpos($data, '<') !== FALSE) && if ((strpos($data, '<') !== false) &&
(strlen($data) !== strlen(strip_tags($data)))) { (strlen($data) !== strlen(strip_tags($data)))) {
return TRUE; return true;
} }
return FALSE; return false;
} }
/** /**
@ -173,8 +166,9 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
protected function _setTableStartColumn($column) protected function _setTableStartColumn($column)
{ {
if ($this->_tableLevel == 0) if ($this->_tableLevel == 0) {
$column = 'A'; $column = 'A';
}
++$this->_tableLevel; ++$this->_tableLevel;
$this->_nestedColumn[$this->_tableLevel] = $column; $this->_nestedColumn[$this->_tableLevel] = $column;
@ -259,11 +253,13 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
case 'strong': case 'strong':
case 'b': case 'b':
// echo 'STYLING, SPAN OR DIV<br />'; // echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '') if ($cellContent > '') {
$cellContent .= ' '; $cellContent .= ' ';
}
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '') if ($cellContent > '') {
$cellContent .= ' '; $cellContent .= ' ';
}
// echo 'END OF STYLING, SPAN OR DIV<br />'; // echo 'END OF STYLING, SPAN OR DIV<br />';
break; break;
case 'hr': case 'hr':
@ -360,8 +356,9 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$this->_flushCell($sheet, $column, $row, $cellContent); $this->_flushCell($sheet, $column, $row, $cellContent);
$column = $this->_setTableStartColumn($column); $column = $this->_setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />'; // echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
if ($this->_tableLevel > 1) if ($this->_tableLevel > 1) {
--$row; --$row;
}
$this->_processDomElement($child, $sheet, $row, $column, $cellContent); $this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />'; // echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
$column = $this->_releaseTableStartColumn(); $column = $this->_releaseTableStartColumn();
@ -476,7 +473,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
$dom = new domDocument; $dom = new domDocument;
// Reload the HTML file into the DOM object // Reload the HTML file into the DOM object
$loaded = $dom->loadHTML($this->securityScanFile($pFilename)); $loaded = $dom->loadHTML($this->securityScanFile($pFilename));
if ($loaded === FALSE) { if ($loaded === false) {
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document'); throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
} }
@ -529,6 +526,4 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
} }
return $xml; return $xml;
} }
} }

View File

@ -436,9 +436,7 @@ class PHPExcel_ReferenceHelper
$newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows); $newCoordinates = PHPExcel_Cell::stringFromColumnIndex($cellIndex-1 + $pNumCols) . ($cell->getRow() + $pNumRows);
// Should the cell be updated? Move value and cellXf index from one cell to another. // Should the cell be updated? Move value and cellXf index from one cell to another.
if (($cellIndex >= $beforeColumnIndex) && if (($cellIndex >= $beforeColumnIndex) && ($cell->getRow() >= $beforeRow)) {
($cell->getRow() >= $beforeRow)) {
// Update cell styles // Update cell styles
$pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex()); $pSheet->getCell($newCoordinates)->setXfIndex($cell->getXfIndex());
@ -471,7 +469,6 @@ class PHPExcel_ReferenceHelper
if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) { if ($pNumCols > 0 && $beforeColumnIndex - 2 > 0) {
for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) { for ($i = $beforeRow; $i <= $highestRow - 1; ++$i) {
// Style // Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($beforeColumnIndex - 2) . $i; $coordinate = PHPExcel_Cell::stringFromColumnIndex($beforeColumnIndex - 2) . $i;
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {
@ -495,7 +492,6 @@ class PHPExcel_ReferenceHelper
if ($pNumRows > 0 && $beforeRow - 1 > 0) { if ($pNumRows > 0 && $beforeRow - 1 > 0) {
for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) { for ($i = $beforeColumnIndex - 1; $i <= PHPExcel_Cell::columnIndexFromString($highestColumn) - 1; ++$i) {
// Style // Style
$coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1); $coordinate = PHPExcel_Cell::stringFromColumnIndex($i) . ($beforeRow - 1);
if ($pSheet->cellExists($coordinate)) { if ($pSheet->cellExists($coordinate)) {

View File

@ -38,58 +38,155 @@ class PHPExcel_Shared_CodePage
public static function NumberToName($codePage = 1252) public static function NumberToName($codePage = 1252)
{ {
switch ($codePage) { switch ($codePage) {
case 367: return 'ASCII'; break; // ASCII case 367:
case 437: return 'CP437'; break; // OEM US return 'ASCII';
case 720: throw new PHPExcel_Exception('Code page 720 not supported.'); break; // ASCII
case 437:
return 'CP437';
break; // OEM US
case 720:
throw new PHPExcel_Exception('Code page 720 not supported.');
break; // OEM Arabic break; // OEM Arabic
case 737: return 'CP737'; break; // OEM Greek case 737:
case 775: return 'CP775'; break; // OEM Baltic return 'CP737';
case 850: return 'CP850'; break; // OEM Latin I break; // OEM Greek
case 852: return 'CP852'; break; // OEM Latin II (Central European) case 775:
case 855: return 'CP855'; break; // OEM Cyrillic return 'CP775';
case 857: return 'CP857'; break; // OEM Turkish break; // OEM Baltic
case 858: return 'CP858'; break; // OEM Multilingual Latin I with Euro case 850:
case 860: return 'CP860'; break; // OEM Portugese return 'CP850';
case 861: return 'CP861'; break; // OEM Icelandic break; // OEM Latin I
case 862: return 'CP862'; break; // OEM Hebrew case 852:
case 863: return 'CP863'; break; // OEM Canadian (French) return 'CP852';
case 864: return 'CP864'; break; // OEM Arabic break; // OEM Latin II (Central European)
case 865: return 'CP865'; break; // OEM Nordic case 855:
case 866: return 'CP866'; break; // OEM Cyrillic (Russian) return 'CP855';
case 869: return 'CP869'; break; // OEM Greek (Modern) break; // OEM Cyrillic
case 874: return 'CP874'; break; // ANSI Thai case 857:
case 932: return 'CP932'; break; // ANSI Japanese Shift-JIS return 'CP857';
case 936: return 'CP936'; break; // ANSI Chinese Simplified GBK break; // OEM Turkish
case 949: return 'CP949'; break; // ANSI Korean (Wansung) case 858:
case 950: return 'CP950'; break; // ANSI Chinese Traditional BIG5 return 'CP858';
case 1200: return 'UTF-16LE'; break; // UTF-16 (BIFF8) break; // OEM Multilingual Latin I with Euro
case 1250: return 'CP1250'; break; // ANSI Latin II (Central European) case 860:
case 1251: return 'CP1251'; break; // ANSI Cyrillic return 'CP860';
case 0: // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program break; // OEM Portugese
case 1252: return 'CP1252'; break; // ANSI Latin I (BIFF4-BIFF7) case 861:
case 1253: return 'CP1253'; break; // ANSI Greek return 'CP861';
case 1254: return 'CP1254'; break; // ANSI Turkish break; // OEM Icelandic
case 1255: return 'CP1255'; break; // ANSI Hebrew case 862:
case 1256: return 'CP1256'; break; // ANSI Arabic return 'CP862';
case 1257: return 'CP1257'; break; // ANSI Baltic break; // OEM Hebrew
case 1258: return 'CP1258'; break; // ANSI Vietnamese case 863:
case 1361: return 'CP1361'; break; // ANSI Korean (Johab) return 'CP863';
case 10000: return 'MAC'; break; // Apple Roman break; // OEM Canadian (French)
case 10001: return 'CP932'; break; // Macintosh Japanese case 864:
case 10002: return 'CP950'; break; // Macintosh Chinese Traditional return 'CP864';
case 10003: return 'CP1361'; break; // Macintosh Korean break; // OEM Arabic
case 10006: return 'MACGREEK'; break; // Macintosh Greek case 865:
case 10007: return 'MACCYRILLIC'; break; // Macintosh Cyrillic return 'CP865';
case 10008: return 'CP936'; break; // Macintosh - Simplified Chinese (GB 2312) break; // OEM Nordic
case 10029: return 'MACCENTRALEUROPE'; break; // Macintosh Central Europe case 866:
case 10079: return 'MACICELAND'; break; // Macintosh Icelandic return 'CP866';
case 10081: return 'MACTURKISH'; break; // Macintosh Turkish break; // OEM Cyrillic (Russian)
case 21010: return 'UTF-16LE'; break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE case 869:
case 32768: return 'MAC'; break; // Apple Roman return 'CP869';
case 32769: throw new PHPExcel_Exception('Code page 32769 not supported.'); break; // OEM Greek (Modern)
case 874:
return 'CP874';
break; // ANSI Thai
case 932:
return 'CP932';
break; // ANSI Japanese Shift-JIS
case 936:
return 'CP936';
break; // ANSI Chinese Simplified GBK
case 949:
return 'CP949';
break; // ANSI Korean (Wansung)
case 950:
return 'CP950';
break; // ANSI Chinese Traditional BIG5
case 1200:
return 'UTF-16LE';
break; // UTF-16 (BIFF8)
case 1250:
return 'CP1250';
break; // ANSI Latin II (Central European)
case 1251:
return 'CP1251';
break; // ANSI Cyrillic
case 0:
// CodePage is not always correctly set when the xls file was saved by Apple's Numbers program
case 1252:
return 'CP1252';
break; // ANSI Latin I (BIFF4-BIFF7)
case 1253:
return 'CP1253';
break; // ANSI Greek
case 1254:
return 'CP1254';
break; // ANSI Turkish
case 1255:
return 'CP1255';
break; // ANSI Hebrew
case 1256:
return 'CP1256';
break; // ANSI Arabic
case 1257:
return 'CP1257';
break; // ANSI Baltic
case 1258:
return 'CP1258';
break; // ANSI Vietnamese
case 1361:
return 'CP1361';
break; // ANSI Korean (Johab)
case 10000:
return 'MAC';
break; // Apple Roman
case 10001:
return 'CP932';
break; // Macintosh Japanese
case 10002:
return 'CP950';
break; // Macintosh Chinese Traditional
case 10003:
return 'CP1361';
break; // Macintosh Korean
case 10006:
return 'MACGREEK';
break; // Macintosh Greek
case 10007:
return 'MACCYRILLIC';
break; // Macintosh Cyrillic
case 10008:
return 'CP936';
break; // Macintosh - Simplified Chinese (GB 2312)
case 10029:
return 'MACCENTRALEUROPE';
break; // Macintosh Central Europe
case 10079:
return 'MACICELAND';
break; // Macintosh Icelandic
case 10081:
return 'MACTURKISH';
break; // Macintosh Turkish
case 21010:
return 'UTF-16LE';
break; // UTF-16 (BIFF8) This isn't correct, but some Excel writer libraries erroneously use Codepage 21010 for UTF-16LE
case 32768:
return 'MAC';
break; // Apple Roman
case 32769:
throw new PHPExcel_Exception('Code page 32769 not supported.');
break; // ANSI Latin I (BIFF2-BIFF3) break; // ANSI Latin I (BIFF2-BIFF3)
case 65000: return 'UTF-7'; break; // Unicode (UTF-7) case 65000:
case 65001: return 'UTF-8'; break; // Unicode (UTF-8) return 'UTF-7';
break; // Unicode (UTF-7)
case 65001:
return 'UTF-8';
break; // Unicode (UTF-8)
} }
throw new PHPExcel_Exception('Unknown codepage: ' . $codePage); throw new PHPExcel_Exception('Unknown codepage: ' . $codePage);
} }

View File

@ -184,13 +184,9 @@ class PHPExcel_Shared_Date
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$retValue = false; $retValue = false;
if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) { if ((is_object($dateValue)) && ($dateValue instanceof DateTime)) {
$retValue = self::FormattedPHPToExcel( $dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $retValue = self::FormattedPHPToExcel($dateValue->format('Y'), $dateValue->format('m'), $dateValue->format('d'), $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);
@ -283,12 +279,15 @@ class PHPExcel_Shared_Date
*/ */
public static function isDateTimeFormatCode($pFormatCode = '') public static function isDateTimeFormatCode($pFormatCode = '')
{ {
if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) {
// "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check) // "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check)
return false; return false;
if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) }
if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) {
// Scientific format // Scientific format
return false; return false;
}
// Switch on formatcode // Switch on formatcode
switch ($pFormatCode) { switch ($pFormatCode) {
// Explicitly defined date formats // Explicitly defined date formats
@ -352,10 +351,12 @@ class PHPExcel_Shared_Date
*/ */
public static function stringToExcel($dateValue = '') public static function stringToExcel($dateValue = '')
{ {
if (strlen($dateValue) < 2) if (strlen($dateValue) < 2) {
return false; return false;
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) }
if (!preg_match('/^(\d{1,4}[ \.\/\-][A-Z]{3,9}([ \.\/\-]\d{1,4})?|[A-Z]{3,9}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?|\d{1,4}[ \.\/\-]\d{1,4}([ \.\/\-]\d{1,4})?)( \d{1,2}:\d{1,2}(:\d{1,2})?)?$/iu', $dateValue)) {
return false; return false;
}
$dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue); $dateValueNew = PHPExcel_Calculation_DateTime::DATEVALUE($dateValue);

View File

@ -79,5 +79,4 @@ class PHPExcel_Shared_Escher_DgContainer
{ {
return $this->_spgrContainer = $spgrContainer; return $this->_spgrContainer = $spgrContainer;
} }
} }

View File

@ -61,5 +61,4 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer
{ {
return $this->_BSECollection; return $this->_BSECollection;
} }
} }

View File

@ -116,5 +116,4 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE
{ {
$this->_blipType = $blipType; $this->_blipType = $blipType;
} }
} }

View File

@ -87,5 +87,4 @@ class PHPExcel_Shared_Escher_DggContainer_BstoreContainer_BSE_Blip
{ {
return $this->_parent; return $this->_parent;
} }
} }

View File

@ -52,21 +52,16 @@ class PHPExcel_Shared_Excel5
// first find the true column width in pixels (uncollapsed and unhidden) // first find the true column width in pixels (uncollapsed and unhidden)
if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) { if (isset($columnDimensions[$col]) and $columnDimensions[$col]->getWidth() != -1) {
// then we have column dimension with explicit width // then we have column dimension with explicit width
$columnDimension = $columnDimensions[$col]; $columnDimension = $columnDimensions[$col];
$width = $columnDimension->getWidth(); $width = $columnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font); $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
} else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) { } else if ($sheet->getDefaultColumnDimension()->getWidth() != -1) {
// then we have default column dimension with explicit width // then we have default column dimension with explicit width
$defaultColumnDimension = $sheet->getDefaultColumnDimension(); $defaultColumnDimension = $sheet->getDefaultColumnDimension();
$width = $defaultColumnDimension->getWidth(); $width = $defaultColumnDimension->getWidth();
$pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font); $pixelWidth = PHPExcel_Shared_Drawing::cellDimensionToPixels($width, $font);
} else { } else {
// we don't even have any default column dimension. Width depends on default font // we don't even have any default column dimension. Width depends on default font
$pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true); $pixelWidth = PHPExcel_Shared_Font::getDefaultColumnWidthByFont($font, true);
} }
@ -99,25 +94,19 @@ class PHPExcel_Shared_Excel5
// first find the true row height in pixels (uncollapsed and unhidden) // first find the true row height in pixels (uncollapsed and unhidden)
if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) { if (isset($rowDimensions[$row]) and $rowDimensions[$row]->getRowHeight() != -1) {
// then we have a row dimension // then we have a row dimension
$rowDimension = $rowDimensions[$row]; $rowDimension = $rowDimensions[$row];
$rowHeight = $rowDimension->getRowHeight(); $rowHeight = $rowDimension->getRowHeight();
$pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10 $pixelRowHeight = (int) ceil(4 * $rowHeight / 3); // here we assume Arial 10
} else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) { } else if ($sheet->getDefaultRowDimension()->getRowHeight() != -1) {
// then we have a default row dimension with explicit height // then we have a default row dimension with explicit height
$defaultRowDimension = $sheet->getDefaultRowDimension(); $defaultRowDimension = $sheet->getDefaultRowDimension();
$rowHeight = $defaultRowDimension->getRowHeight(); $rowHeight = $defaultRowDimension->getRowHeight();
$pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight); $pixelRowHeight = PHPExcel_Shared_Drawing::pointsToPixels($rowHeight);
} else { } else {
// we don't even have any default row dimension. Height depends on default font // we don't even have any default row dimension. Height depends on default font
$pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font); $pointRowHeight = PHPExcel_Shared_Font::getDefaultRowHeightByFont($font);
$pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight); $pixelRowHeight = PHPExcel_Shared_Font::fontSizeToPixels($pointRowHeight);
} }
// now find the effective row height in pixels // now find the effective row height in pixels
@ -313,5 +302,4 @@ class PHPExcel_Shared_Excel5
return $twoAnchor; return $twoAnchor;
} }
} }

View File

@ -197,11 +197,11 @@ class PHPExcel_Shared_Font
public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX) public static function setAutoSizeMethod($pValue = self::AUTOSIZE_METHOD_APPROX)
{ {
if (!in_array($pValue, self::$_autoSizeMethods)) { if (!in_array($pValue, self::$_autoSizeMethods)) {
return FALSE; return false;
} }
self::$autoSizeMethod = $pValue; self::$autoSizeMethod = $pValue;
return TRUE; return true;
} }
/** /**
@ -249,7 +249,8 @@ class PHPExcel_Shared_Font
* @param PHPExcel_Style_Font|NULL $defaultFont Font object * @param PHPExcel_Style_Font|NULL $defaultFont Font object
* @return integer Column width * @return integer Column width
*/ */
public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null) { public static function calculateColumnWidth(PHPExcel_Style_Font $font, $cellText = '', $rotation = 0, PHPExcel_Style_Font $defaultFont = null)
{
// If it is rich text, use plain text // If it is rich text, use plain text
if ($cellText instanceof PHPExcel_RichText) { if ($cellText instanceof PHPExcel_RichText) {
$cellText = $cellText->getPlainText(); $cellText = $cellText->getPlainText();
@ -301,7 +302,8 @@ class PHPExcel_Shared_Font
* @return int * @return int
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0) { public static function getTextWidthPixelsExact($text, PHPExcel_Style_Font $font, $rotation = 0)
{
if (!function_exists('imagettfbbox')) { if (!function_exists('imagettfbbox')) {
throw new PHPExcel_Exception('GD library needs to be enabled'); throw new PHPExcel_Exception('GD library needs to be enabled');
} }
@ -391,7 +393,8 @@ class PHPExcel_Shared_Font
* @param int $fontSizeInPoints Font size (in points) * @param int $fontSizeInPoints Font size (in points)
* @return int Font size (in pixels) * @return int Font size (in pixels)
*/ */
public static function fontSizeToPixels($fontSizeInPoints = 11) { public static function fontSizeToPixels($fontSizeInPoints = 11)
{
return (int) ((4 / 3) * $fontSizeInPoints); return (int) ((4 / 3) * $fontSizeInPoints);
} }
@ -401,7 +404,8 @@ class PHPExcel_Shared_Font
* @param int $sizeInInch Font size (in inch) * @param int $sizeInInch Font size (in inch)
* @return int Size (in pixels) * @return int Size (in pixels)
*/ */
public static function inchSizeToPixels($sizeInInch = 1) { public static function inchSizeToPixels($sizeInInch = 1)
{
return ($sizeInInch * 96); return ($sizeInInch * 96);
} }
@ -411,7 +415,8 @@ class PHPExcel_Shared_Font
* @param int $sizeInCm Font size (in centimeters) * @param int $sizeInCm Font size (in centimeters)
* @return int Size (in pixels) * @return int Size (in pixels)
*/ */
public static function centimeterSizeToPixels($sizeInCm = 1) { public static function centimeterSizeToPixels($sizeInCm = 1)
{
return ($sizeInCm * 37.795275591); return ($sizeInCm * 37.795275591);
} }
@ -421,7 +426,8 @@ class PHPExcel_Shared_Font
* @param PHPExcel_Style_Font * @param PHPExcel_Style_Font
* @return string Path to TrueType font file * @return string Path to TrueType font file
*/ */
public static function getTrueTypeFontFileFromFont($font) { public static function getTrueTypeFontFileFromFont($font)
{
if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) { if (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath)) {
throw new PHPExcel_Exception('Valid directory to TrueType Font files not specified'); throw new PHPExcel_Exception('Valid directory to TrueType Font files not specified');
} }
@ -438,95 +444,79 @@ class PHPExcel_Shared_Font
: ($italic ? self::ARIAL_ITALIC : self::ARIAL) : ($italic ? self::ARIAL_ITALIC : self::ARIAL)
); );
break; break;
case 'Calibri': case 'Calibri':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD) $bold ? ($italic ? self::CALIBRI_BOLD_ITALIC : self::CALIBRI_BOLD)
: ($italic ? self::CALIBRI_ITALIC : self::CALIBRI) : ($italic ? self::CALIBRI_ITALIC : self::CALIBRI)
); );
break; break;
case 'Courier New': case 'Courier New':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD) $bold ? ($italic ? self::COURIER_NEW_BOLD_ITALIC : self::COURIER_NEW_BOLD)
: ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW) : ($italic ? self::COURIER_NEW_ITALIC : self::COURIER_NEW)
); );
break; break;
case 'Comic Sans MS': case 'Comic Sans MS':
$fontFile = ( $fontFile = (
$bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS $bold ? self::COMIC_SANS_MS_BOLD : self::COMIC_SANS_MS
); );
break; break;
case 'Georgia': case 'Georgia':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD) $bold ? ($italic ? self::GEORGIA_BOLD_ITALIC : self::GEORGIA_BOLD)
: ($italic ? self::GEORGIA_ITALIC : self::GEORGIA) : ($italic ? self::GEORGIA_ITALIC : self::GEORGIA)
); );
break; break;
case 'Impact': case 'Impact':
$fontFile = self::IMPACT; $fontFile = self::IMPACT;
break; break;
case 'Liberation Sans': case 'Liberation Sans':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD) $bold ? ($italic ? self::LIBERATION_SANS_BOLD_ITALIC : self::LIBERATION_SANS_BOLD)
: ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS) : ($italic ? self::LIBERATION_SANS_ITALIC : self::LIBERATION_SANS)
); );
break; break;
case 'Lucida Console': case 'Lucida Console':
$fontFile = self::LUCIDA_CONSOLE; $fontFile = self::LUCIDA_CONSOLE;
break; break;
case 'Lucida Sans Unicode': case 'Lucida Sans Unicode':
$fontFile = self::LUCIDA_SANS_UNICODE; $fontFile = self::LUCIDA_SANS_UNICODE;
break; break;
case 'Microsoft Sans Serif': case 'Microsoft Sans Serif':
$fontFile = self::MICROSOFT_SANS_SERIF; $fontFile = self::MICROSOFT_SANS_SERIF;
break; break;
case 'Palatino Linotype': case 'Palatino Linotype':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD) $bold ? ($italic ? self::PALATINO_LINOTYPE_BOLD_ITALIC : self::PALATINO_LINOTYPE_BOLD)
: ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE) : ($italic ? self::PALATINO_LINOTYPE_ITALIC : self::PALATINO_LINOTYPE)
); );
break; break;
case 'Symbol': case 'Symbol':
$fontFile = self::SYMBOL; $fontFile = self::SYMBOL;
break; break;
case 'Tahoma': case 'Tahoma':
$fontFile = ( $fontFile = (
$bold ? self::TAHOMA_BOLD : self::TAHOMA $bold ? self::TAHOMA_BOLD : self::TAHOMA
); );
break; break;
case 'Times New Roman': case 'Times New Roman':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD) $bold ? ($italic ? self::TIMES_NEW_ROMAN_BOLD_ITALIC : self::TIMES_NEW_ROMAN_BOLD)
: ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN) : ($italic ? self::TIMES_NEW_ROMAN_ITALIC : self::TIMES_NEW_ROMAN)
); );
break; break;
case 'Trebuchet MS': case 'Trebuchet MS':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD) $bold ? ($italic ? self::TREBUCHET_MS_BOLD_ITALIC : self::TREBUCHET_MS_BOLD)
: ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS) : ($italic ? self::TREBUCHET_MS_ITALIC : self::TREBUCHET_MS)
); );
break; break;
case 'Verdana': case 'Verdana':
$fontFile = ( $fontFile = (
$bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD) $bold ? ($italic ? self::VERDANA_BOLD_ITALIC : self::VERDANA_BOLD)
: ($italic ? self::VERDANA_ITALIC : self::VERDANA) : ($italic ? self::VERDANA_ITALIC : self::VERDANA)
); );
break; break;
default: default:
throw new PHPExcel_Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file'); throw new PHPExcel_Exception('Unknown font name "'. $name .'". Cannot map to TrueType font file');
break; break;
@ -536,7 +526,7 @@ class PHPExcel_Shared_Font
// Check if file actually exists // Check if file actually exists
if (!file_exists($fontFile)) { if (!file_exists($fontFile)) {
throw New PHPExcel_Exception('TrueType Font file not found'); throw new PHPExcel_Exception('TrueType Font file not found');
} }
return $fontFile; return $fontFile;
@ -552,11 +542,16 @@ class PHPExcel_Shared_Font
{ {
switch ($name) { switch ($name) {
// Add more cases. Check FONT records in real Excel files. // Add more cases. Check FONT records in real Excel files.
case 'EucrosiaUPC': return self::CHARSET_ANSI_THAI; case 'EucrosiaUPC':
case 'Wingdings': return self::CHARSET_SYMBOL; return self::CHARSET_ANSI_THAI;
case 'Wingdings 2': return self::CHARSET_SYMBOL; case 'Wingdings':
case 'Wingdings 3': return self::CHARSET_SYMBOL; return self::CHARSET_SYMBOL;
default: return self::CHARSET_ANSI_LATIN; case 'Wingdings 2':
return self::CHARSET_SYMBOL;
case 'Wingdings 3':
return self::CHARSET_SYMBOL;
default:
return self::CHARSET_ANSI_LATIN;
} }
} }
@ -609,44 +604,36 @@ class PHPExcel_Shared_Font
// inspection of Arial 10 workbook says 12.75pt ~17px // inspection of Arial 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Arial 9 workbook says 12.00pt ~16px // inspection of Arial 9 workbook says 12.00pt ~16px
$rowHeight = 12; $rowHeight = 12;
break; break;
case 8: case 8:
// inspection of Arial 8 workbook says 11.25pt ~15px // inspection of Arial 8 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 7: case 7:
// inspection of Arial 7 workbook says 9.00pt ~12px // inspection of Arial 7 workbook says 9.00pt ~12px
$rowHeight = 9; $rowHeight = 9;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Arial 5,6 workbook says 8.25pt ~11px // inspection of Arial 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Arial 4 workbook says 6.75pt ~9px // inspection of Arial 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Arial 3 workbook says 6.00pt ~8px // inspection of Arial 3 workbook says 6.00pt ~8px
$rowHeight = 6; $rowHeight = 6;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Arial 1,2 workbook says 5.25pt ~7px // inspection of Arial 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Arial 10 workbook as an approximation, extrapolation // use Arial 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10; $rowHeight = 12.75 * $font->getSize() / 10;
@ -660,49 +647,40 @@ class PHPExcel_Shared_Font
// inspection of Calibri 11 workbook says 15.00pt ~20px // inspection of Calibri 11 workbook says 15.00pt ~20px
$rowHeight = 15; $rowHeight = 15;
break; break;
case 10: case 10:
// inspection of Calibri 10 workbook says 12.75pt ~17px // inspection of Calibri 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Calibri 9 workbook says 12.00pt ~16px // inspection of Calibri 9 workbook says 12.00pt ~16px
$rowHeight = 12; $rowHeight = 12;
break; break;
case 8: case 8:
// inspection of Calibri 8 workbook says 11.25pt ~15px // inspection of Calibri 8 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 7: case 7:
// inspection of Calibri 7 workbook says 9.00pt ~12px // inspection of Calibri 7 workbook says 9.00pt ~12px
$rowHeight = 9; $rowHeight = 9;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Calibri 5,6 workbook says 8.25pt ~11px // inspection of Calibri 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Calibri 4 workbook says 6.75pt ~9px // inspection of Calibri 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Calibri 3 workbook says 6.00pt ~8px // inspection of Calibri 3 workbook says 6.00pt ~8px
$rowHeight = 6.00; $rowHeight = 6.00;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Calibri 1,2 workbook says 5.25pt ~7px // inspection of Calibri 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Calibri 11 workbook as an approximation, extrapolation // use Calibri 11 workbook as an approximation, extrapolation
$rowHeight = 15 * $font->getSize() / 11; $rowHeight = 15 * $font->getSize() / 11;
@ -716,51 +694,42 @@ class PHPExcel_Shared_Font
// inspection of Verdana 10 workbook says 12.75pt ~17px // inspection of Verdana 10 workbook says 12.75pt ~17px
$rowHeight = 12.75; $rowHeight = 12.75;
break; break;
case 9: case 9:
// inspection of Verdana 9 workbook says 11.25pt ~15px // inspection of Verdana 9 workbook says 11.25pt ~15px
$rowHeight = 11.25; $rowHeight = 11.25;
break; break;
case 8: case 8:
// inspection of Verdana 8 workbook says 10.50pt ~14px // inspection of Verdana 8 workbook says 10.50pt ~14px
$rowHeight = 10.50; $rowHeight = 10.50;
break; break;
case 7: case 7:
// inspection of Verdana 7 workbook says 9.00pt ~12px // inspection of Verdana 7 workbook says 9.00pt ~12px
$rowHeight = 9.00; $rowHeight = 9.00;
break; break;
case 6: case 6:
case 5: case 5:
// inspection of Verdana 5,6 workbook says 8.25pt ~11px // inspection of Verdana 5,6 workbook says 8.25pt ~11px
$rowHeight = 8.25; $rowHeight = 8.25;
break; break;
case 4: case 4:
// inspection of Verdana 4 workbook says 6.75pt ~9px // inspection of Verdana 4 workbook says 6.75pt ~9px
$rowHeight = 6.75; $rowHeight = 6.75;
break; break;
case 3: case 3:
// inspection of Verdana 3 workbook says 6.00pt ~8px // inspection of Verdana 3 workbook says 6.00pt ~8px
$rowHeight = 6; $rowHeight = 6;
break; break;
case 2: case 2:
case 1: case 1:
// inspection of Verdana 1,2 workbook says 5.25pt ~7px // inspection of Verdana 1,2 workbook says 5.25pt ~7px
$rowHeight = 5.25; $rowHeight = 5.25;
break; break;
default: default:
// use Verdana 10 workbook as an approximation, extrapolation // use Verdana 10 workbook as an approximation, extrapolation
$rowHeight = 12.75 * $font->getSize() / 10; $rowHeight = 12.75 * $font->getSize() / 10;
break; break;
} }
break; break;
default: default:
// just use Calibri as an approximation // just use Calibri as an approximation
$rowHeight = 15 * $font->getSize() / 11; $rowHeight = 15 * $font->getSize() / 11;
@ -769,5 +738,4 @@ class PHPExcel_Shared_Font
return $rowHeight; return $rowHeight;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** /**
* PHPExcel * PHPExcel_Shared_OLE_ChainedBlockStream
* *
* Copyright (c) 2006 - 2015 PHPExcel * Copyright (c) 2006 - 2015 PHPExcel
* *
@ -24,17 +25,6 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/**
* PHPExcel_Shared_OLE_ChainedBlockStream
*
* Stream wrapper for reading data stored in an OLE file. Implements methods
* for PHP's stream_wrapper_register(). For creating streams using this
* wrapper, use PHPExcel_Shared_OLE_PPS_File::getStream().
*
* @category PHPExcel
* @package PHPExcel_Shared_OLE
*/
class PHPExcel_Shared_OLE_ChainedBlockStream class PHPExcel_Shared_OLE_ChainedBlockStream
{ {
/** /**
@ -83,10 +73,7 @@ class PHPExcel_Shared_OLE_ChainedBlockStream
// 25 is length of "ole-chainedblockstream://" // 25 is length of "ole-chainedblockstream://"
parse_str(substr($path, 25), $this->params); parse_str(substr($path, 25), $this->params);
if (!isset($this->params['oleInstanceId'], if (!isset($this->params['oleInstanceId'], $this->params['blockId'], $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
$this->params['blockId'],
$GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
if ($options & STREAM_REPORT_ERRORS) { if ($options & STREAM_REPORT_ERRORS) {
trigger_error('OLE stream not found', E_USER_WARNING); trigger_error('OLE stream not found', E_USER_WARNING);
} }
@ -96,10 +83,7 @@ class PHPExcel_Shared_OLE_ChainedBlockStream
$blockId = $this->params['blockId']; $blockId = $this->params['blockId'];
$this->data = ''; $this->data = '';
if (isset($this->params['size']) && if (isset($this->params['size']) && $this->params['size'] < $this->ole->bigBlockThreshold && $blockId != $this->ole->root->_StartBlock) {
$this->params['size'] < $this->ole->bigBlockThreshold &&
$blockId != $this->ole->root->_StartBlock) {
// Block id refers to small blocks // Block id refers to small blocks
$rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock); $rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
while ($blockId != -2) { while ($blockId != -2) {

View File

@ -38,17 +38,7 @@ class PHPExcel_Shared_OLE_PPS_File extends PHPExcel_Shared_OLE_PPS
*/ */
public function __construct($name) public function __construct($name)
{ {
parent::__construct( parent::__construct(null, $name, PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE, null, null, null, null, null, '', array());
null,
$name,
PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE,
null,
null,
null,
null,
null,
'',
array());
} }
/** /**

View File

@ -34,7 +34,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
* Directory for temporary files * Directory for temporary files
* @var string * @var string
*/ */
protected $_tmp_dir = NULL; protected $_tmp_dir = null;
/** /**
* @param integer $time_1st A timestamp * @param integer $time_1st A timestamp
@ -44,17 +44,7 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
{ {
$this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir(); $this->_tempDir = PHPExcel_Shared_File::sys_get_temp_dir();
parent::__construct( parent::__construct(null, PHPExcel_Shared_OLE::Asc2Ucs('Root Entry'), PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild);
null,
PHPExcel_Shared_OLE::Asc2Ucs('Root Entry'),
PHPExcel_Shared_OLE::OLE_PPS_TYPE_ROOT,
null,
null,
null,
$time_1st,
$time_2nd,
null,
$raChild);
} }
/** /**
@ -71,15 +61,19 @@ class PHPExcel_Shared_OLE_PPS_Root extends PHPExcel_Shared_OLE_PPS
public function save($filename) public function save($filename)
{ {
// Initial Setting for saving // Initial Setting for saving
$this->_BIG_BLOCK_SIZE = pow(2, $this->_BIG_BLOCK_SIZE = pow(
((isset($this->_BIG_BLOCK_SIZE))? self::_adjust2($this->_BIG_BLOCK_SIZE) : 9)); 2,
$this->_SMALL_BLOCK_SIZE= pow(2, (isset($this->_BIG_BLOCK_SIZE))? self::_adjust2($this->_BIG_BLOCK_SIZE) : 9
((isset($this->_SMALL_BLOCK_SIZE))? self::_adjust2($this->_SMALL_BLOCK_SIZE): 6)); );
$this->_SMALL_BLOCK_SIZE= pow(
2,
(isset($this->_SMALL_BLOCK_SIZE))? self::_adjust2($this->_SMALL_BLOCK_SIZE) : 6
);
if (is_resource($filename)) { if (is_resource($filename)) {
$this->_FILEH_ = $filename; $this->_FILEH_ = $filename;
} else if ($filename == '-' || $filename == '') { } else if ($filename == '-' || $filename == '') {
if ($this->_tmp_dir === NULL) if ($this->_tmp_dir === null)
$this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir(); $this->_tmp_dir = PHPExcel_Shared_File::sys_get_temp_dir();
$this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root"); $this->_tmp_filename = tempnam($this->_tmp_dir, "OLE_PPS_Root");
$this->_FILEH_ = fopen($this->_tmp_filename,"w+b"); $this->_FILEH_ = fopen($this->_tmp_filename,"w+b");

View File

@ -82,7 +82,7 @@ class PHPExcel_Shared_OLERead {
// Get the file identifier // Get the file identifier
// Don't bother reading the whole file until we know it's a valid OLE file // Don't bother reading the whole file until we know it's a valid OLE file
$this->data = file_get_contents($sFileName, FALSE, NULL, 0, 8); $this->data = file_get_contents($sFileName, false, null, 0, 8);
// Check OLE identifier // Check OLE identifier
if ($this->data != self::IDENTIFIER_OLE) { if ($this->data != self::IDENTIFIER_OLE) {
@ -172,7 +172,7 @@ class PHPExcel_Shared_OLERead {
*/ */
public function getStream($stream) public function getStream($stream)
{ {
if ($stream === NULL) { if ($stream === null) {
return null; return null;
} }
@ -197,7 +197,9 @@ class PHPExcel_Shared_OLERead {
++$numBlocks; ++$numBlocks;
} }
if ($numBlocks == 0) return ''; if ($numBlocks == 0) {
return '';
}
$block = $this->props[$stream]['startBlock']; $block = $this->props[$stream]['startBlock'];
@ -233,7 +235,8 @@ class PHPExcel_Shared_OLERead {
/** /**
* Read entries in the directory stream. * Read entries in the directory stream.
*/ */
private function _readPropertySets() { private function _readPropertySets()
{
$offset = 0; $offset = 0;
// loop through entires, each entry is 128 bytes // loop through entires, each entry is 128 bytes
@ -256,12 +259,12 @@ class PHPExcel_Shared_OLERead {
$name = str_replace("\x00", "", substr($d, 0, $nameSize)); $name = str_replace("\x00", "", substr($d, 0, $nameSize));
$this->props[] = array( $this->props[] = array(
'name' => $name, 'name' => $name,
'type' => $type, 'type' => $type,
'startBlock' => $startBlock, 'startBlock' => $startBlock,
'size' => $size); 'size' => $size
);
// tmp helper to simplify checks // tmp helper to simplify checks
$upName = strtoupper($name); $upName = strtoupper($name);
@ -269,8 +272,7 @@ class PHPExcel_Shared_OLERead {
// Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook) // Workbook directory entry (BIFF5 uses Book, BIFF8 uses Workbook)
if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) { if (($upName === 'WORKBOOK') || ($upName === 'BOOK')) {
$this->wrkbook = count($this->props) - 1; $this->wrkbook = count($this->props) - 1;
} } else if ($upName === 'ROOT ENTRY' || $upName === 'R') {
else if ( $upName === 'ROOT ENTRY' || $upName === 'R') {
// Root entry // Root entry
$this->rootentry = count($this->props) - 1; $this->rootentry = count($this->props) - 1;
} }
@ -289,7 +291,6 @@ class PHPExcel_Shared_OLERead {
$offset += self::PROPERTY_STORAGE_BLOCK_SIZE; $offset += self::PROPERTY_STORAGE_BLOCK_SIZE;
} }
} }
/** /**
@ -313,5 +314,4 @@ class PHPExcel_Shared_OLERead {
} }
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24; return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $_ord_24;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,8 @@ class PHPExcel_Shared_PasswordHasher
* @param string $pPassword Password to hash * @param string $pPassword Password to hash
* @return string Hashed password * @return string Hashed password
*/ */
public static function hashPassword($pPassword = '') { public static function hashPassword($pPassword = '')
{
$password = 0x0000; $password = 0x0000;
$charPos = 1; // char position $charPos = 1; // char position

View File

@ -93,7 +93,8 @@ class PHPExcel_Shared_String
/** /**
* Build control characters array * Build control characters array
*/ */
private static function _buildControlCharacters() { private static function _buildControlCharacters()
{
for ($i = 0; $i <= 31; ++$i) { for ($i = 0; $i <= 31; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) { if ($i != 9 && $i != 10 && $i != 13) {
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_'; $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_';
@ -316,10 +317,7 @@ class PHPExcel_Shared_String
} }
// CUSTOM: IBM AIX iconv() does not work // CUSTOM: IBM AIX iconv() does not work
if ( defined('PHP_OS') && @stristr(PHP_OS, 'AIX') if (defined('PHP_OS') && @stristr(PHP_OS, 'AIX') && defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0) && defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0)) {
&& defined('ICONV_IMPL') && (@strcasecmp(ICONV_IMPL, 'unknown') == 0)
&& defined('ICONV_VERSION') && (@strcasecmp(ICONV_VERSION, 'unknown') == 0) )
{
self::$_isIconvEnabled = false; self::$_isIconvEnabled = false;
return false; return false;
} }
@ -329,7 +327,8 @@ class PHPExcel_Shared_String
return true; return true;
} }
public static function buildCharacterSets() { public static function buildCharacterSets()
{
if (empty(self::$_controlCharacters)) { if (empty(self::$_controlCharacters)) {
self::_buildControlCharacters(); self::_buildControlCharacters();
} }
@ -352,7 +351,8 @@ class PHPExcel_Shared_String
* @param string $value Value to unescape * @param string $value Value to unescape
* @return string * @return string
*/ */
public static function ControlCharacterOOXML2PHP($value = '') { public static function ControlCharacterOOXML2PHP($value = '')
{
return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value); return str_replace(array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value);
} }
@ -370,7 +370,8 @@ class PHPExcel_Shared_String
* @param string $value Value to escape * @param string $value Value to escape
* @return string * @return string
*/ */
public static function ControlCharacterPHP2OOXML($value = '') { public static function ControlCharacterPHP2OOXML($value = '')
{
return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value); return str_replace(array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value);
} }
@ -402,7 +403,8 @@ class PHPExcel_Shared_String
* @param string $value * @param string $value
* @return boolean * @return boolean
*/ */
public static function IsUTF8($value = '') { public static function IsUTF8($value = '')
{
return $value === '' || preg_match('/^./su', $value) === 1; return $value === '' || preg_match('/^./su', $value) === 1;
} }
@ -413,7 +415,8 @@ class PHPExcel_Shared_String
* @param mixed $value * @param mixed $value
* @return string * @return string
*/ */
public static function FormatNumber($value) { public static function FormatNumber($value)
{
if (is_float($value)) { if (is_float($value)) {
return str_replace(',', '.', $value); return str_replace(',', '.', $value);
} }
@ -523,17 +526,29 @@ class PHPExcel_Shared_String
* @author Rasmus Andersson {@link http://rasmusandersson.se/} * @author Rasmus Andersson {@link http://rasmusandersson.se/}
* @author vadik56 * @author vadik56
*/ */
public static function utf16_decode($str, $bom_be = TRUE) { public static function utf16_decode($str, $bom_be = true)
if ( strlen($str) < 2 ) return $str; {
if (strlen($str) < 2) {
return $str;
}
$c0 = ord($str{0}); $c0 = ord($str{0});
$c1 = ord($str{1}); $c1 = ord($str{1});
if ( $c0 == 0xfe && $c1 == 0xff ) { $str = substr($str,2); } if ($c0 == 0xfe && $c1 == 0xff) {
elseif ( $c0 == 0xff && $c1 == 0xfe ) { $str = substr($str,2); $bom_be = false; } $str = substr($str, 2);
} elseif ($c0 == 0xff && $c1 == 0xfe) {
$str = substr($str, 2);
$bom_be = false;
}
$len = strlen($str); $len = strlen($str);
$newstr = ''; $newstr = '';
for ($i=0; $i<$len; $i+=2) { for ($i=0; $i<$len; $i+=2) {
if ( $bom_be ) { $val = ord($str{$i}) << 4; $val += ord($str{$i+1}); } if ($bom_be) {
else { $val = ord($str{$i+1}) << 4; $val += ord($str{$i}); } $val = ord($str{$i}) << 4;
$val += ord($str{$i+1});
} else {
$val = ord($str{$i+1}) << 4;
$val += ord($str{$i});
}
$newstr .= ($val == 0x228) ? "\n" : chr($val); $newstr .= ($val == 0x228) ? "\n" : chr($val);
} }
return $newstr; return $newstr;
@ -667,7 +682,8 @@ class PHPExcel_Shared_String
* @param string &$operand string value to test * @param string &$operand string value to test
* @return boolean * @return boolean
*/ */
public static function convertToNumberIfFraction(&$operand) { public static function convertToNumberIfFraction(&$operand)
{
if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) { if (preg_match('/^'.self::STRING_REGEXP_FRACTION.'$/i', $operand, $match)) {
$sign = ($match[1] == '-') ? '-' : '+'; $sign = ($match[1] == '-') ? '-' : '+';
$fractionFormula = '='.$sign.$match[2].$sign.$match[3]; $fractionFormula = '='.$sign.$match[2].$sign.$match[3];
@ -802,8 +818,9 @@ class PHPExcel_Shared_String
*/ */
public static function testStringAsNumeric($value) public static function testStringAsNumeric($value)
{ {
if (is_numeric($value)) if (is_numeric($value)) {
return $value; return $value;
}
$v = floatval($value); $v = floatval($value);
return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value; return (is_numeric(substr($value, 0, strlen($v)))) ? $v : $value;
} }

View File

@ -50,7 +50,8 @@ class PHPExcel_Shared_TimeZone
* @param string $timezone Time zone (e.g. 'Europe/London') * @param string $timezone Time zone (e.g. 'Europe/London')
* @return boolean Success or failure * @return boolean Success or failure
*/ */
public static function _validateTimeZone($timezone) { public static function _validateTimeZone($timezone)
{
if (in_array($timezone, DateTimeZone::listIdentifiers())) { if (in_array($timezone, DateTimeZone::listIdentifiers())) {
return true; return true;
} }
@ -63,7 +64,8 @@ class PHPExcel_Shared_TimeZone
* @param string $timezone Time zone (e.g. 'Europe/London') * @param string $timezone Time zone (e.g. 'Europe/London')
* @return boolean Success or failure * @return boolean Success or failure
*/ */
public static function setTimeZone($timezone) { public static function setTimeZone($timezone)
{
if (self::_validateTimezone($timezone)) { if (self::_validateTimezone($timezone)) {
self::$_timezone = $timezone; self::$_timezone = $timezone;
return true; return true;
@ -77,7 +79,8 @@ class PHPExcel_Shared_TimeZone
* *
* @return string Timezone (e.g. 'Europe/London') * @return string Timezone (e.g. 'Europe/London')
*/ */
public static function getTimeZone() { public static function getTimeZone()
{
return self::$_timezone; return self::$_timezone;
} // function getTimezone() } // function getTimezone()
@ -89,7 +92,8 @@ class PHPExcel_Shared_TimeZone
* @param integer $timestamp PHP date/time value for finding the current transition * @param integer $timestamp PHP date/time value for finding the current transition
* @return array The current transition details * @return array The current transition details
*/ */
private static function _getTimezoneTransitions($objTimezone, $timestamp) { private static function _getTimezoneTransitions($objTimezone, $timestamp)
{
$allTransitions = $objTimezone->getTransitions(); $allTransitions = $objTimezone->getTransitions();
$transitions = array(); $transitions = array();
foreach ($allTransitions as $key => $transition) { foreach ($allTransitions as $key => $transition) {
@ -114,7 +118,8 @@ class PHPExcel_Shared_TimeZone
* @return integer Number of seconds for timezone adjustment * @return integer Number of seconds for timezone adjustment
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public static function getTimeZoneAdjustment($timezone, $timestamp) { public static function getTimeZoneAdjustment($timezone, $timestamp)
{
if ($timezone !== null) { if ($timezone !== null) {
if (!self::_validateTimezone($timezone)) { if (!self::_validateTimezone($timezone)) {
throw new PHPExcel_Exception("Invalid timezone " . $timezone); throw new PHPExcel_Exception("Invalid timezone " . $timezone);

View File

@ -33,7 +33,6 @@ if (!defined('DEBUGMODE_ENABLED')) {
define('DEBUGMODE_ENABLED', false); define('DEBUGMODE_ENABLED', false);
} }
/** /**
* PHPExcel_Shared_XMLWriter * PHPExcel_Shared_XMLWriter
* *
@ -41,7 +40,8 @@ if (!defined('DEBUGMODE_ENABLED')) {
* @package PHPExcel_Shared * @package PHPExcel_Shared
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Shared_XMLWriter extends XMLWriter { class PHPExcel_Shared_XMLWriter extends XMLWriter
{
/** Temporary storage method */ /** Temporary storage method */
const STORAGE_MEMORY = 1; const STORAGE_MEMORY = 1;
const STORAGE_DISK = 2; const STORAGE_DISK = 2;
@ -59,14 +59,16 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
* @param int $pTemporaryStorage Temporary storage location * @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageFolder Temporary storage folder * @param string $pTemporaryStorageFolder Temporary storage folder
*/ */
public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = NULL) { public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTemporaryStorageFolder = null)
{
// Open temporary storage // Open temporary storage
if ($pTemporaryStorage == self::STORAGE_MEMORY) { if ($pTemporaryStorage == self::STORAGE_MEMORY) {
$this->openMemory(); $this->openMemory();
} else { } else {
// Create temporary filename // Create temporary filename
if ($pTemporaryStorageFolder === NULL) if ($pTemporaryStorageFolder === null) {
$pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir(); $pTemporaryStorageFolder = PHPExcel_Shared_File::sys_get_temp_dir();
}
$this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml'); $this->_tempFileName = @tempnam($pTemporaryStorageFolder, 'xml');
// Open storage // Open storage
@ -85,7 +87,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
/** /**
* Destructor * Destructor
*/ */
public function __destruct() { public function __destruct()
{
// Unlink temporary files // Unlink temporary files
if ($this->_tempFileName != '') { if ($this->_tempFileName != '') {
@unlink($this->_tempFileName); @unlink($this->_tempFileName);
@ -97,7 +100,8 @@ class PHPExcel_Shared_XMLWriter extends XMLWriter {
* *
* @return $data * @return $data
*/ */
public function getData() { public function getData()
{
if ($this->_tempFileName == '') { if ($this->_tempFileName == '') {
return $this->outputMemory(true); return $this->outputMemory(true);
} else { } else {

View File

@ -92,10 +92,7 @@ class PHPExcel_Shared_ZipArchive
fwrite($handle, $contents); fwrite($handle, $contents);
fclose($handle); fclose($handle);
$res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"], $res = $this->_zip->add($this->_tempDir.'/'.$filenameParts["basename"], PCLZIP_OPT_REMOVE_PATH, $this->_tempDir, PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]);
PCLZIP_OPT_REMOVE_PATH, $this->_tempDir,
PCLZIP_OPT_ADD_PATH, $filenameParts["dirname"]
);
if ($res == 0) { if ($res == 0) {
throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true)); throw new PHPExcel_Writer_Exception("Error zipping files : " . $this->_zip->errorInfo(true));
} }

View File

@ -25,11 +25,12 @@
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
class PHPExcel_Shared_ZipStreamWrapper { class PHPExcel_Shared_ZipStreamWrapper
{
/** /**
* Internal ZipAcrhive * Internal ZipAcrhive
* *
* @var ZipAcrhive * @var ZipArchive
*/ */
private $_archive; private $_archive;

View File

@ -25,7 +25,6 @@
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
/** /**
* PHPExcel_Best_Fit * PHPExcel_Best_Fit
* *
@ -40,7 +39,7 @@ class PHPExcel_Best_Fit
* *
* @var boolean * @var boolean
**/ **/
protected $_error = False; protected $_error = false;
/** /**
* Algorithm type to use for best-fit * Algorithm type to use for best-fit
@ -75,7 +74,7 @@ class PHPExcel_Best_Fit
* *
* @var boolean * @var boolean
**/ **/
protected $_adjustToZero = False; protected $_adjustToZero = false;
/** /**
* Y-value series of best-fit values * Y-value series of best-fit values
@ -113,205 +112,207 @@ class PHPExcel_Best_Fit
protected $_Yoffset = 0; protected $_Yoffset = 0;
public function getError() { public function getError()
{
return $this->_error; return $this->_error;
} // function getBestFitType() } // function getBestFitType()
public function getBestFitType() { public function getBestFitType()
{
return $this->_bestFitType; return $this->_bestFitType;
} // function getBestFitType() } // function getBestFitType()
/** /**
* Return the Y-Value for a specified value of X * Return the Y-Value for a specified value of X
* *
* @param float $xValue X-Value * @param float $xValue X-Value
* @return float Y-Value * @return float Y-Value
*/ */
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue)
return False; {
return false;
} // function getValueOfYForX() } // function getValueOfYForX()
/** /**
* Return the X-Value for a specified value of Y * Return the X-Value for a specified value of Y
* *
* @param float $yValue Y-Value * @param float $yValue Y-Value
* @return float X-Value * @return float X-Value
*/ */
public function getValueOfXForY($yValue) { public function getValueOfXForY($yValue)
return False; {
return false;
} // function getValueOfXForY() } // function getValueOfXForY()
/** /**
* Return the original set of X-Values * Return the original set of X-Values
* *
* @return float[] X-Values * @return float[] X-Values
*/ */
public function getXValues() { public function getXValues()
{
return $this->_xValues; return $this->_xValues;
} // function getValueOfXForY() } // function getValueOfXForY()
/** /**
* Return the Equation of the best-fit line * Return the Equation of the best-fit line
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
*/ */
public function getEquation($dp=0) { public function getEquation($dp = 0)
return False; {
return false;
} // function getEquation() } // function getEquation()
/** /**
* Return the Slope of the line * Return the Slope of the line
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
*/ */
public function getSlope($dp=0) { public function getSlope($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round($this->_slope, $dp); return round($this->_slope, $dp);
} }
return $this->_slope; return $this->_slope;
} // function getSlope() } // function getSlope()
/** /**
* Return the standard error of the Slope * Return the standard error of the Slope
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
*/ */
public function getSlopeSE($dp=0) { public function getSlopeSE($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round($this->_slopeSE, $dp); return round($this->_slopeSE, $dp);
} }
return $this->_slopeSE; return $this->_slopeSE;
} // function getSlopeSE() } // function getSlopeSE()
/** /**
* Return the Value of X where it intersects Y = 0 * Return the Value of X where it intersects Y = 0
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
*/ */
public function getIntersect($dp=0) { public function getIntersect($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round($this->_intersect, $dp); return round($this->_intersect, $dp);
} }
return $this->_intersect; return $this->_intersect;
} // function getIntersect() } // function getIntersect()
/** /**
* Return the standard error of the Intersect * Return the standard error of the Intersect
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
*/ */
public function getIntersectSE($dp=0) { public function getIntersectSE($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round($this->_intersectSE, $dp); return round($this->_intersectSE, $dp);
} }
return $this->_intersectSE; return $this->_intersectSE;
} // function getIntersectSE() } // function getIntersectSE()
/** /**
* Return the goodness of fit for this regression * Return the goodness of fit for this regression
* *
* @param int $dp Number of places of decimal precision to return * @param int $dp Number of places of decimal precision to return
* @return float * @return float
*/ */
public function getGoodnessOfFit($dp=0) { public function getGoodnessOfFit($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round($this->_goodnessOfFit, $dp); return round($this->_goodnessOfFit, $dp);
} }
return $this->_goodnessOfFit; return $this->_goodnessOfFit;
} // function getGoodnessOfFit() } // function getGoodnessOfFit()
public function getGoodnessOfFitPercent($dp = 0)
public function getGoodnessOfFitPercent($dp=0) { {
if ($dp != 0) { if ($dp != 0) {
return round($this->_goodnessOfFit * 100, $dp); return round($this->_goodnessOfFit * 100, $dp);
} }
return $this->_goodnessOfFit * 100; return $this->_goodnessOfFit * 100;
} // function getGoodnessOfFitPercent() } // function getGoodnessOfFitPercent()
/** /**
* Return the standard deviation of the residuals for this regression * Return the standard deviation of the residuals for this regression
* *
* @param int $dp Number of places of decimal precision to return * @param int $dp Number of places of decimal precision to return
* @return float * @return float
*/ */
public function getStdevOfResiduals($dp=0) { public function getStdevOfResiduals($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round($this->_stdevOfResiduals, $dp); return round($this->_stdevOfResiduals, $dp);
} }
return $this->_stdevOfResiduals; return $this->_stdevOfResiduals;
} // function getStdevOfResiduals() } // function getStdevOfResiduals()
public function getSSRegression($dp = 0)
public function getSSRegression($dp=0) { {
if ($dp != 0) { if ($dp != 0) {
return round($this->_SSRegression, $dp); return round($this->_SSRegression, $dp);
} }
return $this->_SSRegression; return $this->_SSRegression;
} // function getSSRegression() } // function getSSRegression()
public function getSSResiduals($dp = 0)
public function getSSResiduals($dp=0) { {
if ($dp != 0) { if ($dp != 0) {
return round($this->_SSResiduals, $dp); return round($this->_SSResiduals, $dp);
} }
return $this->_SSResiduals; return $this->_SSResiduals;
} // function getSSResiduals() } // function getSSResiduals()
public function getDFResiduals($dp = 0)
public function getDFResiduals($dp=0) { {
if ($dp != 0) { if ($dp != 0) {
return round($this->_DFResiduals, $dp); return round($this->_DFResiduals, $dp);
} }
return $this->_DFResiduals; return $this->_DFResiduals;
} // function getDFResiduals() } // function getDFResiduals()
public function getF($dp = 0)
public function getF($dp=0) { {
if ($dp != 0) { if ($dp != 0) {
return round($this->_F, $dp); return round($this->_F, $dp);
} }
return $this->_F; return $this->_F;
} // function getF() } // function getF()
public function getCovariance($dp = 0)
public function getCovariance($dp=0) { {
if ($dp != 0) { if ($dp != 0) {
return round($this->_covariance, $dp); return round($this->_covariance, $dp);
} }
return $this->_covariance; return $this->_covariance;
} // function getCovariance() } // function getCovariance()
public function getCorrelation($dp = 0)
public function getCorrelation($dp=0) { {
if ($dp != 0) { if ($dp != 0) {
return round($this->_correlation, $dp); return round($this->_correlation, $dp);
} }
return $this->_correlation; return $this->_correlation;
} // function getCorrelation() } // function getCorrelation()
public function getYBestFitValues()
public function getYBestFitValues() { {
return $this->_yBestFitValues; return $this->_yBestFitValues;
} // function getYBestFitValues() } // function getYBestFitValues()
protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const)
protected function _calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const) { {
$SSres = $SScov = $SScor = $SStot = $SSsex = 0.0; $SSres = $SScov = $SScor = $SStot = $SSsex = 0.0;
foreach ($this->_xValues as $xKey => $xValue) { foreach ($this->_xValues as $xKey => $xValue) {
$bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue); $bestFitY = $this->_yBestFitValues[$xKey] = $this->getValueOfYForX($xValue);
@ -364,8 +365,8 @@ class PHPExcel_Best_Fit
} }
} // function _calculateGoodnessOfFit() } // function _calculateGoodnessOfFit()
protected function _leastSquareFit($yValues, $xValues, $const)
protected function _leastSquareFit($yValues, $xValues, $const) { {
// calculate sums // calculate sums
$x_sum = array_sum($xValues); $x_sum = array_sum($xValues);
$y_sum = array_sum($yValues); $y_sum = array_sum($yValues);
@ -401,7 +402,6 @@ class PHPExcel_Best_Fit
$this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const); $this->_calculateGoodnessOfFit($x_sum, $y_sum, $xx_sum, $yy_sum, $xy_sum, $meanX, $meanY, $const);
} // function _leastSquareFit() } // function _leastSquareFit()
/** /**
* Define the regression * Define the regression
* *
@ -409,7 +409,8 @@ class PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
function __construct($yValues, $xValues=array(), $const=True) { public function __construct($yValues, $xValues = array(), $const = true)
{
// Calculate number of points // Calculate number of points
$nY = count($yValues); $nY = count($yValues);
$nX = count($xValues); $nX = count($xValues);
@ -420,13 +421,12 @@ class PHPExcel_Best_Fit
$nX = $nY; $nX = $nY;
} elseif ($nY != $nX) { } elseif ($nY != $nX) {
// Ensure both arrays of points are the same size // Ensure both arrays of points are the same size
$this->_error = True; $this->_error = true;
return False; return false;
} }
$this->_valueCount = $nY; $this->_valueCount = $nY;
$this->_xValues = $xValues; $this->_xValues = $xValues;
$this->_yValues = $yValues; $this->_yValues = $yValues;
} // function __construct() } // function __construct()
}
} // class bestFit

View File

@ -46,71 +46,70 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
**/ **/
protected $_bestFitType = 'exponential'; protected $_bestFitType = 'exponential';
/** /**
* Return the Y-Value for a specified value of X * Return the Y-Value for a specified value of X
* *
* @param float $xValue X-Value * @param float $xValue X-Value
* @return float Y-Value * @return float Y-Value
**/ **/
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue)
{
return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->_Xoffset)); return $this->getIntersect() * pow($this->getSlope(), ($xValue - $this->_Xoffset));
} // function getValueOfYForX() } // function getValueOfYForX()
/** /**
* Return the X-Value for a specified value of Y * Return the X-Value for a specified value of Y
* *
* @param float $yValue Y-Value * @param float $yValue Y-Value
* @return float X-Value * @return float X-Value
**/ **/
public function getValueOfXForY($yValue) { public function getValueOfXForY($yValue)
{
return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($this->getSlope()); return log(($yValue + $this->_Yoffset) / $this->getIntersect()) / log($this->getSlope());
} // function getValueOfXForY() } // function getValueOfXForY()
/** /**
* Return the Equation of the best-fit line * Return the Equation of the best-fit line
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getEquation($dp=0) { public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
return 'Y = '.$intersect.' * '.$slope.'^X'; return 'Y = '.$intersect.' * '.$slope.'^X';
} // function getEquation() } // function getEquation()
/** /**
* Return the Slope of the line * Return the Slope of the line
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getSlope($dp=0) { public function getSlope($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_slope), $dp); return round(exp($this->_slope), $dp);
} }
return exp($this->_slope); return exp($this->_slope);
} // function getSlope() } // function getSlope()
/** /**
* Return the Value of X where it intersects Y = 0 * Return the Value of X where it intersects Y = 0
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getIntersect($dp=0) { public function getIntersect($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_intersect), $dp); return round(exp($this->_intersect), $dp);
} }
return exp($this->_intersect); return exp($this->_intersect);
} // function getIntersect() } // function getIntersect()
/** /**
* Execute the regression and calculate the goodness of fit for a set of X and Y data values * Execute the regression and calculate the goodness of fit for a set of X and Y data values
* *
@ -118,7 +117,8 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
private function _exponential_regression($yValues, $xValues, $const) { private function _exponential_regression($yValues, $xValues, $const)
{
foreach ($yValues as &$value) { foreach ($yValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
@ -131,7 +131,6 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
$this->_leastSquareFit($yValues, $xValues, $const); $this->_leastSquareFit($yValues, $xValues, $const);
} // function _exponential_regression() } // function _exponential_regression()
/** /**
* Define the regression and calculate the goodness of fit for a set of X and Y data values * Define the regression and calculate the goodness of fit for a set of X and Y data values
* *
@ -139,10 +138,10 @@ class PHPExcel_Exponential_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
function __construct($yValues, $xValues=array(), $const=True) { function __construct($yValues, $xValues = array(), $const = true)
if (parent::__construct($yValues, $xValues) !== False) { {
if (parent::__construct($yValues, $xValues) !== false) {
$this->_exponential_regression($yValues, $xValues, $const); $this->_exponential_regression($yValues, $xValues, $const);
} }
} // function __construct() } // function __construct()
}
} // class exponentialBestFit

View File

@ -25,10 +25,8 @@
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php'); require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
/** /**
* PHPExcel_Linear_Best_Fit * PHPExcel_Linear_Best_Fit
* *
@ -46,25 +44,25 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
**/ **/
protected $_bestFitType = 'linear'; protected $_bestFitType = 'linear';
/** /**
* Return the Y-Value for a specified value of X * Return the Y-Value for a specified value of X
* *
* @param float $xValue X-Value * @param float $xValue X-Value
* @return float Y-Value * @return float Y-Value
**/ **/
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue)
{
return $this->getIntersect() + $this->getSlope() * $xValue; return $this->getIntersect() + $this->getSlope() * $xValue;
} // function getValueOfYForX() } // function getValueOfYForX()
/** /**
* Return the X-Value for a specified value of Y * Return the X-Value for a specified value of Y
* *
* @param float $yValue Y-Value * @param float $yValue Y-Value
* @return float X-Value * @return float X-Value
**/ **/
public function getValueOfXForY($yValue) { public function getValueOfXForY($yValue)
{
return ($yValue - $this->getIntersect()) / $this->getSlope(); return ($yValue - $this->getIntersect()) / $this->getSlope();
} // function getValueOfXForY() } // function getValueOfXForY()
@ -75,14 +73,14 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getEquation($dp=0) { public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
return 'Y = '.$intersect.' + '.$slope.' * X'; return 'Y = '.$intersect.' + '.$slope.' * X';
} // function getEquation() } // function getEquation()
/** /**
* Execute the regression and calculate the goodness of fit for a set of X and Y data values * Execute the regression and calculate the goodness of fit for a set of X and Y data values
* *
@ -90,11 +88,11 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
private function _linear_regression($yValues, $xValues, $const) { private function _linear_regression($yValues, $xValues, $const)
{
$this->_leastSquareFit($yValues, $xValues, $const); $this->_leastSquareFit($yValues, $xValues, $const);
} // function _linear_regression() } // function _linear_regression()
/** /**
* Define the regression and calculate the goodness of fit for a set of X and Y data values * Define the regression and calculate the goodness of fit for a set of X and Y data values
* *
@ -102,10 +100,10 @@ class PHPExcel_Linear_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
function __construct($yValues, $xValues=array(), $const=True) { function __construct($yValues, $xValues = array(), $const = true)
if (parent::__construct($yValues, $xValues) !== False) { {
if (parent::__construct($yValues, $xValues) !== false) {
$this->_linear_regression($yValues, $xValues, $const); $this->_linear_regression($yValues, $xValues, $const);
} }
} // function __construct() } // function __construct()
}
} // class linearBestFit

View File

@ -25,10 +25,8 @@
* @version ##VERSION##, ##DATE## * @version ##VERSION##, ##DATE##
*/ */
require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php'); require_once(PHPEXCEL_ROOT . 'PHPExcel/Shared/trend/bestFitClass.php');
/** /**
* PHPExcel_Logarithmic_Best_Fit * PHPExcel_Logarithmic_Best_Fit
* *
@ -46,43 +44,42 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
**/ **/
protected $_bestFitType = 'logarithmic'; protected $_bestFitType = 'logarithmic';
/** /**
* Return the Y-Value for a specified value of X * Return the Y-Value for a specified value of X
* *
* @param float $xValue X-Value * @param float $xValue X-Value
* @return float Y-Value * @return float Y-Value
**/ **/
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue)
{
return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset); return $this->getIntersect() + $this->getSlope() * log($xValue - $this->_Xoffset);
} // function getValueOfYForX() } // function getValueOfYForX()
/** /**
* Return the X-Value for a specified value of Y * Return the X-Value for a specified value of Y
* *
* @param float $yValue Y-Value * @param float $yValue Y-Value
* @return float X-Value * @return float X-Value
**/ **/
public function getValueOfXForY($yValue) { public function getValueOfXForY($yValue)
{
return exp(($yValue - $this->getIntersect()) / $this->getSlope()); return exp(($yValue - $this->getIntersect()) / $this->getSlope());
} // function getValueOfXForY() } // function getValueOfXForY()
/** /**
* Return the Equation of the best-fit line * Return the Equation of the best-fit line
* *
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getEquation($dp=0) { public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
return 'Y = '.$intersect.' + '.$slope.' * log(X)'; return 'Y = '.$intersect.' + '.$slope.' * log(X)';
} // function getEquation() } // function getEquation()
/** /**
* Execute the regression and calculate the goodness of fit for a set of X and Y data values * Execute the regression and calculate the goodness of fit for a set of X and Y data values
* *
@ -90,7 +87,8 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
private function _logarithmic_regression($yValues, $xValues, $const) { private function _logarithmic_regression($yValues, $xValues, $const)
{
foreach ($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
@ -103,7 +101,6 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
$this->_leastSquareFit($yValues, $xValues, $const); $this->_leastSquareFit($yValues, $xValues, $const);
} // function _logarithmic_regression() } // function _logarithmic_regression()
/** /**
* Define the regression and calculate the goodness of fit for a set of X and Y data values * Define the regression and calculate the goodness of fit for a set of X and Y data values
* *
@ -111,10 +108,10 @@ class PHPExcel_Logarithmic_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
function __construct($yValues, $xValues=array(), $const=True) { function __construct($yValues, $xValues = array(), $const = true)
if (parent::__construct($yValues, $xValues) !== False) { {
if (parent::__construct($yValues, $xValues) !== false) {
$this->_logarithmic_regression($yValues, $xValues, $const); $this->_logarithmic_regression($yValues, $xValues, $const);
} }
} // function __construct() } // function __construct()
}
} // class logarithmicBestFit

View File

@ -61,7 +61,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* *
* @return int * @return int
**/ **/
public function getOrder() { public function getOrder()
{
return $this->_order; return $this->_order;
} // function getOrder() } // function getOrder()
@ -72,7 +73,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float $xValue X-Value * @param float $xValue X-Value
* @return float Y-Value * @return float Y-Value
**/ **/
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue)
{
$retVal = $this->getIntersect(); $retVal = $this->getIntersect();
$slope = $this->getSlope(); $slope = $this->getSlope();
foreach ($slope as $key => $value) { foreach ($slope as $key => $value) {
@ -90,7 +92,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float $yValue Y-Value * @param float $yValue Y-Value
* @return float X-Value * @return float X-Value
**/ **/
public function getValueOfXForY($yValue) { public function getValueOfXForY($yValue)
{
return ($yValue - $this->getIntersect()) / $this->getSlope(); return ($yValue - $this->getIntersect()) / $this->getSlope();
} // function getValueOfXForY() } // function getValueOfXForY()
@ -101,7 +104,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getEquation($dp=0) { public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
@ -124,7 +128,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getSlope($dp=0) { public function getSlope($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
$coefficients = array(); $coefficients = array();
foreach ($this->_slope as $coefficient) { foreach ($this->_slope as $coefficient) {
@ -136,7 +141,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
} // function getSlope() } // function getSlope()
public function getCoefficients($dp=0) { public function getCoefficients($dp = 0)
{
return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp)); return array_merge(array($this->getIntersect($dp)), $this->getSlope($dp));
} // function getCoefficients() } // function getCoefficients()
@ -149,7 +155,8 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
private function _polynomial_regression($order, $yValues, $xValues, $const) { private function _polynomial_regression($order, $yValues, $xValues, $const)
{
// calculate sums // calculate sums
$x_sum = array_sum($xValues); $x_sum = array_sum($xValues);
$y_sum = array_sum($yValues); $y_sum = array_sum($yValues);
@ -206,19 +213,19 @@ class PHPExcel_Polynomial_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
function __construct($order, $yValues, $xValues=array(), $const=True) { function __construct($order, $yValues, $xValues = array(), $const = true)
if (parent::__construct($yValues, $xValues) !== False) { {
if (parent::__construct($yValues, $xValues) !== false) {
if ($order < $this->_valueCount) { if ($order < $this->_valueCount) {
$this->_bestFitType .= '_'.$order; $this->_bestFitType .= '_'.$order;
$this->_order = $order; $this->_order = $order;
$this->_polynomial_regression($order, $yValues, $xValues, $const); $this->_polynomial_regression($order, $yValues, $xValues, $const);
if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) { if (($this->getGoodnessOfFit() < 0.0) || ($this->getGoodnessOfFit() > 1.0)) {
$this->_error = True; $this->_error = true;
} }
} else { } else {
$this->_error = True; $this->_error = true;
} }
} }
} // function __construct() } // function __construct()
}
} // class polynomialBestFit

View File

@ -53,7 +53,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float $xValue X-Value * @param float $xValue X-Value
* @return float Y-Value * @return float Y-Value
**/ **/
public function getValueOfYForX($xValue) { public function getValueOfYForX($xValue)
{
return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope()); return $this->getIntersect() * pow(($xValue - $this->_Xoffset), $this->getSlope());
} // function getValueOfYForX() } // function getValueOfYForX()
@ -64,7 +65,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float $yValue Y-Value * @param float $yValue Y-Value
* @return float X-Value * @return float X-Value
**/ **/
public function getValueOfXForY($yValue) { public function getValueOfXForY($yValue)
{
return pow((($yValue + $this->_Yoffset) / $this->getIntersect()), (1 / $this->getSlope())); return pow((($yValue + $this->_Yoffset) / $this->getIntersect()), (1 / $this->getSlope()));
} // function getValueOfXForY() } // function getValueOfXForY()
@ -75,7 +77,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getEquation($dp=0) { public function getEquation($dp = 0)
{
$slope = $this->getSlope($dp); $slope = $this->getSlope($dp);
$intersect = $this->getIntersect($dp); $intersect = $this->getIntersect($dp);
@ -89,7 +92,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param int $dp Number of places of decimal precision to display * @param int $dp Number of places of decimal precision to display
* @return string * @return string
**/ **/
public function getIntersect($dp=0) { public function getIntersect($dp = 0)
{
if ($dp != 0) { if ($dp != 0) {
return round(exp($this->_intersect), $dp); return round(exp($this->_intersect), $dp);
} }
@ -104,7 +108,8 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
private function _power_regression($yValues, $xValues, $const) { private function _power_regression($yValues, $xValues, $const)
{
foreach ($xValues as &$value) { foreach ($xValues as &$value) {
if ($value < 0.0) { if ($value < 0.0) {
$value = 0 - log(abs($value)); $value = 0 - log(abs($value));
@ -133,10 +138,10 @@ class PHPExcel_Power_Best_Fit extends PHPExcel_Best_Fit
* @param float[] $xValues The set of X-values for this regression * @param float[] $xValues The set of X-values for this regression
* @param boolean $const * @param boolean $const
*/ */
function __construct($yValues, $xValues=array(), $const=True) { function __construct($yValues, $xValues = array(), $const = true)
if (parent::__construct($yValues, $xValues) !== False) { {
if (parent::__construct($yValues, $xValues) !== false) {
$this->_power_regression($yValues, $xValues, $const); $this->_power_regression($yValues, $xValues, $const);
} }
} // function __construct() }
}
} // class powerBestFit

View File

@ -84,7 +84,8 @@ class trendClass
private static $_trendCache = array(); private static $_trendCache = array();
public static function calculate($trendType=self::TREND_BEST_FIT, $yValues, $xValues=array(), $const=True) { public static function calculate($trendType = self::TREND_BEST_FIT, $yValues, $xValues = array(), $const = true)
{
// Calculate number of points in each dataset // Calculate number of points in each dataset
$nY = count($yValues); $nY = count($yValues);
$nX = count($xValues); $nX = count($xValues);
@ -152,5 +153,4 @@ class trendClass
return false; return false;
} }
} // function calculate() } // function calculate()
} // class trendClass } // class trendClass

View File

@ -196,7 +196,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @var PHPExcel_Worksheet_AutoFilter * @var PHPExcel_Worksheet_AutoFilter
*/ */
private $_autoFilter = NULL; private $_autoFilter = null;
/** /**
* Freeze pane * Freeze pane
@ -334,7 +334,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{ {
// Set parent and title // Set parent and title
$this->_parent = $pParent; $this->_parent = $pParent;
$this->setTitle($pTitle, FALSE); $this->setTitle($pTitle, false);
// setTitle can change $pTitle // setTitle can change $pTitle
$this->setCodeName($this->getTitle()); $this->setCodeName($this->getTitle());
$this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE); $this->setSheetState(PHPExcel_Worksheet::SHEETSTATE_VISIBLE);
@ -363,12 +363,12 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$this->_protection = new PHPExcel_Worksheet_Protection(); $this->_protection = new PHPExcel_Worksheet_Protection();
// Default row dimension // Default row dimension
$this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(NULL); $this->_defaultRowDimension = new PHPExcel_Worksheet_RowDimension(null);
// Default column dimension // Default column dimension
$this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(NULL); $this->_defaultColumnDimension = new PHPExcel_Worksheet_ColumnDimension(null);
$this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(NULL, $this); $this->_autoFilter = new PHPExcel_Worksheet_AutoFilter(null, $this);
} }
@ -377,10 +377,11 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* typically so that the worksheet object can be unset * typically so that the worksheet object can be unset
* *
*/ */
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;
} }
// detach ourself from the workbook, so that it can then delete this worksheet successfully // detach ourself from the workbook, so that it can then delete this worksheet successfully
$this->_parent = null; $this->_parent = null;
@ -390,9 +391,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* Code to execute when this worksheet is unset() * Code to execute when this worksheet is unset()
* *
*/ */
function __destruct() { function __destruct()
PHPExcel_Calculation::getInstance($this->_parent) {
->clearCalculationCacheForWorksheet($this->_title); PHPExcel_Calculation::getInstance($this->_parent)->clearCalculationCacheForWorksheet($this->_title);
$this->disconnectCells(); $this->disconnectCells();
} }
@ -402,7 +403,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_CachedObjectStorage_xxx * @return PHPExcel_CachedObjectStorage_xxx
*/ */
public function getCellCacheController() { public function getCellCacheController()
{
return $this->_cellCollection; return $this->_cellCollection;
} // function getCellCacheController() } // function getCellCacheController()
@ -479,7 +481,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// Re-order cell collection // Re-order cell collection
return $this->sortCellCollection(); return $this->sortCellCollection();
} }
if ($this->_cellCollection !== NULL) { if ($this->_cellCollection !== null) {
return $this->_cellCollection->getCellList(); return $this->_cellCollection->getCellList();
} }
return array(); return array();
@ -492,7 +494,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function sortCellCollection() public function sortCellCollection()
{ {
if ($this->_cellCollection !== NULL) { if ($this->_cellCollection !== null) {
return $this->_cellCollection->getSortedCellList(); return $this->_cellCollection->getSortedCellList();
} }
return array(); return array();
@ -725,7 +727,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// There is only something to do if there are some auto-size columns // There is only something to do if there are some auto-size columns
if (!empty($autoSizes)) { if (!empty($autoSizes)) {
// build list of cells references that participate in a merge // build list of cells references that participate in a merge
$isMergeCell = array(); $isMergeCell = array();
foreach ($this->getMergeCells() as $cells) { foreach ($this->getMergeCells() as $cells) {
@ -762,7 +763,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
// adjust column widths // adjust column widths
foreach ($autoSizes as $columnIndex => $width) { foreach ($autoSizes as $columnIndex => $width) {
if ($width == -1) $width = $this->getDefaultColumnDimension()->getWidth(); if ($width == -1) {
$width = $this->getDefaultColumnDimension()->getWidth();
}
$this->getColumnDimension($columnIndex)->setWidth($width); $this->getColumnDimension($columnIndex)->setWidth($width);
} }
} }
@ -775,7 +778,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel * @return PHPExcel
*/ */
public function getParent() { public function getParent()
{
return $this->_parent; return $this->_parent;
} }
@ -785,7 +789,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param PHPExcel $parent * @param PHPExcel $parent
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function rebindParent(PHPExcel $parent) { public function rebindParent(PHPExcel $parent)
{
if ($this->_parent !== null) { if ($this->_parent !== null) {
$namedRanges = $this->_parent->getNamedRanges(); $namedRanges = $this->_parent->getNamedRanges();
foreach ($namedRanges as $namedRange) { foreach ($namedRanges as $namedRange) {
@ -871,9 +876,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$newTitle = $this->getTitle(); $newTitle = $this->getTitle();
PHPExcel_Calculation::getInstance($this->_parent) PHPExcel_Calculation::getInstance($this->_parent)
->renameCalculationCacheForWorksheet($oldTitle, $newTitle); ->renameCalculationCacheForWorksheet($oldTitle, $newTitle);
if ($updateFormulaCellReferences) if ($updateFormulaCellReferences) {
PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle); PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_parent, $oldTitle, $newTitle);
} }
}
return $this; return $this;
} }
@ -883,7 +889,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return string Sheet state (visible, hidden, veryHidden) * @return string Sheet state (visible, hidden, veryHidden)
*/ */
public function getSheetState() { public function getSheetState()
{
return $this->_sheetState; return $this->_sheetState;
} }
@ -893,7 +900,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $value Sheet state (visible, hidden, veryHidden) * @param string $value Sheet state (visible, hidden, veryHidden)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE) { public function setSheetState($value = PHPExcel_Worksheet::SHEETSTATE_VISIBLE)
{
$this->_sheetState = $value; $this->_sheetState = $value;
return $this; return $this;
} }
@ -1159,7 +1167,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== NULL) { if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange(); $pCoordinate = $namedRange->getRange();
return $namedRange->getWorksheet()->getCell($pCoordinate); return $namedRange->getWorksheet()->getCell($pCoordinate);
} }
@ -1207,29 +1215,26 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{ {
$cell = $this->_cellCollection->addCacheData( $cell = $this->_cellCollection->addCacheData(
$pCoordinate, $pCoordinate,
new PHPExcel_Cell( new PHPExcel_Cell(null, PHPExcel_Cell_DataType::TYPE_NULL, $this)
NULL,
PHPExcel_Cell_DataType::TYPE_NULL,
$this
)
); );
$this->_cellCollectionIsSorted = false; $this->_cellCollectionIsSorted = false;
// Coordinates // Coordinates
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate); $aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0])) {
$this->_cachedHighestColumn = $aCoordinates[0]; $this->_cachedHighestColumn = $aCoordinates[0];
}
$this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]); $this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
// Cell needs appropriate xfIndex from dimensions records // Cell needs appropriate xfIndex from dimensions records
// but don't create dimension records if they don't already exist // but don't create dimension records if they don't already exist
$rowDimension = $this->getRowDimension($aCoordinates[1], FALSE); $rowDimension = $this->getRowDimension($aCoordinates[1], false);
$columnDimension = $this->getColumnDimension($aCoordinates[0], FALSE); $columnDimension = $this->getColumnDimension($aCoordinates[0], false);
if ($rowDimension !== NULL && $rowDimension->getXfIndex() > 0) { if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
// then there is a row dimension with explicit style, assign it to the cell // then there is a row dimension with explicit style, assign it to the cell
$cell->setXfIndex($rowDimension->getXfIndex()); $cell->setXfIndex($rowDimension->getXfIndex());
} elseif ($columnDimension !== NULL && $columnDimension->getXfIndex() > 0) { } elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) {
// then there is a column dimension, assign it to the cell // then there is a column dimension, assign it to the cell
$cell->setXfIndex($columnDimension->getXfIndex()); $cell->setXfIndex($columnDimension->getXfIndex());
} }
@ -1256,7 +1261,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) && if ((!preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF.'$/i', $pCoordinate, $matches)) &&
(preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) { (preg_match('/^'.PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $pCoordinate, $matches))) {
$namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this); $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== NULL) { if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange(); $pCoordinate = $namedRange->getRange();
if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) { if ($this->getHashCode() != $namedRange->getWorksheet()->getHashCode()) {
if (!$namedRange->getLocalOnly()) { if (!$namedRange->getLocalOnly()) {
@ -1265,8 +1270,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle()); throw new PHPExcel_Exception('Named range ' . $namedRange->getName() . ' is not accessible from within sheet ' . $this->getTitle());
} }
} }
} else {
return false;
} }
else { return false; }
} }
// Uppercase coordinate // Uppercase coordinate
@ -1303,15 +1309,16 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param int $pRow Numeric index of the row * @param int $pRow Numeric index of the row
* @return PHPExcel_Worksheet_RowDimension * @return PHPExcel_Worksheet_RowDimension
*/ */
public function getRowDimension($pRow = 1, $create = TRUE) public function getRowDimension($pRow = 1, $create = true)
{ {
// Found // Found
$found = null; $found = null;
// Get row dimension // Get row dimension
if (!isset($this->_rowDimensions[$pRow])) { if (!isset($this->_rowDimensions[$pRow])) {
if (!$create) if (!$create) {
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);
@ -1325,20 +1332,22 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $pColumn String index of the column * @param string $pColumn String index of the column
* @return PHPExcel_Worksheet_ColumnDimension * @return PHPExcel_Worksheet_ColumnDimension
*/ */
public function getColumnDimension($pColumn = 'A', $create = TRUE) public function getColumnDimension($pColumn = 'A', $create = true)
{ {
// Uppercase coordinate // Uppercase coordinate
$pColumn = strtoupper($pColumn); $pColumn = strtoupper($pColumn);
// Fetch dimensions // Fetch dimensions
if (!isset($this->_columnDimensions[$pColumn])) { if (!isset($this->_columnDimensions[$pColumn])) {
if (!$create) if (!$create) {
return NULL; return null;
}
$this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn); $this->_columnDimensions[$pColumn] = new PHPExcel_Worksheet_ColumnDimension($pColumn);
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($pColumn)) {
$this->_cachedHighestColumn = $pColumn; $this->_cachedHighestColumn = $pColumn;
} }
}
return $this->_columnDimensions[$pColumn]; return $this->_columnDimensions[$pColumn];
} }
@ -1488,8 +1497,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null) public function getStyleByColumnAndRow($pColumn = 0, $pRow = 1, $pColumn2 = null, $pRow2 = null)
{ {
if (!is_null($pColumn2) && !is_null($pRow2)) { if (!is_null($pColumn2) && !is_null($pRow2)) {
$cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . $cellRange = PHPExcel_Cell::stringFromColumnIndex($pColumn) . $pRow . ':' . PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
PHPExcel_Cell::stringFromColumnIndex($pColumn2) . $pRow2;
return $this->getStyle($cellRange); return $this->getStyle($cellRange);
} }
@ -1699,7 +1707,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
for ($i = 1; $i < $count; $i++) { for ($i = 1; $i < $count; $i++) {
$this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL); $this->getCell($aReferences[$i])->setValueExplicit(null, PHPExcel_Cell_DataType::TYPE_NULL);
} }
} else { } else {
throw new PHPExcel_Exception('Merge must be set on a range of cells.'); throw new PHPExcel_Exception('Merge must be set on a range of cells.');
} }
@ -1783,7 +1790,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setMergeCells($pValue = array()) public function setMergeCells($pValue = array())
{ {
$this->_mergeCells = $pValue; $this->_mergeCells = $pValue;
return $this; return $this;
} }
@ -1896,7 +1902,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
public function setAutoFilter($pValue) public function setAutoFilter($pValue)
{ {
$pRange = strtoupper($pValue); $pRange = strtoupper($pValue);
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)) {
@ -1931,7 +1936,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function removeAutoFilter() public function removeAutoFilter()
{ {
$this->_autoFilter->setRange(NULL); $this->_autoFilter->setRange(null);
return $this; return $this;
} }
@ -1961,7 +1966,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
{ {
// Uppercase coordinate // Uppercase coordinate
$pCell = strtoupper($pCell); $pCell = strtoupper($pCell);
if (strpos($pCell, ':') === false && strpos($pCell, ',') === false) { if (strpos($pCell, ':') === false && strpos($pCell, ',') === false) {
$this->_freezePane = $pCell; $this->_freezePane = $pCell;
} else { } else {
@ -2001,7 +2005,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function insertNewRowBefore($pBefore = 1, $pNumRows = 1) { public function insertNewRowBefore($pBefore = 1, $pNumRows = 1)
{
if ($pBefore >= 1) { if ($pBefore >= 1) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this); $objReferenceHelper->insertNewBefore('A' . $pBefore, 0, $pNumRows, $this);
@ -2019,7 +2024,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1) { public function insertNewColumnBefore($pBefore = 'A', $pNumCols = 1)
{
if (!is_numeric($pBefore)) { if (!is_numeric($pBefore)) {
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this); $objReferenceHelper->insertNewBefore($pBefore . '1', $pNumCols, 0, $this);
@ -2037,7 +2043,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1) { public function insertNewColumnBeforeByIndex($pBefore = 0, $pNumCols = 1)
{
if ($pBefore >= 0) { if ($pBefore >= 0) {
return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols); return $this->insertNewColumnBefore(PHPExcel_Cell::stringFromColumnIndex($pBefore), $pNumCols);
} else { } else {
@ -2053,7 +2060,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function removeRow($pRow = 1, $pNumRows = 1) { public function removeRow($pRow = 1, $pNumRows = 1)
{
if ($pRow >= 1) { if ($pRow >= 1) {
$highestRow = $this->getHighestDataRow(); $highestRow = $this->getHighestDataRow();
$objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance();
@ -2076,7 +2084,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function removeColumn($pColumn = 'A', $pNumCols = 1) { public function removeColumn($pColumn = 'A', $pNumCols = 1)
{
if (!is_numeric($pColumn)) { if (!is_numeric($pColumn)) {
$highestColumn = $this->getHighestDataColumn(); $highestColumn = $this->getHighestDataColumn();
$pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols); $pColumn = PHPExcel_Cell::stringFromColumnIndex(PHPExcel_Cell::columnIndexFromString($pColumn) - 1 + $pNumCols);
@ -2100,7 +2109,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function removeColumnByIndex($pColumn = 0, $pNumCols = 1) { public function removeColumnByIndex($pColumn = 0, $pNumCols = 1)
{
if ($pColumn >= 0) { if ($pColumn >= 0) {
return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols); return $this->removeColumn(PHPExcel_Cell::stringFromColumnIndex($pColumn), $pNumCols);
} else { } else {
@ -2113,7 +2123,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowGridlines() { public function getShowGridlines()
{
return $this->_showGridlines; return $this->_showGridlines;
} }
@ -2123,7 +2134,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show gridlines (true/false) * @param boolean $pValue Show gridlines (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowGridlines($pValue = false) { public function setShowGridlines($pValue = false)
{
$this->_showGridlines = $pValue; $this->_showGridlines = $pValue;
return $this; return $this;
} }
@ -2133,7 +2145,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getPrintGridlines() { public function getPrintGridlines()
{
return $this->_printGridlines; return $this->_printGridlines;
} }
@ -2143,7 +2156,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Print gridlines (true/false) * @param boolean $pValue Print gridlines (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setPrintGridlines($pValue = false) { public function setPrintGridlines($pValue = false)
{
$this->_printGridlines = $pValue; $this->_printGridlines = $pValue;
return $this; return $this;
} }
@ -2153,7 +2167,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowRowColHeaders() { public function getShowRowColHeaders()
{
return $this->_showRowColHeaders; return $this->_showRowColHeaders;
} }
@ -2163,7 +2178,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show row and column headers (true/false) * @param boolean $pValue Show row and column headers (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowRowColHeaders($pValue = false) { public function setShowRowColHeaders($pValue = false)
{
$this->_showRowColHeaders = $pValue; $this->_showRowColHeaders = $pValue;
return $this; return $this;
} }
@ -2173,7 +2189,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowSummaryBelow() { public function getShowSummaryBelow()
{
return $this->_showSummaryBelow; return $this->_showSummaryBelow;
} }
@ -2183,7 +2200,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show summary below (true/false) * @param boolean $pValue Show summary below (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowSummaryBelow($pValue = true) { public function setShowSummaryBelow($pValue = true)
{
$this->_showSummaryBelow = $pValue; $this->_showSummaryBelow = $pValue;
return $this; return $this;
} }
@ -2193,7 +2211,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getShowSummaryRight() { public function getShowSummaryRight()
{
return $this->_showSummaryRight; return $this->_showSummaryRight;
} }
@ -2203,7 +2222,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $pValue Show summary right (true/false) * @param boolean $pValue Show summary right (true/false)
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setShowSummaryRight($pValue = true) { public function setShowSummaryRight($pValue = true)
{
$this->_showSummaryRight = $pValue; $this->_showSummaryRight = $pValue;
return $this; return $this;
} }
@ -2368,7 +2388,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return boolean * @return boolean
*/ */
public function getRightToLeft() { public function getRightToLeft()
{
return $this->_rightToLeft; return $this->_rightToLeft;
} }
@ -2378,7 +2399,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param boolean $value Right-to-left true/false * @param boolean $value Right-to-left true/false
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function setRightToLeft($value = false) { public function setRightToLeft($value = false)
{
$this->_rightToLeft = $value; $this->_rightToLeft = $value;
return $this; return $this;
} }
@ -2393,7 +2415,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) { public function fromArray($source = null, $nullValue = null, $startCell = 'A1', $strictNullComparison = false)
{
if (is_array($source)) { if (is_array($source)) {
// Convert a 1-D array to 2-D (for ease of looping) // Convert a 1-D array to 2-D (for ease of looping)
if (!is_array(end($source))) { if (!is_array(end($source))) {
@ -2439,7 +2462,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* True - Return rows and columns indexed by their actual row and column IDs * True - Return rows and columns indexed by their actual row and column IDs
* @return array * @return array
*/ */
public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { public function rangeToArray($pRange = 'A1', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
// Returnvalue // Returnvalue
$returnValue = array(); $returnValue = array();
// Identify the range that we need to extract from the worksheet // Identify the range that we need to extract from the worksheet
@ -2478,9 +2502,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$style = $this->_parent->getCellXfByIndex($cell->getXfIndex()); $style = $this->_parent->getCellXfByIndex($cell->getXfIndex());
$returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString( $returnValue[$rRef][$cRef] = PHPExcel_Style_NumberFormat::toFormattedString(
$returnValue[$rRef][$cRef], $returnValue[$rRef][$cRef],
($style && $style->getNumberFormat()) ? ($style && $style->getNumberFormat()) ? $style->getNumberFormat()->getFormatCode() : PHPExcel_Style_NumberFormat::FORMAT_GENERAL
$style->getNumberFormat()->getFormatCode() :
PHPExcel_Style_NumberFormat::FORMAT_GENERAL
); );
} }
} else { } else {
@ -2511,14 +2533,14 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @return array * @return array
* @throws PHPExcel_Exception * @throws PHPExcel_Exception
*/ */
public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { public function namedRangeToArray($pNamedRange = '', $nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
$namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this); $namedRange = PHPExcel_NamedRange::resolveRange($pNamedRange, $this);
if ($namedRange !== NULL) { if ($namedRange !== null) {
$pWorkSheet = $namedRange->getWorksheet(); $pWorkSheet = $namedRange->getWorksheet();
$pCellRange = $namedRange->getRange(); $pCellRange = $namedRange->getRange();
return $pWorkSheet->rangeToArray( $pCellRange, return $pWorkSheet->rangeToArray($pCellRange, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
} }
throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.'); throw new PHPExcel_Exception('Named Range '.$pNamedRange.' does not exist.');
@ -2535,7 +2557,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* True - Return rows and columns indexed by their actual row and column IDs * True - Return rows and columns indexed by their actual row and column IDs
* @return array * @return array
*/ */
public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false) { public function toArray($nullValue = null, $calculateFormulas = true, $formatData = true, $returnCellRef = false)
{
// Garbage collect... // Garbage collect...
$this->garbageCollect(); $this->garbageCollect();
@ -2543,8 +2566,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
$maxCol = $this->getHighestColumn(); $maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow(); $maxRow = $this->getHighestRow();
// Return // Return
return $this->rangeToArray( 'A1:'.$maxCol.$maxRow, return $this->rangeToArray('A1:'.$maxCol.$maxRow, $nullValue, $calculateFormulas, $formatData, $returnCellRef);
$nullValue, $calculateFormulas, $formatData, $returnCellRef);
} }
/** /**
@ -2555,7 +2577,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet_RowIterator * @return PHPExcel_Worksheet_RowIterator
*/ */
public function getRowIterator($startRow = 1, $endRow = null) { public function getRowIterator($startRow = 1, $endRow = null)
{
return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow); return new PHPExcel_Worksheet_RowIterator($this, $startRow, $endRow);
} }
@ -2567,7 +2590,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet_ColumnIterator * @return PHPExcel_Worksheet_ColumnIterator
*/ */
public function getColumnIterator($startColumn = 'A', $endColumn = null) { public function getColumnIterator($startColumn = 'A', $endColumn = null)
{
return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn); return new PHPExcel_Worksheet_ColumnIterator($this, $startColumn, $endColumn);
} }
@ -2576,7 +2600,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function garbageCollect() { public function garbageCollect()
{
// Flush cache // Flush cache
$this->_cellCollection->getCacheData('A1'); $this->_cellCollection->getCacheData('A1');
// Build a reference table from images // Build a reference table from images
@ -2620,13 +2645,10 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return string Hash code * @return string Hash code
*/ */
public function getHashCode() { public function getHashCode()
{
if ($this->_dirty) { if ($this->_dirty) {
$this->_hash = md5( $this->_title . $this->_hash = md5($this->_title . $this->_autoFilter . ($this->_protection->isProtectionEnabled() ? 't' : 'f') . __CLASS__);
$this->_autoFilter .
($this->_protection->isProtectionEnabled() ? 't' : 'f') .
__CLASS__
);
$this->_dirty = false; $this->_dirty = false;
} }
return $this->_hash; return $this->_hash;
@ -2642,17 +2664,15 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param bool $returnRange Return range? (see example) * @param bool $returnRange Return range? (see example)
* @return mixed * @return mixed
*/ */
public static function extractSheetTitle($pRange, $returnRange = false) { public static function extractSheetTitle($pRange, $returnRange = false)
{
// Sheet title included? // Sheet title included?
if (($sep = strpos($pRange, '!')) === false) { if (($sep = strpos($pRange, '!')) === false) {
return ''; return '';
} }
if ($returnRange) { if ($returnRange) {
return array( return array(trim(substr($pRange, 0, $sep), "'"), substr($pRange, $sep + 1));
trim(substr($pRange, 0, $sep),"'"),
substr($pRange, $sep + 1)
);
} }
return substr($pRange, $sep + 1); return substr($pRange, $sep + 1);
@ -2774,7 +2794,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* @param string $range * @param string $range
* @return string Adjusted range value * @return string Adjusted range value
*/ */
public function shrinkRangeToFit($range) { public function shrinkRangeToFit($range)
{
$maxCol = $this->getHighestColumn(); $maxCol = $this->getHighestColumn();
$maxRow = $this->getHighestRow(); $maxRow = $this->getHighestRow();
$maxCol = PHPExcel_Cell::columnIndexFromString($maxCol); $maxCol = PHPExcel_Cell::columnIndexFromString($maxCol);
@ -2783,10 +2804,18 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
foreach ($rangeBlocks as &$rangeSet) { foreach ($rangeBlocks as &$rangeSet) {
$rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet); $rangeBoundaries = PHPExcel_Cell::getRangeBoundaries($rangeSet);
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) { $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) {
if ($rangeBoundaries[0][1] > $maxRow) { $rangeBoundaries[0][1] = $maxRow; } $rangeBoundaries[0][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol);
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) { $rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol); } }
if ($rangeBoundaries[1][1] > $maxRow) { $rangeBoundaries[1][1] = $maxRow; } if ($rangeBoundaries[0][1] > $maxRow) {
$rangeBoundaries[0][1] = $maxRow;
}
if (PHPExcel_Cell::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) {
$rangeBoundaries[1][0] = PHPExcel_Cell::stringFromColumnIndex($maxCol);
}
if ($rangeBoundaries[1][1] > $maxRow) {
$rangeBoundaries[1][1] = $maxRow;
}
$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);
@ -2802,9 +2831,9 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function getTabColor() public function getTabColor()
{ {
if ($this->_tabColor === NULL) if ($this->_tabColor === null) {
$this->_tabColor = new PHPExcel_Style_Color(); $this->_tabColor = new PHPExcel_Style_Color();
}
return $this->_tabColor; return $this->_tabColor;
} }
@ -2828,7 +2857,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
*/ */
public function isTabColorSet() public function isTabColorSet()
{ {
return ($this->_tabColor !== NULL); return ($this->_tabColor !== null);
} }
/** /**
@ -2836,7 +2865,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
* *
* @return PHPExcel_Worksheet * @return PHPExcel_Worksheet
*/ */
public function copy() { public function copy()
{
$copied = clone $this; $copied = clone $this;
return $copied; return $copied;
@ -2845,7 +2875,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
/** /**
* Implement PHP __clone to create a deep clone, not just a shallow copy. * Implement PHP __clone to create a deep clone, not just a shallow copy.
*/ */
public function __clone() { public function __clone()
{
foreach ($this as $key => $val) { foreach ($this as $key => $val) {
if ($key == '_parent') { if ($key == '_parent') {
continue; continue;
@ -2876,7 +2907,8 @@ 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;
@ -2924,14 +2956,16 @@ 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

@ -620,8 +620,9 @@ class PHPExcel_Worksheet_AutoFilter
// Test if we want to include blanks in our filter criteria // Test if we want to include blanks in our filter criteria
$blanks = false; $blanks = false;
$ruleDataSet = array_filter($ruleValues); $ruleDataSet = array_filter($ruleValues);
if (count($ruleValues) != count($ruleDataSet)) if (count($ruleValues) != count($ruleDataSet)) {
$blanks = true; $blanks = true;
}
if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) { if ($ruleType == PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_FILTER) {
// Filter on absolute values // Filter on absolute values
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
@ -638,23 +639,29 @@ class PHPExcel_Worksheet_AutoFilter
foreach ($ruleDataSet as $ruleValue) { foreach ($ruleDataSet as $ruleValue) {
$date = $time = ''; $date = $time = '';
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) {
$date .= sprintf('%04d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]); $date .= sprintf('%04d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) {
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]); $date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) {
$date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]); $date .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) {
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) {
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]);
}
if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) && if ((isset($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) &&
($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) ($ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) {
$time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]); $time .= sprintf('%02d', $ruleValue[PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]);
}
$dateTime = $date . $time; $dateTime = $date . $time;
$arguments['date'][] = $date; $arguments['date'][] = $date;
$arguments['time'][] = $time; $arguments['time'][] = $time;
@ -727,7 +734,7 @@ class PHPExcel_Worksheet_AutoFilter
--$period; --$period;
$periodEnd = (1+$period)*3; $periodEnd = (1+$period)*3;
$periodStart = 1+$period*3; $periodStart = 1+$period*3;
$ruleValues = range($periodStart,periodEnd); $ruleValues = range($periodStart, $periodEnd);
} }
$columnFilterTests[$columnID] = array( $columnFilterTests[$columnID] = array(
'method' => '_filterTestInPeriodDateSet', 'method' => '_filterTestInPeriodDateSet',
@ -754,8 +761,12 @@ class PHPExcel_Worksheet_AutoFilter
if ($ruleOperator === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) { if ($ruleOperator === PHPExcel_Worksheet_AutoFilter_Column_Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) {
$ruleValue = floor($ruleValue * ($dataRowCount / 100)); $ruleValue = floor($ruleValue * ($dataRowCount / 100));
} }
if ($ruleValue < 1) $ruleValue = 1; if ($ruleValue < 1) {
if ($ruleValue > 500) $ruleValue = 500; $ruleValue = 1;
}
if ($ruleValue > 500) {
$ruleValue = 500;
}
$maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue); $maxVal = $this->_calculateTopTenValue($columnID, $rangeStart[1]+1, $rangeEnd[1], $toptenRuleType, $ruleValue);
@ -836,7 +847,8 @@ class PHPExcel_Worksheet_AutoFilter
* toString method replicates previous behavior by returning the range if object is * toString method replicates previous behavior by returning the range if object is
* referenced as a property of its parent. * referenced as a property of its parent.
*/ */
public function __toString() { public function __toString()
{
return (string) $this->_range; return (string) $this->_range;
} }
} }

View File

@ -366,7 +366,8 @@ class PHPExcel_Worksheet_PageSetup
* *
* @return boolean * @return boolean
*/ */
public function getFitToPage() { public function getFitToPage()
{
return $this->_fitToPage; return $this->_fitToPage;
} }