PSR12 code style

This commit is contained in:
Adrien Crivelli 2020-07-26 13:51:13 +09:00
parent 4739f8b2e7
commit 6a41381c1d
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
46 changed files with 566 additions and 313 deletions

View File

@ -157,8 +157,10 @@ $spreadsheet->getActiveSheet()->setCellValue('E23', 'Mode of both ranges:')
$helper->log('Calculated data'); $helper->log('Calculated data');
for ($col = 'B'; $col != 'G'; ++$col) { for ($col = 'B'; $col != 'G'; ++$col) {
for ($row = 14; $row <= 41; ++$row) { for ($row = 14; $row <= 41; ++$row) {
if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) && if (
($formula[0] == '=')) { (($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
($formula[0] == '=')
) {
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue()); $helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
} }
} }

View File

@ -22,8 +22,10 @@ Calculation::getInstance($spreadsheet)->cyclicFormulaCount = 15;
$helper->log('Calculated data'); $helper->log('Calculated data');
for ($row = 1; $row <= 2; ++$row) { for ($row = 1; $row <= 2; ++$row) {
for ($col = 'A'; $col != 'C'; ++$col) { for ($col = 'A'; $col != 'C'; ++$col) {
if ((($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) && if (
($formula[0] == '=')) { (($formula = $spreadsheet->getActiveSheet()->getCell($col . $row)->getValue()) !== null) &&
($formula[0] == '=')
) {
$helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue()); $helper->log('Value of ' . $col . $row . ' [' . $formula . ']: ' . $spreadsheet->getActiveSheet()->getCell($col . $row)->getCalculatedValue());
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
require __DIR__ . '/../Header.php'; require __DIR__ . '/../Header.php';

View File

@ -2754,9 +2754,11 @@ class Calculation
*/ */
public static function setArrayReturnType($returnType) public static function setArrayReturnType($returnType)
{ {
if (($returnType == self::RETURN_ARRAY_AS_VALUE) || if (
($returnType == self::RETURN_ARRAY_AS_VALUE) ||
($returnType == self::RETURN_ARRAY_AS_ERROR) || ($returnType == self::RETURN_ARRAY_AS_ERROR) ||
($returnType == self::RETURN_ARRAY_AS_ARRAY)) { ($returnType == self::RETURN_ARRAY_AS_ARRAY)
) {
self::$returnArrayAsType = $returnType; self::$returnArrayAsType = $returnType;
return true; return true;
@ -3856,10 +3858,12 @@ class Calculation
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal
return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
} elseif ((isset(self::$operators[$opCharacter]) || $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? } elseif ((isset(self::$operators[$opCharacter]) || $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
while ($stack->count() > 0 && while (
$stack->count() > 0 &&
($o2 = $stack->last()) && ($o2 = $stack->last()) &&
isset(self::$operators[$o2['value']]) && isset(self::$operators[$o2['value']]) &&
@(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])
) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
} }
@ -3960,7 +3964,8 @@ class Calculation
} }
++$index; ++$index;
} elseif ($opCharacter == ',') { // Is this the separator for function arguments? } elseif ($opCharacter == ',') { // Is this the separator for function arguments?
if (!empty($pendingStoreKey) && if (
!empty($pendingStoreKey) &&
$parenthesisDepthMap[$pendingStoreKey] == 0 $parenthesisDepthMap[$pendingStoreKey] == 0
) { ) {
// We must go to the IF next argument // We must go to the IF next argument
@ -4088,14 +4093,18 @@ class Calculation
if ($pCellParent !== null && $rangeSheetRef !== $pCellParent->getTitle()) { if ($pCellParent !== null && $rangeSheetRef !== $pCellParent->getTitle()) {
$refSheet = $pCellParent->getParent()->getSheetByName($rangeSheetRef); $refSheet = $pCellParent->getParent()->getSheetByName($rangeSheetRef);
} }
if ((is_int($startRowColRef)) && (ctype_digit($val)) && if (
($startRowColRef <= 1048576) && ($val <= 1048576)) { (is_int($startRowColRef)) && (ctype_digit($val)) &&
($startRowColRef <= 1048576) && ($val <= 1048576)
) {
// Row range // Row range
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
$output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef; $output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef;
$val = $rangeWS2 . $endRowColRef . $val; $val = $rangeWS2 . $endRowColRef . $val;
} elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) && } elseif (
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) { (ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)
) {
// Column range // Column range
$endRowColRef = ($refSheet !== null) ? $refSheet->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
$output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1'; $output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1';
@ -4168,16 +4177,20 @@ class Calculation
} }
// If we're expecting an operator, but only have a space between the previous and next operands (and both are // If we're expecting an operator, but only have a space between the previous and next operands (and both are
// Cell References) then we have an INTERSECTION operator // Cell References) then we have an INTERSECTION operator
if (($expectingOperator) && if (
($expectingOperator) &&
((preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && ((preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) &&
($output[count($output) - 1]['type'] == 'Cell Reference') || ($output[count($output) - 1]['type'] == 'Cell Reference') ||
(preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/miu', substr($formula, $index), $match)) && (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '.*/miu', substr($formula, $index), $match)) &&
($output[count($output) - 1]['type'] == 'Named Range' || $output[count($output) - 1]['type'] == 'Value') ($output[count($output) - 1]['type'] == 'Named Range' || $output[count($output) - 1]['type'] == 'Value')
)) { )
while ($stack->count() > 0 && ) {
while (
$stack->count() > 0 &&
($o2 = $stack->last()) && ($o2 = $stack->last()) &&
isset(self::$operators[$o2['value']]) && isset(self::$operators[$o2['value']]) &&
@(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])
) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
} }
$stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack
@ -4252,7 +4265,8 @@ class Calculation
$storeValue = end($wrappedItem); $storeValue = end($wrappedItem);
} }
if (isset($storeValue) if (
isset($storeValue)
&& ( && (
!$storeValueAsBool !$storeValueAsBool
|| Functions::isError($storeValue) || Functions::isError($storeValue)
@ -4286,7 +4300,8 @@ class Calculation
$wrappedItem = end($storeValue); $wrappedItem = end($storeValue);
$storeValue = end($wrappedItem); $storeValue = end($wrappedItem);
} }
if (isset($storeValue) if (
isset($storeValue)
&& ( && (
$storeValueAsBool $storeValueAsBool
|| Functions::isError($storeValue) || Functions::isError($storeValue)
@ -4623,9 +4638,11 @@ class Calculation
for ($i = 0; $i < $argCount; ++$i) { for ($i = 0; $i < $argCount; ++$i) {
$arg = $stack->pop(); $arg = $stack->pop();
$a = $argCount - $i - 1; $a = $argCount - $i - 1;
if (($passByReference) && if (
($passByReference) &&
(isset(self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])) && (isset(self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])) &&
(self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])) { (self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])
) {
if ($arg['reference'] === null) { if ($arg['reference'] === null) {
$args[] = $cellID; $args[] = $cellID;
if ($functionName != 'MKMATRIX') { if ($functionName != 'MKMATRIX') {
@ -4949,9 +4966,11 @@ class Calculation
$result = '#VALUE!'; $result = '#VALUE!';
} }
} else { } else {
if ((Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) && if (
(Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) &&
((is_string($operand1) && !is_numeric($operand1) && strlen($operand1) > 0) || ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1) > 0) ||
(is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0))) { (is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0))
) {
$result = Functions::VALUE(); $result = Functions::VALUE();
} else { } else {
// If we're dealing with non-matrix operations, execute the necessary operation // If we're dealing with non-matrix operations, execute the necessary operation

View File

@ -274,9 +274,11 @@ class DateTime
$year = ($year !== null) ? StringHelper::testStringAsNumeric($year) : 0; $year = ($year !== null) ? StringHelper::testStringAsNumeric($year) : 0;
$month = ($month !== null) ? StringHelper::testStringAsNumeric($month) : 0; $month = ($month !== null) ? StringHelper::testStringAsNumeric($month) : 0;
$day = ($day !== null) ? StringHelper::testStringAsNumeric($day) : 0; $day = ($day !== null) ? StringHelper::testStringAsNumeric($day) : 0;
if ((!is_numeric($year)) || if (
(!is_numeric($year)) ||
(!is_numeric($month)) || (!is_numeric($month)) ||
(!is_numeric($day))) { (!is_numeric($day))
) {
return Functions::VALUE(); return Functions::VALUE();
} }
$year = (int) $year; $year = (int) $year;

View File

@ -1674,7 +1674,8 @@ class Engineering
$imaginary = ($imaginary === null) ? 0.0 : Functions::flattenSingleValue($imaginary); $imaginary = ($imaginary === null) ? 0.0 : Functions::flattenSingleValue($imaginary);
$suffix = ($suffix === null) ? 'i' : Functions::flattenSingleValue($suffix); $suffix = ($suffix === null) ? 'i' : Functions::flattenSingleValue($suffix);
if (((is_numeric($realNumber)) && (is_numeric($imaginary))) && if (
((is_numeric($realNumber)) && (is_numeric($imaginary))) &&
(($suffix == 'i') || ($suffix == 'j') || ($suffix == '')) (($suffix == 'i') || ($suffix == 'j') || ($suffix == ''))
) { ) {
$complex = new Complex($realNumber, $imaginary, $suffix); $complex = new Complex($realNumber, $imaginary, $suffix);
@ -2729,11 +2730,13 @@ class Engineering
} }
return $value; return $value;
} elseif ((($fromUOM == 'K') || ($fromUOM == 'kel')) && } elseif (
(($fromUOM == 'K') || ($fromUOM == 'kel')) &&
(($toUOM == 'K') || ($toUOM == 'kel')) (($toUOM == 'K') || ($toUOM == 'kel'))
) { ) {
return $value; return $value;
} elseif ((($fromUOM == 'C') || ($fromUOM == 'cel')) && } elseif (
(($fromUOM == 'C') || ($fromUOM == 'cel')) &&
(($toUOM == 'C') || ($toUOM == 'cel')) (($toUOM == 'C') || ($toUOM == 'cel'))
) { ) {
return $value; return $value;

View File

@ -395,9 +395,11 @@ class Financial
return Functions::VALUE(); return Functions::VALUE();
} }
if (($settlement >= $maturity) || if (
($settlement >= $maturity) ||
(!self::isValidFrequency($frequency)) || (!self::isValidFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) { (($basis < 0) || ($basis > 4))
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -452,9 +454,11 @@ class Financial
return Functions::VALUE(); return Functions::VALUE();
} }
if (($settlement >= $maturity) || if (
($settlement >= $maturity) ||
(!self::isValidFrequency($frequency)) || (!self::isValidFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) { (($basis < 0) || ($basis > 4))
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -520,9 +524,11 @@ class Financial
return Functions::VALUE(); return Functions::VALUE();
} }
if (($settlement >= $maturity) || if (
($settlement >= $maturity) ||
(!self::isValidFrequency($frequency)) || (!self::isValidFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) { (($basis < 0) || ($basis > 4))
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -574,9 +580,11 @@ class Financial
return Functions::VALUE(); return Functions::VALUE();
} }
if (($settlement >= $maturity) || if (
($settlement >= $maturity) ||
(!self::isValidFrequency($frequency)) || (!self::isValidFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) { (($basis < 0) || ($basis > 4))
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -625,9 +633,11 @@ class Financial
return Functions::VALUE(); return Functions::VALUE();
} }
if (($settlement >= $maturity) || if (
($settlement >= $maturity) ||
(!self::isValidFrequency($frequency)) || (!self::isValidFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) { (($basis < 0) || ($basis > 4))
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -678,9 +688,11 @@ class Financial
return Functions::VALUE(); return Functions::VALUE();
} }
if (($settlement >= $maturity) || if (
($settlement >= $maturity) ||
(!self::isValidFrequency($frequency)) || (!self::isValidFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) { (($basis < 0) || ($basis > 4))
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -1619,9 +1631,11 @@ class Financial
$frequency = (int) $frequency; $frequency = (int) $frequency;
$basis = (int) $basis; $basis = (int) $basis;
if (($settlement > $maturity) || if (
($settlement > $maturity) ||
(!self::isValidFrequency($frequency)) || (!self::isValidFrequency($frequency)) ||
(($basis < 0) || ($basis > 4))) { (($basis < 0) || ($basis > 4))
) {
return Functions::NAN(); return Functions::NAN();
} }

View File

@ -490,11 +490,13 @@ class FormulaParser
continue; continue;
} }
if (!( if (
!(
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND) ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
)) { )
) {
continue; continue;
} }
@ -502,11 +504,13 @@ class FormulaParser
continue; continue;
} }
if (!( if (
!(
(($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) || (($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) ||
(($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) || (($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && ($nextToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_START)) ||
($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND) ($nextToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
)) { )
) {
continue; continue;
} }
@ -538,12 +542,14 @@ class FormulaParser
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') { if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '-') {
if ($i == 0) { if ($i == 0) {
$token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX); $token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
} elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && } elseif (
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) || ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)) { ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
) {
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH); $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
} else { } else {
$token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX); $token->setTokenType(FormulaToken::TOKEN_TYPE_OPERATORPREFIX);
@ -557,12 +563,14 @@ class FormulaParser
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '+') { if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && $token->getValue() == '+') {
if ($i == 0) { if ($i == 0) {
continue; continue;
} elseif ((($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) && } elseif (
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_FUNCTION) &&
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
(($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) && (($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_SUBEXPRESSION) &&
($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) || ($previousToken->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_STOP)) ||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) || ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORPOSTFIX) ||
($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)) { ($previousToken->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND)
) {
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH); $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_MATH);
} else { } else {
continue; continue;
@ -573,8 +581,10 @@ class FormulaParser
continue; continue;
} }
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX && if (
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) { $token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERATORINFIX &&
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING
) {
if (strpos('<>=', substr($token->getValue(), 0, 1)) !== false) { if (strpos('<>=', substr($token->getValue(), 0, 1)) !== false) {
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL); $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL);
} elseif ($token->getValue() == '&') { } elseif ($token->getValue() == '&') {
@ -588,8 +598,10 @@ class FormulaParser
continue; continue;
} }
if ($token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND && if (
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING) { $token->getTokenType() == FormulaToken::TOKEN_TYPE_OPERAND &&
$token->getTokenSubType() == FormulaToken::TOKEN_SUBTYPE_NOTHING
) {
if (!is_numeric($token->getValue())) { if (!is_numeric($token->getValue())) {
if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue()) == 'FALSE') { if (strtoupper($token->getValue()) == 'TRUE' || strtoupper($token->getValue()) == 'FALSE') {
$token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL); $token->setTokenSubType(FormulaToken::TOKEN_SUBTYPE_LOGICAL);

View File

@ -67,7 +67,8 @@ class Functions
*/ */
public static function setCompatibilityMode($compatibilityMode) public static function setCompatibilityMode($compatibilityMode)
{ {
if (($compatibilityMode == self::COMPATIBILITY_EXCEL) || if (
($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
($compatibilityMode == self::COMPATIBILITY_GNUMERIC) || ($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
($compatibilityMode == self::COMPATIBILITY_OPENOFFICE) ($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)
) { ) {
@ -106,7 +107,8 @@ class Functions
*/ */
public static function setReturnDateType($returnDateType) public static function setReturnDateType($returnDateType)
{ {
if (($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) || if (
($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) ||
($returnDateType == self::RETURNDATE_PHP_DATETIME_OBJECT) || ($returnDateType == self::RETURNDATE_PHP_DATETIME_OBJECT) ||
($returnDateType == self::RETURNDATE_EXCEL) ($returnDateType == self::RETURNDATE_EXCEL)
) { ) {

View File

@ -286,8 +286,10 @@ class LookupRef
[$cellAddress1, $cellAddress2] = explode(':', $cellAddress); [$cellAddress1, $cellAddress2] = explode(':', $cellAddress);
} }
if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) || if (
(($cellAddress2 !== null) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))) { (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress1, $matches)) ||
(($cellAddress2 !== null) && (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $cellAddress2, $matches)))
) {
if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) { if (!preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $cellAddress1, $matches)) {
return Functions::REF(); return Functions::REF();
} }
@ -495,7 +497,8 @@ class LookupRef
// Lookup_array should contain only number, text, or logical values, or empty (null) cells // Lookup_array should contain only number, text, or logical values, or empty (null) cells
foreach ($lookupArray as $i => $lookupArrayValue) { foreach ($lookupArray as $i => $lookupArrayValue) {
// check the type of the value // check the type of the value
if ((!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) && if (
(!is_numeric($lookupArrayValue)) && (!is_string($lookupArrayValue)) &&
(!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null) (!is_bool($lookupArrayValue)) && ($lookupArrayValue !== null)
) { ) {
return Functions::NA(); return Functions::NA();
@ -750,18 +753,23 @@ class LookupRef
$firstLower = StringHelper::strToLower($rowData[$firstColumn]); $firstLower = StringHelper::strToLower($rowData[$firstColumn]);
// break if we have passed possible keys // break if we have passed possible keys
if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) || if (
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower))) { (is_numeric($lookup_value) && is_numeric($rowData[$firstColumn]) && ($rowData[$firstColumn] > $lookup_value)) ||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]) && ($firstLower > $lookupLower))
) {
break; break;
} }
// remember the last key, but only if datatypes match // remember the last key, but only if datatypes match
if ((is_numeric($lookup_value) && is_numeric($rowData[$firstColumn])) || if (
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]))) { (is_numeric($lookup_value) && is_numeric($rowData[$firstColumn])) ||
(!is_numeric($lookup_value) && !is_numeric($rowData[$firstColumn]))
) {
if ($not_exact_match) { if ($not_exact_match) {
$rowNumber = $rowKey; $rowNumber = $rowKey;
continue; continue;
} elseif (($firstLower == $lookupLower) } elseif (
($firstLower == $lookupLower)
// Spreadsheets software returns first exact match, // Spreadsheets software returns first exact match,
// we have sorted and we might have broken key orders // we have sorted and we might have broken key orders
// we want the first one (by its initial index) // we want the first one (by its initial index)
@ -823,10 +831,12 @@ class LookupRef
$lookupLower = StringHelper::strToLower($lookup_value); $lookupLower = StringHelper::strToLower($lookup_value);
$rowDataLower = StringHelper::strToLower($rowData); $rowDataLower = StringHelper::strToLower($rowData);
if ($not_exact_match && ( if (
$not_exact_match && (
($bothNumeric && $rowData > $lookup_value) || ($bothNumeric && $rowData > $lookup_value) ||
($bothNotNumeric && $rowDataLower > $lookupLower) ($bothNotNumeric && $rowDataLower > $lookupLower)
)) { )
) {
break; break;
} }
@ -836,7 +846,8 @@ class LookupRef
$rowNumber = $rowKey; $rowNumber = $rowKey;
continue; continue;
} elseif ($rowDataLower === $lookupLower } elseif (
$rowDataLower === $lookupLower
&& ($rowNumber === null || $rowKey < $rowNumber) && ($rowNumber === null || $rowKey < $rowNumber)
) { ) {
$rowNumber = $rowKey; $rowNumber = $rowKey;

View File

@ -147,8 +147,10 @@ class MathTrig
$xCoordinate = ($xCoordinate !== null) ? $xCoordinate : 0.0; $xCoordinate = ($xCoordinate !== null) ? $xCoordinate : 0.0;
$yCoordinate = ($yCoordinate !== null) ? $yCoordinate : 0.0; $yCoordinate = ($yCoordinate !== null) ? $yCoordinate : 0.0;
if (((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) && if (
((is_numeric($yCoordinate))) || (is_bool($yCoordinate))) { ((is_numeric($xCoordinate)) || (is_bool($xCoordinate))) &&
((is_numeric($yCoordinate))) || (is_bool($yCoordinate))
) {
$xCoordinate = (float) $xCoordinate; $xCoordinate = (float) $xCoordinate;
$yCoordinate = (float) $yCoordinate; $yCoordinate = (float) $yCoordinate;
@ -224,8 +226,10 @@ class MathTrig
$number = Functions::flattenSingleValue($number); $number = Functions::flattenSingleValue($number);
$significance = Functions::flattenSingleValue($significance); $significance = Functions::flattenSingleValue($significance);
if (($significance === null) && if (
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) { ($significance === null) &&
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)
) {
$significance = $number / abs($number); $significance = $number / abs($number);
} }
@ -331,8 +335,10 @@ class MathTrig
return Functions::NAN(); return Functions::NAN();
} }
$factLoop = floor($factVal); $factLoop = floor($factVal);
if ((Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) && if (
($factVal > $factLoop)) { (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC) &&
($factVal > $factLoop)
) {
return Functions::NAN(); return Functions::NAN();
} }
@ -398,8 +404,10 @@ class MathTrig
$number = Functions::flattenSingleValue($number); $number = Functions::flattenSingleValue($number);
$significance = Functions::flattenSingleValue($significance); $significance = Functions::flattenSingleValue($significance);
if (($significance === null) && if (
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)) { ($significance === null) &&
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_GNUMERIC)
) {
$significance = $number / abs($number); $significance = $number / abs($number);
} }
@ -1381,8 +1389,10 @@ class MathTrig
$testCondition = '=' . $arg . $condition; $testCondition = '=' . $arg . $condition;
$sumValue = array_key_exists($key, $sumArgs) ? $sumArgs[$key] : 0; $sumValue = array_key_exists($key, $sumArgs) ? $sumArgs[$key] : 0;
if (is_numeric($sumValue) && if (
Calculation::getInstance()->_calculateFormulaValue($testCondition)) { is_numeric($sumValue) &&
Calculation::getInstance()->_calculateFormulaValue($testCondition)
) {
// Is it a value within our criteria and only numeric can be added to the result // Is it a value within our criteria and only numeric can be added to the result
$returnValue += $sumValue; $returnValue += $sumValue;
} }
@ -1532,8 +1542,10 @@ class MathTrig
$result = 0; $result = 0;
for ($i = 0; $i < $count; ++$i) { for ($i = 0; $i < $count; ++$i) {
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && if (
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) { ((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
((is_numeric($array2[$i])) && (!is_string($array2[$i])))
) {
$result += ($array1[$i] * $array1[$i]) - ($array2[$i] * $array2[$i]); $result += ($array1[$i] * $array1[$i]) - ($array2[$i] * $array2[$i]);
} }
} }
@ -1557,8 +1569,10 @@ class MathTrig
$result = 0; $result = 0;
for ($i = 0; $i < $count; ++$i) { for ($i = 0; $i < $count; ++$i) {
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && if (
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) { ((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
((is_numeric($array2[$i])) && (!is_string($array2[$i])))
) {
$result += ($array1[$i] * $array1[$i]) + ($array2[$i] * $array2[$i]); $result += ($array1[$i] * $array1[$i]) + ($array2[$i] * $array2[$i]);
} }
} }
@ -1582,8 +1596,10 @@ class MathTrig
$result = 0; $result = 0;
for ($i = 0; $i < $count; ++$i) { for ($i = 0; $i < $count; ++$i) {
if (((is_numeric($array1[$i])) && (!is_string($array1[$i]))) && if (
((is_numeric($array2[$i])) && (!is_string($array2[$i])))) { ((is_numeric($array1[$i])) && (!is_string($array1[$i]))) &&
((is_numeric($array2[$i])) && (!is_string($array2[$i])))
) {
$result += ($array1[$i] - $array2[$i]) * ($array1[$i] - $array2[$i]); $result += ($array1[$i] - $array2[$i]) * ($array1[$i] - $array2[$i]);
} }
} }

View File

@ -530,9 +530,11 @@ class Statistical
*/ */
private static function testAcceptedBoolean($arg, $k) private static function testAcceptedBoolean($arg, $k)
{ {
if ((is_bool($arg)) && if (
(is_bool($arg)) &&
((!Functions::isCellValue($k) && (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_EXCEL)) || ((!Functions::isCellValue($k) && (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_EXCEL)) ||
(Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE))) { (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE))
) {
$arg = (int) $arg; $arg = (int) $arg;
} }
@ -547,9 +549,11 @@ class Statistical
*/ */
private static function isAcceptedCountable($arg, $k) private static function isAcceptedCountable($arg, $k)
{ {
if (((is_numeric($arg)) && (!is_string($arg))) || if (
((is_numeric($arg)) && (!is_string($arg))) ||
((is_numeric($arg)) && (!Functions::isCellValue($k)) && ((is_numeric($arg)) && (!Functions::isCellValue($k)) &&
(Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC))) { (Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC))
) {
return true; return true;
} }
@ -664,8 +668,10 @@ class Statistical
$aCount = 0; $aCount = 0;
// Loop through arguments // Loop through arguments
foreach (Functions::flattenArrayIndexed($args) as $k => $arg) { foreach (Functions::flattenArrayIndexed($args) as $k => $arg) {
if ((is_bool($arg)) && if (
(!Functions::isMatrixValue($k))) { (is_bool($arg)) &&
(!Functions::isMatrixValue($k))
) {
} else { } else {
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) { if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) && ($arg != '')))) {
if (is_bool($arg)) { if (is_bool($arg)) {
@ -1414,9 +1420,11 @@ class Statistical
$aCount = -1; $aCount = -1;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
// Is it a numeric value? // Is it a numeric value?
if ((is_bool($arg)) && if (
(is_bool($arg)) &&
((!Functions::isCellValue($k)) || ((!Functions::isCellValue($k)) ||
(Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))
) {
$arg = (int) $arg; $arg = (int) $arg;
} }
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
@ -1968,8 +1976,10 @@ class Statistical
$count = $summer = 0; $count = $summer = 0;
// Loop through arguments // Loop through arguments
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if (
(!Functions::isMatrixValue($k))) { (is_bool($arg)) &&
(!Functions::isMatrixValue($k))
) {
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
@ -3084,8 +3094,10 @@ class Statistical
$count = $summer = 0; $count = $summer = 0;
// Loop through arguments // Loop through arguments
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if (
(!Functions::isMatrixValue($k))) { (is_bool($arg)) &&
(!Functions::isMatrixValue($k))
) {
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) && (!is_string($arg))) { if ((is_numeric($arg)) && (!is_string($arg))) {
@ -3224,8 +3236,10 @@ class Statistical
if ($aMean !== null) { if ($aMean !== null) {
$aCount = -1; $aCount = -1;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if (
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { (is_bool($arg)) &&
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))
) {
$arg = (int) $arg; $arg = (int) $arg;
} }
// Is it a numeric value? // Is it a numeric value?
@ -3270,8 +3284,10 @@ class Statistical
if ($aMean !== null) { if ($aMean !== null) {
$aCount = -1; $aCount = -1;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if (
(!Functions::isMatrixValue($k))) { (is_bool($arg)) &&
(!Functions::isMatrixValue($k))
) {
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
@ -3320,8 +3336,10 @@ class Statistical
if ($aMean !== null) { if ($aMean !== null) {
$aCount = 0; $aCount = 0;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if (
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))) { (is_bool($arg)) &&
((!Functions::isCellValue($k)) || (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE))
) {
$arg = (int) $arg; $arg = (int) $arg;
} }
// Is it a numeric value? // Is it a numeric value?
@ -3365,8 +3383,10 @@ class Statistical
if ($aMean !== null) { if ($aMean !== null) {
$aCount = 0; $aCount = 0;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_bool($arg)) && if (
(!Functions::isMatrixValue($k))) { (is_bool($arg)) &&
(!Functions::isMatrixValue($k))
) {
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
@ -3686,11 +3706,15 @@ class Statistical
$aArgs = Functions::flattenArrayIndexed($args); $aArgs = Functions::flattenArrayIndexed($args);
$aCount = 0; $aCount = 0;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_string($arg)) && if (
(Functions::isValue($k))) { (is_string($arg)) &&
(Functions::isValue($k))
) {
return Functions::VALUE(); return Functions::VALUE();
} elseif ((is_string($arg)) && } elseif (
(!Functions::isMatrixValue($k))) { (is_string($arg)) &&
(!Functions::isMatrixValue($k))
) {
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {
@ -3780,11 +3804,15 @@ class Statistical
$aArgs = Functions::flattenArrayIndexed($args); $aArgs = Functions::flattenArrayIndexed($args);
$aCount = 0; $aCount = 0;
foreach ($aArgs as $k => $arg) { foreach ($aArgs as $k => $arg) {
if ((is_string($arg)) && if (
(Functions::isValue($k))) { (is_string($arg)) &&
(Functions::isValue($k))
) {
return Functions::VALUE(); return Functions::VALUE();
} elseif ((is_string($arg)) && } elseif (
(!Functions::isMatrixValue($k))) { (is_string($arg)) &&
(!Functions::isMatrixValue($k))
) {
} else { } else {
// Is it a numeric value? // Is it a numeric value?
if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) { if ((is_numeric($arg)) || (is_bool($arg)) || ((is_string($arg) & ($arg != '')))) {

View File

@ -457,11 +457,14 @@ class Properties
*/ */
public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null) public function setCustomProperty($propertyName, $propertyValue = '', $propertyType = null)
{ {
if (($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER, if (
self::PROPERTY_TYPE_FLOAT, ($propertyType === null) || (!in_array($propertyType, [self::PROPERTY_TYPE_INTEGER,
self::PROPERTY_TYPE_STRING, self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_DATE, self::PROPERTY_TYPE_STRING,
self::PROPERTY_TYPE_BOOLEAN, ]))) { self::PROPERTY_TYPE_DATE,
self::PROPERTY_TYPE_BOOLEAN,
]))
) {
if ($propertyValue === null) { if ($propertyValue === null) {
$propertyType = self::PROPERTY_TYPE_STRING; $propertyType = self::PROPERTY_TYPE_STRING;
} elseif (is_float($propertyValue)) { } elseif (is_float($propertyValue)) {

View File

@ -534,8 +534,10 @@ class Gnumeric extends BaseReader
foreach ($sheet->Styles->StyleRegion as $styleRegion) { foreach ($sheet->Styles->StyleRegion as $styleRegion) {
$styleAttributes = $styleRegion->attributes(); $styleAttributes = $styleRegion->attributes();
if (($styleAttributes['startRow'] <= $maxRow) && if (
($styleAttributes['startCol'] <= $maxCol)) { ($styleAttributes['startRow'] <= $maxRow) &&
($styleAttributes['startCol'] <= $maxCol)
) {
$startColumn = Coordinate::stringFromColumnIndex((int) $styleAttributes['startCol'] + 1); $startColumn = Coordinate::stringFromColumnIndex((int) $styleAttributes['startCol'] + 1);
$startRow = $styleAttributes['startRow'] + 1; $startRow = $styleAttributes['startRow'] + 1;

View File

@ -317,9 +317,11 @@ class Ods extends BaseReader
$worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name'); $worksheetName = $worksheetDataSet->getAttributeNS($tableNs, 'name');
// Check loadSheetsOnly // Check loadSheetsOnly
if (isset($this->loadSheetsOnly) if (
isset($this->loadSheetsOnly)
&& $worksheetName && $worksheetName
&& !in_array($worksheetName, $this->loadSheetsOnly)) { && !in_array($worksheetName, $this->loadSheetsOnly)
) {
continue; continue;
} }
@ -624,7 +626,8 @@ class Ods extends BaseReader
} }
// Merged cells // Merged cells
if ($cellData->hasAttributeNS($tableNs, 'number-columns-spanned') if (
$cellData->hasAttributeNS($tableNs, 'number-columns-spanned')
|| $cellData->hasAttributeNS($tableNs, 'number-rows-spanned') || $cellData->hasAttributeNS($tableNs, 'number-rows-spanned')
) { ) {
if (($type !== DataType::TYPE_NULL) || (!$this->readDataOnly)) { if (($type !== DataType::TYPE_NULL) || (!$this->readDataOnly)) {

View File

@ -1275,8 +1275,10 @@ class Xls extends BaseReader
// Extract range // Extract range
if (strpos($definedName['formula'], '!') !== false) { if (strpos($definedName['formula'], '!') !== false) {
$explodes = Worksheet::extractSheetTitle($definedName['formula'], true); $explodes = Worksheet::extractSheetTitle($definedName['formula'], true);
if (($docSheet = $this->spreadsheet->getSheetByName($explodes[0])) || if (
($docSheet = $this->spreadsheet->getSheetByName(trim($explodes[0], "'")))) { ($docSheet = $this->spreadsheet->getSheetByName($explodes[0])) ||
($docSheet = $this->spreadsheet->getSheetByName(trim($explodes[0], "'")))
) {
$extractedRange = $explodes[1]; $extractedRange = $explodes[1];
$extractedRange = str_replace('$', '', $extractedRange); $extractedRange = str_replace('$', '', $extractedRange);
@ -3999,21 +4001,27 @@ class Xls extends BaseReader
// read STRING record // read STRING record
$value = $this->readString(); $value = $this->readString();
} elseif ((ord($recordData[6]) == 1) } elseif (
(ord($recordData[6]) == 1)
&& (ord($recordData[12]) == 255) && (ord($recordData[12]) == 255)
&& (ord($recordData[13]) == 255)) { && (ord($recordData[13]) == 255)
) {
// Boolean formula. Result is in +2; 0=false, 1=true // Boolean formula. Result is in +2; 0=false, 1=true
$dataType = DataType::TYPE_BOOL; $dataType = DataType::TYPE_BOOL;
$value = (bool) ord($recordData[8]); $value = (bool) ord($recordData[8]);
} elseif ((ord($recordData[6]) == 2) } elseif (
(ord($recordData[6]) == 2)
&& (ord($recordData[12]) == 255) && (ord($recordData[12]) == 255)
&& (ord($recordData[13]) == 255)) { && (ord($recordData[13]) == 255)
) {
// Error formula. Error code is in +2 // Error formula. Error code is in +2
$dataType = DataType::TYPE_ERROR; $dataType = DataType::TYPE_ERROR;
$value = Xls\ErrorCode::lookup(ord($recordData[8])); $value = Xls\ErrorCode::lookup(ord($recordData[8]));
} elseif ((ord($recordData[6]) == 3) } elseif (
(ord($recordData[6]) == 3)
&& (ord($recordData[12]) == 255) && (ord($recordData[12]) == 255)
&& (ord($recordData[13]) == 255)) { && (ord($recordData[13]) == 255)
) {
// Formula result is a null string // Formula result is a null string
$dataType = DataType::TYPE_NULL; $dataType = DataType::TYPE_NULL;
$value = ''; $value = '';
@ -4599,8 +4607,10 @@ class Xls extends BaseReader
if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) { if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) {
$cellRangeAddressList = $this->readBIFF8CellRangeAddressList($recordData); $cellRangeAddressList = $this->readBIFF8CellRangeAddressList($recordData);
foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) { foreach ($cellRangeAddressList['cellRangeAddresses'] as $cellRangeAddress) {
if ((strpos($cellRangeAddress, ':') !== false) && if (
($this->includeCellRangeFiltered($cellRangeAddress))) { (strpos($cellRangeAddress, ':') !== false) &&
($this->includeCellRangeFiltered($cellRangeAddress))
) {
$this->phpSheet->mergeCells($cellRangeAddress); $this->phpSheet->mergeCells($cellRangeAddress);
} }
} }

View File

@ -502,8 +502,10 @@ class Xlsx extends BaseReader
// We shouldn't override any of the built-in MS Excel values (values below id 164) // We shouldn't override any of the built-in MS Excel values (values below id 164)
// But there's a lot of naughty homebrew xlsx writers that do use "reserved" id values that aren't actually used // But there's a lot of naughty homebrew xlsx writers that do use "reserved" id values that aren't actually used
// So we make allowance for them rather than lose formatting masks // So we make allowance for them rather than lose formatting masks
if ((int) $xf['numFmtId'] < 164 && if (
NumberFormat::builtInFormatCode((int) $xf['numFmtId']) !== '') { (int) $xf['numFmtId'] < 164 &&
NumberFormat::builtInFormatCode((int) $xf['numFmtId']) !== ''
) {
$numFmt = NumberFormat::builtInFormatCode((int) $xf['numFmtId']); $numFmt = NumberFormat::builtInFormatCode((int) $xf['numFmtId']);
} }
} }
@ -1720,12 +1722,16 @@ class Xlsx extends BaseReader
if (isset($run->rPr->color)) { if (isset($run->rPr->color)) {
$objText->getFont()->setColor(new Color(self::readColor($run->rPr->color))); $objText->getFont()->setColor(new Color(self::readColor($run->rPr->color)));
} }
if ((isset($run->rPr->b['val']) && self::boolean((string) $run->rPr->b['val'])) || if (
(isset($run->rPr->b) && !isset($run->rPr->b['val']))) { (isset($run->rPr->b['val']) && self::boolean((string) $run->rPr->b['val'])) ||
(isset($run->rPr->b) && !isset($run->rPr->b['val']))
) {
$objText->getFont()->setBold(true); $objText->getFont()->setBold(true);
} }
if ((isset($run->rPr->i['val']) && self::boolean((string) $run->rPr->i['val'])) || if (
(isset($run->rPr->i) && !isset($run->rPr->i['val']))) { (isset($run->rPr->i['val']) && self::boolean((string) $run->rPr->i['val'])) ||
(isset($run->rPr->i) && !isset($run->rPr->i['val']))
) {
$objText->getFont()->setItalic(true); $objText->getFont()->setItalic(true);
} }
if (isset($run->rPr->vertAlign, $run->rPr->vertAlign['val'])) { if (isset($run->rPr->vertAlign, $run->rPr->vertAlign['val'])) {
@ -1742,8 +1748,10 @@ class Xlsx extends BaseReader
} elseif (isset($run->rPr->u, $run->rPr->u['val'])) { } elseif (isset($run->rPr->u, $run->rPr->u['val'])) {
$objText->getFont()->setUnderline((string) $run->rPr->u['val']); $objText->getFont()->setUnderline((string) $run->rPr->u['val']);
} }
if ((isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) || if (
(isset($run->rPr->strike) && !isset($run->rPr->strike['val']))) { (isset($run->rPr->strike['val']) && self::boolean((string) $run->rPr->strike['val'])) ||
(isset($run->rPr->strike) && !isset($run->rPr->strike['val']))
) {
$objText->getFont()->setStrikethrough(true); $objText->getFont()->setStrikethrough(true);
} }
} }

View File

@ -94,8 +94,10 @@ class ColumnAndRowAttributes extends BaseParserClass
// set columns/rows attributes // set columns/rows attributes
$columnsAttributesAreSet = []; $columnsAttributesAreSet = [];
foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) { foreach ($columnsAttributes as $columnCoordinate => $columnAttributes) {
if ($readFilter === null || if (
!$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)) { $readFilter === null ||
!$this->isFilteredColumn($readFilter, $columnCoordinate, $rowsAttributes)
) {
if (!isset($columnsAttributesAreSet[$columnCoordinate])) { if (!isset($columnsAttributesAreSet[$columnCoordinate])) {
$this->setColumnAttributes($columnCoordinate, $columnAttributes); $this->setColumnAttributes($columnCoordinate, $columnAttributes);
$columnsAttributesAreSet[$columnCoordinate] = true; $columnsAttributesAreSet[$columnCoordinate] = true;
@ -105,8 +107,10 @@ class ColumnAndRowAttributes extends BaseParserClass
$rowsAttributesAreSet = []; $rowsAttributesAreSet = [];
foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) { foreach ($rowsAttributes as $rowCoordinate => $rowAttributes) {
if ($readFilter === null || if (
!$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)) { $readFilter === null ||
!$this->isFilteredRow($readFilter, $rowCoordinate, $columnsAttributes)
) {
if (!isset($rowsAttributesAreSet[$rowCoordinate])) { if (!isset($rowsAttributesAreSet[$rowCoordinate])) {
$this->setRowAttributes($rowCoordinate, $rowAttributes); $this->setRowAttributes($rowCoordinate, $rowAttributes);
$rowsAttributesAreSet[$rowCoordinate] = true; $rowsAttributesAreSet[$rowCoordinate] = true;

View File

@ -34,13 +34,15 @@ class ConditionalStyles
$conditionals = []; $conditionals = [];
foreach ($xmlSheet->conditionalFormatting as $conditional) { foreach ($xmlSheet->conditionalFormatting as $conditional) {
foreach ($conditional->cfRule as $cfRule) { foreach ($conditional->cfRule as $cfRule) {
if (((string) $cfRule['type'] == Conditional::CONDITION_NONE if (
((string) $cfRule['type'] == Conditional::CONDITION_NONE
|| (string) $cfRule['type'] == Conditional::CONDITION_CELLIS || (string) $cfRule['type'] == Conditional::CONDITION_CELLIS
|| (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSTEXT
|| (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSBLANKS || (string) $cfRule['type'] == Conditional::CONDITION_CONTAINSBLANKS
|| (string) $cfRule['type'] == Conditional::CONDITION_NOTCONTAINSBLANKS || (string) $cfRule['type'] == Conditional::CONDITION_NOTCONTAINSBLANKS
|| (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION) || (string) $cfRule['type'] == Conditional::CONDITION_EXPRESSION)
&& isset($this->dxfs[(int) ($cfRule['dxfId'])])) { && isset($this->dxfs[(int) ($cfRule['dxfId'])])
) {
$conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule; $conditionals[(string) $conditional['sqref']][(int) ($cfRule['priority'])] = $cfRule;
} }
} }

View File

@ -65,8 +65,10 @@ class PageSetup extends BaseParserClass
if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) { if (isset($xmlSheet->pageSetup['fitToWidth']) && (int) ($xmlSheet->pageSetup['fitToWidth']) >= 0) {
$docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false); $docPageSetup->setFitToWidth((int) ($xmlSheet->pageSetup['fitToWidth']), false);
} }
if (isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) && if (
self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])) { isset($xmlSheet->pageSetup['firstPageNumber'], $xmlSheet->pageSetup['useFirstPageNumber']) &&
self::boolean((string) $xmlSheet->pageSetup['useFirstPageNumber'])
) {
$docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber'])); $docPageSetup->setFirstPageNumber((int) ($xmlSheet->pageSetup['firstPageNumber']));
} }
if (isset($xmlSheet->pageSetup['pageOrder'])) { if (isset($xmlSheet->pageSetup['pageOrder'])) {
@ -87,26 +89,34 @@ class PageSetup extends BaseParserClass
if ($xmlSheet->headerFooter) { if ($xmlSheet->headerFooter) {
$docHeaderFooter = $worksheet->getHeaderFooter(); $docHeaderFooter = $worksheet->getHeaderFooter();
if (isset($xmlSheet->headerFooter['differentOddEven']) && if (
self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])) { isset($xmlSheet->headerFooter['differentOddEven']) &&
self::boolean((string) $xmlSheet->headerFooter['differentOddEven'])
) {
$docHeaderFooter->setDifferentOddEven(true); $docHeaderFooter->setDifferentOddEven(true);
} else { } else {
$docHeaderFooter->setDifferentOddEven(false); $docHeaderFooter->setDifferentOddEven(false);
} }
if (isset($xmlSheet->headerFooter['differentFirst']) && if (
self::boolean((string) $xmlSheet->headerFooter['differentFirst'])) { isset($xmlSheet->headerFooter['differentFirst']) &&
self::boolean((string) $xmlSheet->headerFooter['differentFirst'])
) {
$docHeaderFooter->setDifferentFirst(true); $docHeaderFooter->setDifferentFirst(true);
} else { } else {
$docHeaderFooter->setDifferentFirst(false); $docHeaderFooter->setDifferentFirst(false);
} }
if (isset($xmlSheet->headerFooter['scaleWithDoc']) && if (
!self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])) { isset($xmlSheet->headerFooter['scaleWithDoc']) &&
!self::boolean((string) $xmlSheet->headerFooter['scaleWithDoc'])
) {
$docHeaderFooter->setScaleWithDocument(false); $docHeaderFooter->setScaleWithDocument(false);
} else { } else {
$docHeaderFooter->setScaleWithDocument(true); $docHeaderFooter->setScaleWithDocument(true);
} }
if (isset($xmlSheet->headerFooter['alignWithMargins']) && if (
!self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])) { isset($xmlSheet->headerFooter['alignWithMargins']) &&
!self::boolean((string) $xmlSheet->headerFooter['alignWithMargins'])
) {
$docHeaderFooter->setAlignWithMargins(false); $docHeaderFooter->setAlignWithMargins(false);
} else { } else {
$docHeaderFooter->setAlignWithMargins(true); $docHeaderFooter->setAlignWithMargins(true);

View File

@ -59,15 +59,19 @@ class SheetViewOptions extends BaseParserClass
private function outlines(SimpleXMLElement $sheetPr): void private function outlines(SimpleXMLElement $sheetPr): void
{ {
if (isset($sheetPr->outlinePr)) { if (isset($sheetPr->outlinePr)) {
if (isset($sheetPr->outlinePr['summaryRight']) && if (
!self::boolean((string) $sheetPr->outlinePr['summaryRight'])) { isset($sheetPr->outlinePr['summaryRight']) &&
!self::boolean((string) $sheetPr->outlinePr['summaryRight'])
) {
$this->worksheet->setShowSummaryRight(false); $this->worksheet->setShowSummaryRight(false);
} else { } else {
$this->worksheet->setShowSummaryRight(true); $this->worksheet->setShowSummaryRight(true);
} }
if (isset($sheetPr->outlinePr['summaryBelow']) && if (
!self::boolean((string) $sheetPr->outlinePr['summaryBelow'])) { isset($sheetPr->outlinePr['summaryBelow']) &&
!self::boolean((string) $sheetPr->outlinePr['summaryBelow'])
) {
$this->worksheet->setShowSummaryBelow(false); $this->worksheet->setShowSummaryBelow(false);
} else { } else {
$this->worksheet->setShowSummaryBelow(true); $this->worksheet->setShowSummaryBelow(true);
@ -78,8 +82,10 @@ class SheetViewOptions extends BaseParserClass
private function pageSetup(SimpleXMLElement $sheetPr): void private function pageSetup(SimpleXMLElement $sheetPr): void
{ {
if (isset($sheetPr->pageSetUpPr)) { if (isset($sheetPr->pageSetUpPr)) {
if (isset($sheetPr->pageSetUpPr['fitToPage']) && if (
!self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])) { isset($sheetPr->pageSetUpPr['fitToPage']) &&
!self::boolean((string) $sheetPr->pageSetUpPr['fitToPage'])
) {
$this->worksheet->getPageSetup()->setFitToPage(false); $this->worksheet->getPageSetup()->setFitToPage(false);
} else { } else {
$this->worksheet->getPageSetup()->setFitToPage(true); $this->worksheet->getPageSetup()->setFitToPage(true);
@ -89,9 +95,11 @@ class SheetViewOptions extends BaseParserClass
private function sheetFormat(SimpleXMLElement $sheetFormatPr): void private function sheetFormat(SimpleXMLElement $sheetFormatPr): void
{ {
if (isset($sheetFormatPr['customHeight']) && if (
isset($sheetFormatPr['customHeight']) &&
self::boolean((string) $sheetFormatPr['customHeight']) && self::boolean((string) $sheetFormatPr['customHeight']) &&
isset($sheetFormatPr['defaultRowHeight'])) { isset($sheetFormatPr['defaultRowHeight'])
) {
$this->worksheet->getDefaultRowDimension() $this->worksheet->getDefaultRowDimension()
->setRowHeight((float) $sheetFormatPr['defaultRowHeight']); ->setRowHeight((float) $sheetFormatPr['defaultRowHeight']);
} }
@ -101,8 +109,10 @@ class SheetViewOptions extends BaseParserClass
->setWidth((float) $sheetFormatPr['defaultColWidth']); ->setWidth((float) $sheetFormatPr['defaultColWidth']);
} }
if (isset($sheetFormatPr['zeroHeight']) && if (
((string) $sheetFormatPr['zeroHeight'] === '1')) { isset($sheetFormatPr['zeroHeight']) &&
((string) $sheetFormatPr['zeroHeight'] === '1')
) {
$this->worksheet->getDefaultRowDimension()->setZeroHeight(true); $this->worksheet->getDefaultRowDimension()->setZeroHeight(true);
} }
} }

View File

@ -400,8 +400,10 @@ class Xml extends BaseReader
foreach ($xml_ss->Worksheet as $worksheet) { foreach ($xml_ss->Worksheet as $worksheet) {
$worksheet_ss = $worksheet->attributes($namespaces['ss']); $worksheet_ss = $worksheet->attributes($namespaces['ss']);
if ((isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) && if (
(!in_array($worksheet_ss['Name'], $this->loadSheetsOnly))) { (isset($this->loadSheetsOnly)) && (isset($worksheet_ss['Name'])) &&
(!in_array($worksheet_ss['Name'], $this->loadSheetsOnly))
) {
continue; continue;
} }

View File

@ -129,13 +129,17 @@ class ReferenceHelper
[$cellColumn, $cellRow] = Coordinate::coordinateFromString($cellAddress); [$cellColumn, $cellRow] = Coordinate::coordinateFromString($cellAddress);
$cellColumnIndex = Coordinate::columnIndexFromString($cellColumn); $cellColumnIndex = Coordinate::columnIndexFromString($cellColumn);
// Is cell within the range of rows/columns if we're deleting // Is cell within the range of rows/columns if we're deleting
if ($pNumRows < 0 && if (
$pNumRows < 0 &&
($cellRow >= ($beforeRow + $pNumRows)) && ($cellRow >= ($beforeRow + $pNumRows)) &&
($cellRow < $beforeRow)) { ($cellRow < $beforeRow)
) {
return true; return true;
} elseif ($pNumCols < 0 && } elseif (
$pNumCols < 0 &&
($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) && ($cellColumnIndex >= ($beforeColumnIndex + $pNumCols)) &&
($cellColumnIndex < $beforeColumnIndex)) { ($cellColumnIndex < $beforeColumnIndex)
) {
return true; return true;
} }

View File

@ -71,8 +71,10 @@ class Date
*/ */
public static function setExcelCalendar($baseDate) public static function setExcelCalendar($baseDate)
{ {
if (($baseDate == self::CALENDAR_WINDOWS_1900) || if (
($baseDate == self::CALENDAR_MAC_1904)) { ($baseDate == self::CALENDAR_WINDOWS_1900) ||
($baseDate == self::CALENDAR_MAC_1904)
) {
self::$excelCalendar = $baseDate; self::$excelCalendar = $baseDate;
return true; return true;
@ -400,8 +402,10 @@ class Date
$segMatcher = false; $segMatcher = false;
foreach (explode('"', $pFormatCode) as $subVal) { foreach (explode('"', $pFormatCode) as $subVal) {
// Only test in alternate array entries (the non-quoted blocks) // Only test in alternate array entries (the non-quoted blocks)
if (($segMatcher = !$segMatcher) && if (
(preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $subVal))) { ($segMatcher = !$segMatcher) &&
(preg_match('/(^|\])[^\[]*[' . self::$possibleDateFormatCharacters . ']/i', $subVal))
) {
return true; return true;
} }
} }

View File

@ -553,8 +553,10 @@ class EigenvalueDecomposition
if ($m == $l) { if ($m == $l) {
break; break;
} }
if (abs($this->H[$m][$m - 1]) * (abs($q) + abs($r)) < if (
$eps * (abs($p) * (abs($this->H[$m - 1][$m - 1]) + abs($z) + abs($this->H[$m + 1][$m + 1])))) { abs($this->H[$m][$m - 1]) * (abs($q) + abs($r)) <
$eps * (abs($p) * (abs($this->H[$m - 1][$m - 1]) + abs($z) + abs($this->H[$m + 1][$m + 1])))
) {
break; break;
} }
--$m; --$m;

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Pythagorean Theorem:. * Pythagorean Theorem:.
* *

View File

@ -131,55 +131,55 @@ class OLE
throw new ReaderException('Only Little-Endian encoding is supported.'); throw new ReaderException('Only Little-Endian encoding is supported.');
} }
// Size of blocks and short blocks in bytes // Size of blocks and short blocks in bytes
$this->bigBlockSize = 2 ** self::_readInt2($fh); $this->bigBlockSize = 2 ** self::readInt2($fh);
$this->smallBlockSize = 2 ** self::_readInt2($fh); $this->smallBlockSize = 2 ** self::readInt2($fh);
// Skip UID, revision number and version number // Skip UID, revision number and version number
fseek($fh, 44); fseek($fh, 44);
// Number of blocks in Big Block Allocation Table // Number of blocks in Big Block Allocation Table
$bbatBlockCount = self::_readInt4($fh); $bbatBlockCount = self::readInt4($fh);
// Root chain 1st block // Root chain 1st block
$directoryFirstBlockId = self::_readInt4($fh); $directoryFirstBlockId = self::readInt4($fh);
// Skip unused bytes // Skip unused bytes
fseek($fh, 56); fseek($fh, 56);
// Streams shorter than this are stored using small blocks // Streams shorter than this are stored using small blocks
$this->bigBlockThreshold = self::_readInt4($fh); $this->bigBlockThreshold = self::readInt4($fh);
// Block id of first sector in Short Block Allocation Table // Block id of first sector in Short Block Allocation Table
$sbatFirstBlockId = self::_readInt4($fh); $sbatFirstBlockId = self::readInt4($fh);
// Number of blocks in Short Block Allocation Table // Number of blocks in Short Block Allocation Table
$sbbatBlockCount = self::_readInt4($fh); $sbbatBlockCount = self::readInt4($fh);
// Block id of first sector in Master Block Allocation Table // Block id of first sector in Master Block Allocation Table
$mbatFirstBlockId = self::_readInt4($fh); $mbatFirstBlockId = self::readInt4($fh);
// Number of blocks in Master Block Allocation Table // Number of blocks in Master Block Allocation Table
$mbbatBlockCount = self::_readInt4($fh); $mbbatBlockCount = self::readInt4($fh);
$this->bbat = []; $this->bbat = [];
// Remaining 4 * 109 bytes of current block is beginning of Master // Remaining 4 * 109 bytes of current block is beginning of Master
// Block Allocation Table // Block Allocation Table
$mbatBlocks = []; $mbatBlocks = [];
for ($i = 0; $i < 109; ++$i) { for ($i = 0; $i < 109; ++$i) {
$mbatBlocks[] = self::_readInt4($fh); $mbatBlocks[] = self::readInt4($fh);
} }
// Read rest of Master Block Allocation Table (if any is left) // Read rest of Master Block Allocation Table (if any is left)
$pos = $this->_getBlockOffset($mbatFirstBlockId); $pos = $this->getBlockOffset($mbatFirstBlockId);
for ($i = 0; $i < $mbbatBlockCount; ++$i) { for ($i = 0; $i < $mbbatBlockCount; ++$i) {
fseek($fh, $pos); fseek($fh, $pos);
for ($j = 0; $j < $this->bigBlockSize / 4 - 1; ++$j) { for ($j = 0; $j < $this->bigBlockSize / 4 - 1; ++$j) {
$mbatBlocks[] = self::_readInt4($fh); $mbatBlocks[] = self::readInt4($fh);
} }
// Last block id in each block points to next block // Last block id in each block points to next block
$pos = $this->_getBlockOffset(self::_readInt4($fh)); $pos = $this->getBlockOffset(self::readInt4($fh));
} }
// Read Big Block Allocation Table according to chain specified by $mbatBlocks // Read Big Block Allocation Table according to chain specified by $mbatBlocks
for ($i = 0; $i < $bbatBlockCount; ++$i) { for ($i = 0; $i < $bbatBlockCount; ++$i) {
$pos = $this->_getBlockOffset($mbatBlocks[$i]); $pos = $this->getBlockOffset($mbatBlocks[$i]);
fseek($fh, $pos); fseek($fh, $pos);
for ($j = 0; $j < $this->bigBlockSize / 4; ++$j) { for ($j = 0; $j < $this->bigBlockSize / 4; ++$j) {
$this->bbat[] = self::_readInt4($fh); $this->bbat[] = self::readInt4($fh);
} }
} }
@ -188,11 +188,11 @@ class OLE
$shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4; $shortBlockCount = $sbbatBlockCount * $this->bigBlockSize / 4;
$sbatFh = $this->getStream($sbatFirstBlockId); $sbatFh = $this->getStream($sbatFirstBlockId);
for ($blockId = 0; $blockId < $shortBlockCount; ++$blockId) { for ($blockId = 0; $blockId < $shortBlockCount; ++$blockId) {
$this->sbat[$blockId] = self::_readInt4($sbatFh); $this->sbat[$blockId] = self::readInt4($sbatFh);
} }
fclose($sbatFh); fclose($sbatFh);
$this->_readPpsWks($directoryFirstBlockId); $this->readPpsWks($directoryFirstBlockId);
return true; return true;
} }
@ -202,7 +202,7 @@ class OLE
* *
* @return int * @return int
*/ */
public function _getBlockOffset($blockId) public function getBlockOffset($blockId)
{ {
return 512 + $blockId * $this->bigBlockSize; return 512 + $blockId * $this->bigBlockSize;
} }
@ -247,7 +247,7 @@ class OLE
* *
* @return int * @return int
*/ */
private static function _readInt1($fh) private static function readInt1($fh)
{ {
[, $tmp] = unpack('c', fread($fh, 1)); [, $tmp] = unpack('c', fread($fh, 1));
@ -261,7 +261,7 @@ class OLE
* *
* @return int * @return int
*/ */
private static function _readInt2($fh) private static function readInt2($fh)
{ {
[, $tmp] = unpack('v', fread($fh, 2)); [, $tmp] = unpack('v', fread($fh, 2));
@ -275,7 +275,7 @@ class OLE
* *
* @return int * @return int
*/ */
private static function _readInt4($fh) private static function readInt4($fh)
{ {
[, $tmp] = unpack('V', fread($fh, 4)); [, $tmp] = unpack('V', fread($fh, 4));
@ -290,17 +290,17 @@ class OLE
* *
* @return bool true on success, PEAR_Error on failure * @return bool true on success, PEAR_Error on failure
*/ */
public function _readPpsWks($blockId) public function readPpsWks($blockId)
{ {
$fh = $this->getStream($blockId); $fh = $this->getStream($blockId);
for ($pos = 0; true; $pos += 128) { for ($pos = 0; true; $pos += 128) {
fseek($fh, $pos, SEEK_SET); fseek($fh, $pos, SEEK_SET);
$nameUtf16 = fread($fh, 64); $nameUtf16 = fread($fh, 64);
$nameLength = self::_readInt2($fh); $nameLength = self::readInt2($fh);
$nameUtf16 = substr($nameUtf16, 0, $nameLength - 2); $nameUtf16 = substr($nameUtf16, 0, $nameLength - 2);
// Simple conversion from UTF-16LE to ISO-8859-1 // Simple conversion from UTF-16LE to ISO-8859-1
$name = str_replace("\x00", '', $nameUtf16); $name = str_replace("\x00", '', $nameUtf16);
$type = self::_readInt1($fh); $type = self::readInt1($fh);
switch ($type) { switch ($type) {
case self::OLE_PPS_TYPE_ROOT: case self::OLE_PPS_TYPE_ROOT:
$pps = new OLE\PPS\Root(null, null, []); $pps = new OLE\PPS\Root(null, null, []);
@ -321,19 +321,19 @@ class OLE
fseek($fh, 1, SEEK_CUR); fseek($fh, 1, SEEK_CUR);
$pps->Type = $type; $pps->Type = $type;
$pps->Name = $name; $pps->Name = $name;
$pps->PrevPps = self::_readInt4($fh); $pps->PrevPps = self::readInt4($fh);
$pps->NextPps = self::_readInt4($fh); $pps->NextPps = self::readInt4($fh);
$pps->DirPps = self::_readInt4($fh); $pps->DirPps = self::readInt4($fh);
fseek($fh, 20, SEEK_CUR); fseek($fh, 20, SEEK_CUR);
$pps->Time1st = self::OLE2LocalDate(fread($fh, 8)); $pps->Time1st = self::OLE2LocalDate(fread($fh, 8));
$pps->Time2nd = self::OLE2LocalDate(fread($fh, 8)); $pps->Time2nd = self::OLE2LocalDate(fread($fh, 8));
$pps->startBlock = self::_readInt4($fh); $pps->startBlock = self::readInt4($fh);
$pps->Size = self::_readInt4($fh); $pps->Size = self::readInt4($fh);
$pps->No = count($this->_list); $pps->No = count($this->_list);
$this->_list[] = $pps; $this->_list[] = $pps;
// check if the PPS tree (starting from root) is complete // check if the PPS tree (starting from root) is complete
if (isset($this->root) && $this->_ppsTreeComplete($this->root->No)) { if (isset($this->root) && $this->ppsTreeComplete($this->root->No)) {
break; break;
} }
} }
@ -367,16 +367,16 @@ class OLE
* *
* @return bool Whether the PPS tree for the given PPS is complete * @return bool Whether the PPS tree for the given PPS is complete
*/ */
public function _ppsTreeComplete($index) private function ppsTreeComplete($index)
{ {
return isset($this->_list[$index]) && return isset($this->_list[$index]) &&
($pps = $this->_list[$index]) && ($pps = $this->_list[$index]) &&
($pps->PrevPps == -1 || ($pps->PrevPps == -1 ||
$this->_ppsTreeComplete($pps->PrevPps)) && $this->ppsTreeComplete($pps->PrevPps)) &&
($pps->NextPps == -1 || ($pps->NextPps == -1 ||
$this->_ppsTreeComplete($pps->NextPps)) && $this->ppsTreeComplete($pps->NextPps)) &&
($pps->DirPps == -1 || ($pps->DirPps == -1 ||
$this->_ppsTreeComplete($pps->DirPps)); $this->ppsTreeComplete($pps->DirPps));
} }
/** /**

View File

@ -71,7 +71,7 @@ class ChainedBlockStream
$this->data = ''; $this->data = '';
if (isset($this->params['size']) && $this->params['size'] < $this->ole->bigBlockThreshold && $blockId != $this->ole->root->startBlock) { if (isset($this->params['size']) && $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) {
$pos = $rootPos + $blockId * $this->ole->bigBlockSize; $pos = $rootPos + $blockId * $this->ole->bigBlockSize;
$blockId = $this->ole->sbat[$blockId]; $blockId = $this->ole->sbat[$blockId];
@ -81,7 +81,7 @@ class ChainedBlockStream
} else { } else {
// Block id refers to big blocks // Block id refers to big blocks
while ($blockId != -2) { while ($blockId != -2) {
$pos = $this->ole->_getBlockOffset($blockId); $pos = $this->ole->getBlockOffset($blockId);
fseek($this->ole->_file_handle, $pos); fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize); $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
$blockId = $this->ole->bbat[$blockId]; $blockId = $this->ole->bbat[$blockId];

View File

@ -172,7 +172,7 @@ class PPS
* *
* @return string The binary string * @return string The binary string
*/ */
public function _getPpsWk() public function getPpsWk()
{ {
$ret = str_pad($this->Name, 64, "\x00"); $ret = str_pad($this->Name, 64, "\x00");
@ -207,7 +207,7 @@ class PPS
* *
* @return int The index for this PPS * @return int The index for this PPS
*/ */
public static function _savePpsSetPnt(&$raList, $to_save, $depth = 0) public static function savePpsSetPnt(&$raList, $to_save, $depth = 0)
{ {
if (!is_array($to_save) || (empty($to_save))) { if (!is_array($to_save) || (empty($to_save))) {
return 0xFFFFFFFF; return 0xFFFFFFFF;
@ -218,7 +218,7 @@ class PPS
$raList[$cnt]->No = $cnt; $raList[$cnt]->No = $cnt;
$raList[$cnt]->PrevPps = 0xFFFFFFFF; $raList[$cnt]->PrevPps = 0xFFFFFFFF;
$raList[$cnt]->NextPps = 0xFFFFFFFF; $raList[$cnt]->NextPps = 0xFFFFFFFF;
$raList[$cnt]->DirPps = self::_savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++); $raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
} else { } else {
$iPos = floor(count($to_save) / 2); $iPos = floor(count($to_save) / 2);
$aPrev = array_slice($to_save, 0, $iPos); $aPrev = array_slice($to_save, 0, $iPos);
@ -227,9 +227,9 @@ class PPS
// If the first entry, it's the root... Don't clone it! // If the first entry, it's the root... Don't clone it!
$raList[$cnt] = ($depth == 0) ? $to_save[$iPos] : clone $to_save[$iPos]; $raList[$cnt] = ($depth == 0) ? $to_save[$iPos] : clone $to_save[$iPos];
$raList[$cnt]->No = $cnt; $raList[$cnt]->No = $cnt;
$raList[$cnt]->PrevPps = self::_savePpsSetPnt($raList, $aPrev, $depth++); $raList[$cnt]->PrevPps = self::savePpsSetPnt($raList, $aPrev, $depth++);
$raList[$cnt]->NextPps = self::_savePpsSetPnt($raList, $aNext, $depth++); $raList[$cnt]->NextPps = self::savePpsSetPnt($raList, $aNext, $depth++);
$raList[$cnt]->DirPps = self::_savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++); $raList[$cnt]->DirPps = self::savePpsSetPnt($raList, @$raList[$cnt]->children, $depth++);
} }
return $cnt; return $cnt;

View File

@ -80,21 +80,21 @@ class Root extends PPS
// Make an array of PPS's (for Save) // Make an array of PPS's (for Save)
$aList = []; $aList = [];
PPS::_savePpsSetPnt($aList, [$this]); PPS::savePpsSetPnt($aList, [$this]);
// calculate values for header // calculate values for header
[$iSBDcnt, $iBBcnt, $iPPScnt] = $this->_calcSize($aList); //, $rhInfo); [$iSBDcnt, $iBBcnt, $iPPScnt] = $this->calcSize($aList); //, $rhInfo);
// Save Header // Save Header
$this->_saveHeader($iSBDcnt, $iBBcnt, $iPPScnt); $this->saveHeader($iSBDcnt, $iBBcnt, $iPPScnt);
// Make Small Data string (write SBD) // Make Small Data string (write SBD)
$this->_data = $this->_makeSmallData($aList); $this->_data = $this->makeSmallData($aList);
// Write BB // Write BB
$this->_saveBigData($iSBDcnt, $aList); $this->saveBigData($iSBDcnt, $aList);
// Write PPS // Write PPS
$this->_savePps($aList); $this->savePps($aList);
// Write Big Block Depot and BDList and Adding Header informations // Write Big Block Depot and BDList and Adding Header informations
$this->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt); $this->saveBbd($iSBDcnt, $iBBcnt, $iPPScnt);
return true; return true;
} }
@ -106,7 +106,7 @@ class Root extends PPS
* *
* @return float[] The array of numbers * @return float[] The array of numbers
*/ */
public function _calcSize(&$raList) private function calcSize(&$raList)
{ {
// Calculate Basic Setting // Calculate Basic Setting
[$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0]; [$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0];
@ -160,7 +160,7 @@ class Root extends PPS
* @param int $iBBcnt * @param int $iBBcnt
* @param int $iPPScnt * @param int $iPPScnt
*/ */
public function _saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void private function saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void
{ {
$FILE = $this->fileHandle; $FILE = $this->fileHandle;
@ -239,7 +239,7 @@ class Root extends PPS
* @param int $iStBlk * @param int $iStBlk
* @param array &$raList Reference to array of PPS's * @param array &$raList Reference to array of PPS's
*/ */
public function _saveBigData($iStBlk, &$raList): void private function saveBigData($iStBlk, &$raList): void
{ {
$FILE = $this->fileHandle; $FILE = $this->fileHandle;
@ -271,7 +271,7 @@ class Root extends PPS
* *
* @return string * @return string
*/ */
public function _makeSmallData(&$raList) private function makeSmallData(&$raList)
{ {
$sRes = ''; $sRes = '';
$FILE = $this->fileHandle; $FILE = $this->fileHandle;
@ -321,12 +321,12 @@ class Root extends PPS
* *
* @param array $raList Reference to an array with all PPS's * @param array $raList Reference to an array with all PPS's
*/ */
public function _savePps(&$raList): void private function savePps(&$raList): void
{ {
// Save each PPS WK // Save each PPS WK
$iC = count($raList); $iC = count($raList);
for ($i = 0; $i < $iC; ++$i) { for ($i = 0; $i < $iC; ++$i) {
fwrite($this->fileHandle, $raList[$i]->_getPpsWk()); fwrite($this->fileHandle, $raList[$i]->getPpsWk());
} }
// Adjust for Block // Adjust for Block
$iCnt = count($raList); $iCnt = count($raList);
@ -343,7 +343,7 @@ class Root extends PPS
* @param int $iBsize * @param int $iBsize
* @param int $iPpsCnt * @param int $iPpsCnt
*/ */
public function _saveBbd($iSbdSize, $iBsize, $iPpsCnt): void private function saveBbd($iSbdSize, $iBsize, $iPpsCnt): void
{ {
$FILE = $this->fileHandle; $FILE = $this->fileHandle;
// Calculate Basic Setting // Calculate Basic Setting

View File

@ -180,7 +180,7 @@ class OLERead
// read the directory stream // read the directory stream
$block = $this->rootStartBlock; $block = $this->rootStartBlock;
$this->entry = $this->_readData($block); $this->entry = $this->readData($block);
$this->readPropertySets(); $this->readPropertySets();
} }
@ -201,7 +201,7 @@ class OLERead
$streamData = ''; $streamData = '';
if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) { if ($this->props[$stream]['size'] < self::SMALL_BLOCK_THRESHOLD) {
$rootdata = $this->_readData($this->props[$this->rootentry]['startBlock']); $rootdata = $this->readData($this->props[$this->rootentry]['startBlock']);
$block = $this->props[$stream]['startBlock']; $block = $this->props[$stream]['startBlock'];
@ -241,7 +241,7 @@ class OLERead
* *
* @return string Data for standard stream * @return string Data for standard stream
*/ */
private function _readData($bl) private function readData($bl)
{ {
$block = $bl; $block = $bl;
$data = ''; $data = '';

View File

@ -396,8 +396,10 @@ class Spreadsheet
break; break;
case 'types': case 'types':
if (is_array($this->ribbonBinObjects) && if (
isset($this->ribbonBinObjects['data']) && is_array($this->ribbonBinObjects['data'])) { is_array($this->ribbonBinObjects) &&
isset($this->ribbonBinObjects['data']) && is_array($this->ribbonBinObjects['data'])
) {
$tmpTypes = array_keys($this->ribbonBinObjects['data']); $tmpTypes = array_keys($this->ribbonBinObjects['data']);
$ReturnData = array_unique(array_map([$this, 'getExtensionOnly'], $tmpTypes)); $ReturnData = array_unique(array_map([$this, 'getExtensionOnly'], $tmpTypes));
} else { } else {
@ -657,8 +659,10 @@ class Spreadsheet
array_splice($this->workSheetCollection, $pIndex, 1); array_splice($this->workSheetCollection, $pIndex, 1);
// Adjust active sheet index if necessary // Adjust active sheet index if necessary
if (($this->activeSheetIndex >= $pIndex) && if (
($pIndex > count($this->workSheetCollection) - 1)) { ($this->activeSheetIndex >= $pIndex) &&
($pIndex > count($this->workSheetCollection) - 1)
) {
--$this->activeSheetIndex; --$this->activeSheetIndex;
} }
} }

View File

@ -385,9 +385,11 @@ class Alignment extends Supervisor
public function setIndent($pValue) public function setIndent($pValue)
{ {
if ($pValue > 0) { if ($pValue > 0) {
if ($this->getHorizontal() != self::HORIZONTAL_GENERAL && if (
$this->getHorizontal() != self::HORIZONTAL_GENERAL &&
$this->getHorizontal() != self::HORIZONTAL_LEFT && $this->getHorizontal() != self::HORIZONTAL_LEFT &&
$this->getHorizontal() != self::HORIZONTAL_RIGHT) { $this->getHorizontal() != self::HORIZONTAL_RIGHT
) {
$pValue = 0; // indent not supported $pValue = 0; // indent not supported
} }
} }

View File

@ -643,28 +643,40 @@ class AutoFilter
]; ];
foreach ($ruleDataSet as $ruleValue) { foreach ($ruleDataSet as $ruleValue) {
$date = $time = ''; $date = $time = '';
if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) && if (
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')) { (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR])) &&
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR] !== '')
) {
$date .= sprintf('%04d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]); $date .= sprintf('%04d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_YEAR]);
} }
if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) && if (
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')) { (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH])) &&
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH] != '')
) {
$date .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]); $date .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MONTH]);
} }
if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) && if (
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')) { (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY])) &&
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY] !== '')
) {
$date .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]); $date .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_DAY]);
} }
if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) && if (
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')) { (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR])) &&
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR] !== '')
) {
$time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]); $time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_HOUR]);
} }
if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) && if (
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')) { (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE])) &&
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE] !== '')
) {
$time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]); $time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_MINUTE]);
} }
if ((isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) && if (
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')) { (isset($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND])) &&
($ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND] !== '')
) {
$time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]); $time .= sprintf('%02d', $ruleValue[AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DATEGROUP_SECOND]);
} }
$dateTime = $date . $time; $dateTime = $date . $time;
@ -712,8 +724,10 @@ class AutoFilter
foreach ($rules as $rule) { foreach ($rules as $rule) {
// We should only ever have one Dynamic Filter Rule anyway // We should only ever have one Dynamic Filter Rule anyway
$dynamicRuleType = $rule->getGrouping(); $dynamicRuleType = $rule->getGrouping();
if (($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) || if (
($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE)) { ($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_ABOVEAVERAGE) ||
($dynamicRuleType == AutoFilter\Column\Rule::AUTOFILTER_RULETYPE_DYNAMIC_BELOWAVERAGE)
) {
// Number (Average) based // Number (Average) based
// Calculate the average // Calculate the average
$averageFormula = '=AVERAGE(' . $columnID . ($rangeStart[1] + 1) . ':' . $columnID . $rangeEnd[1] . ')'; $averageFormula = '=AVERAGE(' . $columnID . ($rangeStart[1] + 1) . ':' . $columnID . $rangeEnd[1] . ')';

View File

@ -337,8 +337,10 @@ class Rule
if (empty($pOperator)) { if (empty($pOperator)) {
$pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL; $pOperator = self::AUTOFILTER_COLUMN_RULE_EQUAL;
} }
if ((!in_array($pOperator, self::$operators)) && if (
(!in_array($pOperator, self::$topTenValue))) { (!in_array($pOperator, self::$operators)) &&
(!in_array($pOperator, self::$topTenValue))
) {
throw new PhpSpreadsheetException('Invalid operator for column AutoFilter Rule.'); throw new PhpSpreadsheetException('Invalid operator for column AutoFilter Rule.');
} }
$this->operator = $pOperator; $this->operator = $pOperator;
@ -365,10 +367,12 @@ class Rule
*/ */
public function setGrouping($pGrouping) public function setGrouping($pGrouping)
{ {
if (($pGrouping !== null) && if (
($pGrouping !== null) &&
(!in_array($pGrouping, self::$dateTimeGroups)) && (!in_array($pGrouping, self::$dateTimeGroups)) &&
(!in_array($pGrouping, self::$dynamicTypes)) && (!in_array($pGrouping, self::$dynamicTypes)) &&
(!in_array($pGrouping, self::$topTenType))) { (!in_array($pGrouping, self::$topTenType))
) {
throw new PhpSpreadsheetException('Invalid rule type for column AutoFilter Rule.'); throw new PhpSpreadsheetException('Invalid rule type for column AutoFilter Rule.');
} }
$this->grouping = $pGrouping; $this->grouping = $pGrouping;

View File

@ -137,9 +137,11 @@ class ColumnCellIterator extends CellIterator
{ {
do { do {
++$this->currentRow; ++$this->currentRow;
} while (($this->onlyExistingCells) && } while (
($this->onlyExistingCells) &&
(!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->currentRow)) && (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->currentRow)) &&
($this->currentRow <= $this->endRow)); ($this->currentRow <= $this->endRow)
);
} }
/** /**
@ -149,9 +151,11 @@ class ColumnCellIterator extends CellIterator
{ {
do { do {
--$this->currentRow; --$this->currentRow;
} while (($this->onlyExistingCells) && } while (
($this->onlyExistingCells) &&
(!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->currentRow)) && (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->currentRow)) &&
($this->currentRow >= $this->startRow)); ($this->currentRow >= $this->startRow)
);
} }
/** /**
@ -170,15 +174,19 @@ class ColumnCellIterator extends CellIterator
protected function adjustForExistingOnlyRange(): void protected function adjustForExistingOnlyRange(): void
{ {
if ($this->onlyExistingCells) { if ($this->onlyExistingCells) {
while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) && while (
($this->startRow <= $this->endRow)) { (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->startRow)) &&
($this->startRow <= $this->endRow)
) {
++$this->startRow; ++$this->startRow;
} }
if ($this->startRow > $this->endRow) { if ($this->startRow > $this->endRow) {
throw new PhpSpreadsheetException('No cells exist within the specified range'); throw new PhpSpreadsheetException('No cells exist within the specified range');
} }
while ((!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) && while (
($this->endRow >= $this->startRow)) { (!$this->worksheet->cellExistsByColumnAndRow($this->columnIndex, $this->endRow)) &&
($this->endRow >= $this->startRow)
) {
--$this->endRow; --$this->endRow;
} }
if ($this->endRow < $this->startRow) { if ($this->endRow < $this->startRow) {

View File

@ -433,9 +433,11 @@ class Worksheet implements IComparable
throw new Exception('Sheet code name cannot be empty.'); throw new Exception('Sheet code name cannot be empty.');
} }
// Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'" // Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'"
if ((str_replace(self::$invalidCharacters, '', $pValue) !== $pValue) || if (
(str_replace(self::$invalidCharacters, '', $pValue) !== $pValue) ||
(Shared\StringHelper::substring($pValue, -1, 1) == '\'') || (Shared\StringHelper::substring($pValue, -1, 1) == '\'') ||
(Shared\StringHelper::substring($pValue, 0, 1) == '\'')) { (Shared\StringHelper::substring($pValue, 0, 1) == '\'')
) {
throw new Exception('Invalid character found in sheet code name'); throw new Exception('Invalid character found in sheet code name');
} }
@ -1188,8 +1190,10 @@ class Worksheet implements IComparable
} }
// Named range? // Named range?
if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) && if (
(preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))) { (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) &&
(preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))
) {
$namedRange = NamedRange::resolveRange($pCoordinate, $this); $namedRange = NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== null) { if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange(); $pCoordinate = $namedRange->getRange();
@ -1286,8 +1290,10 @@ class Worksheet implements IComparable
} }
// Named range? // Named range?
if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) && if (
(preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))) { (!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) &&
(preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))
) {
$namedRange = NamedRange::resolveRange($pCoordinate, $this); $namedRange = NamedRange::resolveRange($pCoordinate, $this);
if ($namedRange !== null) { if ($namedRange !== null) {
$pCoordinate = $namedRange->getRange(); $pCoordinate = $namedRange->getRange();

View File

@ -1368,7 +1368,8 @@ class Html extends BaseWriter
// General horizontal alignment: Actual horizontal alignment depends on dataType // General horizontal alignment: Actual horizontal alignment depends on dataType
$sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex()); $sharedStyle = $pSheet->getParent()->getCellXfByIndex($cell->getXfIndex());
if ($sharedStyle->getAlignment()->getHorizontal() == Alignment::HORIZONTAL_GENERAL if (
$sharedStyle->getAlignment()->getHorizontal() == Alignment::HORIZONTAL_GENERAL
&& isset($this->cssStyles['.' . $cell->getDataType()]['text-align']) && isset($this->cssStyles['.' . $cell->getDataType()]['text-align'])
) { ) {
$cssClass['text-align'] = $this->cssStyles['.' . $cell->getDataType()]['text-align']; $cssClass['text-align'] = $this->cssStyles['.' . $cell->getDataType()]['text-align'];

View File

@ -1172,9 +1172,11 @@ class Parser
return $this->createTree('ptgUplus', $result2, ''); return $this->createTree('ptgUplus', $result2, '');
} }
$result = $this->term(); $result = $this->term();
while (($this->currentToken == '+') || while (
($this->currentToken == '+') ||
($this->currentToken == '-') || ($this->currentToken == '-') ||
($this->currentToken == '^')) { ($this->currentToken == '^')
) {
if ($this->currentToken == '+') { if ($this->currentToken == '+') {
$this->advance(); $this->advance();
$result2 = $this->term(); $result2 = $this->term();
@ -1215,8 +1217,10 @@ class Parser
private function term() private function term()
{ {
$result = $this->fact(); $result = $this->fact();
while (($this->currentToken == '*') || while (
($this->currentToken == '/')) { ($this->currentToken == '*') ||
($this->currentToken == '/')
) {
if ($this->currentToken == '*') { if ($this->currentToken == '*') {
$this->advance(); $this->advance();
$result2 = $this->fact(); $result2 = $this->fact();
@ -1271,8 +1275,10 @@ class Parser
$this->advance(); $this->advance();
return $result; return $result;
} elseif (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken) || } elseif (
preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken)) { preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+:(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken) ||
preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+\.\.(\$)?[A-Ia-i]?[A-Za-z](\$)?\d+$/', $this->currentToken)
) {
// if it's a range A1:B2 or $A$1:$B$2 // if it's a range A1:B2 or $A$1:$B$2
// must be an error? // must be an error?
$result = $this->createTree($this->currentToken, '', ''); $result = $this->createTree($this->currentToken, '', '');
@ -1419,11 +1425,13 @@ class Parser
$polish .= $converted_tree; $polish .= $converted_tree;
} }
// if it's a function convert it here (so we can set it's arguments) // if it's a function convert it here (so we can set it's arguments)
if (preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/", $tree['value']) && if (
preg_match("/^[A-Z0-9\xc0-\xdc\\.]+$/", $tree['value']) &&
!preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) && !preg_match('/^([A-Ia-i]?[A-Za-z])(\d+)$/', $tree['value']) &&
!preg_match('/^[A-Ia-i]?[A-Za-z](\\d+)\\.\\.[A-Ia-i]?[A-Za-z](\\d+)$/', $tree['value']) && !preg_match('/^[A-Ia-i]?[A-Za-z](\\d+)\\.\\.[A-Ia-i]?[A-Za-z](\\d+)$/', $tree['value']) &&
!is_numeric($tree['value']) && !is_numeric($tree['value']) &&
!isset($this->ptg[$tree['value']])) { !isset($this->ptg[$tree['value']])
) {
// left subtree for a function is always an array. // left subtree for a function is always an array.
if ($tree['left'] != '') { if ($tree['left'] != '') {
$left_tree = $this->toReversePolish($tree['left']); $left_tree = $this->toReversePolish($tree['left']);

View File

@ -544,8 +544,10 @@ class Worksheet extends BIFFwriter
// Write ConditionalFormattingTable records // Write ConditionalFormattingTable records
foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) { foreach ($arrConditionalStyles as $cellCoordinate => $conditionalStyles) {
foreach ($conditionalStyles as $conditional) { foreach ($conditionalStyles as $conditional) {
if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION if (
|| $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION
|| $conditional->getConditionType() == Conditional::CONDITION_CELLIS
) {
if (!isset($arrConditional[$conditional->getHashCode()])) { if (!isset($arrConditional[$conditional->getHashCode()])) {
// This hash code has been handled // This hash code has been handled
$arrConditional[$conditional->getHashCode()] = true; $arrConditional[$conditional->getHashCode()] = true;
@ -3086,7 +3088,8 @@ class Worksheet extends BIFFwriter
$bFormatFill = 0; $bFormatFill = 0;
} }
// Font // Font
if ($conditional->getStyle()->getFont()->getName() != null if (
$conditional->getStyle()->getFont()->getName() != null
|| $conditional->getStyle()->getFont()->getSize() != null || $conditional->getStyle()->getFont()->getSize() != null
|| $conditional->getStyle()->getFont()->getBold() != null || $conditional->getStyle()->getFont()->getBold() != null
|| $conditional->getStyle()->getFont()->getItalic() != null || $conditional->getStyle()->getFont()->getItalic() != null
@ -3094,7 +3097,8 @@ class Worksheet extends BIFFwriter
|| $conditional->getStyle()->getFont()->getSubscript() != null || $conditional->getStyle()->getFont()->getSubscript() != null
|| $conditional->getStyle()->getFont()->getUnderline() != null || $conditional->getStyle()->getFont()->getUnderline() != null
|| $conditional->getStyle()->getFont()->getStrikethrough() != null || $conditional->getStyle()->getFont()->getStrikethrough() != null
|| $conditional->getStyle()->getFont()->getColor()->getARGB() != null) { || $conditional->getStyle()->getFont()->getColor()->getARGB() != null
) {
$bFormatFont = 1; $bFormatFont = 1;
} else { } else {
$bFormatFont = 0; $bFormatFont = 0;
@ -4447,8 +4451,10 @@ class Worksheet extends BIFFwriter
$arrConditional = []; $arrConditional = [];
foreach ($this->phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) { foreach ($this->phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) {
foreach ($conditionalStyles as $conditional) { foreach ($conditionalStyles as $conditional) {
if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION if (
|| $conditional->getConditionType() == Conditional::CONDITION_CELLIS) { $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION
|| $conditional->getConditionType() == Conditional::CONDITION_CELLIS
) {
if (!in_array($conditional->getHashCode(), $arrConditional)) { if (!in_array($conditional->getHashCode(), $arrConditional)) {
$arrConditional[] = $conditional->getHashCode(); $arrConditional[] = $conditional->getHashCode();
} }

View File

@ -317,8 +317,10 @@ class Rels extends WriterPart
$i = 1; $i = 1;
$iterator = $pWorksheet->getDrawingCollection()->getIterator(); $iterator = $pWorksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) { while ($iterator->valid()) {
if ($iterator->current() instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing if (
|| $iterator->current() instanceof MemoryDrawing) { $iterator->current() instanceof \PhpOffice\PhpSpreadsheet\Worksheet\Drawing
|| $iterator->current() instanceof MemoryDrawing
) {
// Write relationship for image drawing // Write relationship for image drawing
/** @var \PhpOffice\PhpSpreadsheet\Worksheet\Drawing $drawing */ /** @var \PhpOffice\PhpSpreadsheet\Worksheet\Drawing $drawing */
$drawing = $iterator->current(); $drawing = $iterator->current();

View File

@ -38,16 +38,20 @@ class StringTable extends WriterPart
foreach ($pSheet->getCoordinates() as $coordinate) { foreach ($pSheet->getCoordinates() as $coordinate) {
$cell = $pSheet->getCell($coordinate); $cell = $pSheet->getCell($coordinate);
$cellValue = $cell->getValue(); $cellValue = $cell->getValue();
if (!is_object($cellValue) && if (
!is_object($cellValue) &&
($cellValue !== null) && ($cellValue !== null) &&
$cellValue !== '' && $cellValue !== '' &&
!isset($aFlippedStringTable[$cellValue]) && !isset($aFlippedStringTable[$cellValue]) &&
($cell->getDataType() == DataType::TYPE_STRING || $cell->getDataType() == DataType::TYPE_STRING2 || $cell->getDataType() == DataType::TYPE_NULL)) { ($cell->getDataType() == DataType::TYPE_STRING || $cell->getDataType() == DataType::TYPE_STRING2 || $cell->getDataType() == DataType::TYPE_NULL)
) {
$aStringTable[] = $cellValue; $aStringTable[] = $cellValue;
$aFlippedStringTable[$cellValue] = true; $aFlippedStringTable[$cellValue] = true;
} elseif ($cellValue instanceof RichText && } elseif (
$cellValue instanceof RichText &&
($cellValue !== null) && ($cellValue !== null) &&
!isset($aFlippedStringTable[$cellValue->getHashCode()])) { !isset($aFlippedStringTable[$cellValue->getHashCode()])
) {
$aStringTable[] = $cellValue; $aStringTable[] = $cellValue;
$aFlippedStringTable[$cellValue->getHashCode()] = true; $aFlippedStringTable[$cellValue->getHashCode()] = true;
} }

View File

@ -152,8 +152,10 @@ class Style extends WriterPart
private function writeFill(XMLWriter $objWriter, Fill $pFill): void private function writeFill(XMLWriter $objWriter, Fill $pFill): void
{ {
// Check if this is a pattern type or gradient type // Check if this is a pattern type or gradient type
if ($pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR || if (
$pFill->getFillType() === Fill::FILL_GRADIENT_PATH) { $pFill->getFillType() === Fill::FILL_GRADIENT_LINEAR ||
$pFill->getFillType() === Fill::FILL_GRADIENT_PATH
) {
// Gradient fill // Gradient fill
$this->writeGradientFill($objWriter, $pFill); $this->writeGradientFill($objWriter, $pFill);
} elseif ($pFill->getFillType() !== null) { } elseif ($pFill->getFillType() !== null) {
@ -479,15 +481,21 @@ class Style extends WriterPart
// protection // protection
if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) { if (($pStyle->getProtection()->getLocked() !== null) || ($pStyle->getProtection()->getHidden() !== null)) {
if ($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT || if (
$pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT) { $pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT ||
$pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT
) {
$objWriter->startElement('protection'); $objWriter->startElement('protection');
if (($pStyle->getProtection()->getLocked() !== null) && if (
($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT)) { ($pStyle->getProtection()->getLocked() !== null) &&
($pStyle->getProtection()->getLocked() !== Protection::PROTECTION_INHERIT)
) {
$objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); $objWriter->writeAttribute('locked', ($pStyle->getProtection()->getLocked() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
} }
if (($pStyle->getProtection()->getHidden() !== null) && if (
($pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT)) { ($pStyle->getProtection()->getHidden() !== null) &&
($pStyle->getProtection()->getHidden() !== Protection::PROTECTION_INHERIT)
) {
$objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false')); $objWriter->writeAttribute('hidden', ($pStyle->getProtection()->getHidden() == Protection::PROTECTION_PROTECTED ? 'true' : 'false'));
} }
$objWriter->endElement(); $objWriter->endElement();

View File

@ -314,8 +314,10 @@ class Worksheet extends WriterPart
} }
// Set Zero Height row // Set Zero Height row
if ((string) $pSheet->getDefaultRowDimension()->getZeroHeight() === '1' || if (
strtolower((string) $pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true') { (string) $pSheet->getDefaultRowDimension()->getZeroHeight() === '1' ||
strtolower((string) $pSheet->getDefaultRowDimension()->getZeroHeight()) == 'true'
) {
$objWriter->writeAttribute('zeroHeight', '1'); $objWriter->writeAttribute('zeroHeight', '1');
} }
@ -466,9 +468,11 @@ class Worksheet extends WriterPart
private static function writeOtherCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void private static function writeOtherCondElements(XMLWriter $objWriter, Conditional $conditional, string $cellCoordinate): void
{ {
if ($conditional->getConditionType() == Conditional::CONDITION_CELLIS if (
$conditional->getConditionType() == Conditional::CONDITION_CELLIS
|| $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT || $conditional->getConditionType() == Conditional::CONDITION_CONTAINSTEXT
|| $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION) { || $conditional->getConditionType() == Conditional::CONDITION_EXPRESSION
) {
foreach ($conditional->getConditions() as $formula) { foreach ($conditional->getConditions() as $formula) {
// Formula // Formula
$objWriter->writeElement('formula', Xlfn::addXlfn($formula)); $objWriter->writeElement('formula', Xlfn::addXlfn($formula));
@ -791,9 +795,11 @@ class Worksheet extends WriterPart
} }
foreach ($rules as $rule) { foreach ($rules as $rule) {
if (($column->getFilterType() === Column::AUTOFILTER_FILTERTYPE_FILTER) && if (
($column->getFilterType() === Column::AUTOFILTER_FILTERTYPE_FILTER) &&
($rule->getOperator() === Rule::AUTOFILTER_COLUMN_RULE_EQUAL) && ($rule->getOperator() === Rule::AUTOFILTER_COLUMN_RULE_EQUAL) &&
($rule->getValue() === '')) { ($rule->getValue() === '')
) {
// Filter rule for Blanks // Filter rule for Blanks
$objWriter->writeAttribute('blank', 1); $objWriter->writeAttribute('blank', 1);
} elseif ($rule->getRuleType() === Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) { } elseif ($rule->getRuleType() === Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER) {

View File

@ -90,13 +90,13 @@ class ReadFilterTest extends AbstractFunctional
} }
/** /**
* @see \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::readCell()
*
* @param string $column Column address (as a string value like "A", or "IV") * @param string $column Column address (as a string value like "A", or "IV")
* @param int $row Row number * @param int $row Row number
* @param string $worksheetName Optional worksheet name * @param string $worksheetName Optional worksheet name
* *
* @return bool * @return bool
*
* @see \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::readCell()
*/ */
public function readFilterReadCell($column, $row, $worksheetName = '') public function readFilterReadCell($column, $row, $worksheetName = '')
{ {
@ -112,8 +112,10 @@ class ReadFilterTest extends AbstractFunctional
} }
$col = sprintf('%04s', $column); $col = sprintf('%04s', $column);
if ($col > sprintf('%04s', $columnMax) || if (
$col < sprintf('%04s', $columnMin)) { $col > sprintf('%04s', $columnMax) ||
$col < sprintf('%04s', $columnMin)
) {
return false; return false;
} }

View File

@ -5,6 +5,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Reader\Html;
use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException;
use PhpOffice\PhpSpreadsheet\Reader\Html; use PhpOffice\PhpSpreadsheet\Reader\Html;
use PhpOffice\PhpSpreadsheet\Style\Alignment; use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Style\Border;
use PhpOffice\PhpSpreadsheet\Style\Font; use PhpOffice\PhpSpreadsheet\Style\Font;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;