Apply Scrutinizer patches for spacing

This commit is contained in:
Adrien Crivelli 2016-08-25 18:46:02 +09:00
parent 20ccfa0d59
commit a85f1bdbed
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
58 changed files with 1061 additions and 1067 deletions

View File

@ -245,7 +245,7 @@ class Wincache extends CacheBase implements ICache
*/ */
public function __construct(\PhpSpreadsheet\Worksheet $parent, $arguments) public function __construct(\PhpSpreadsheet\Worksheet $parent, $arguments)
{ {
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600; $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->cachePrefix)) { if (is_null($this->cachePrefix)) {
$baseUnique = $this->getUniqueID(); $baseUnique = $this->getUniqueID();

View File

@ -109,10 +109,10 @@ class Calculation
* @var array * @var array
*/ */
private static $operators = [ private static $operators = [
'+' => true, '-' => true, '*' => true, '/' => true, '+' => true, '-' => true, '*' => true, '/' => true,
'^' => true, '&' => true, '%' => false, '~' => false, '^' => true, '&' => true, '%' => false, '~' => false,
'>' => true, '<' => true, '=' => true, '>=' => true, '>' => true, '<' => true, '=' => true, '>=' => true,
'<=' => true, '<>' => true, '|' => true, ':' => true, '<=' => true, '<>' => true, '|' => true, ':' => true,
]; ];
/** /**
@ -121,10 +121,10 @@ class Calculation
* @var array * @var array
*/ */
private static $binaryOperators = [ private static $binaryOperators = [
'+' => true, '-' => true, '*' => true, '/' => true, '+' => true, '-' => true, '*' => true, '/' => true,
'^' => true, '&' => true, '>' => true, '<' => true, '^' => true, '&' => true, '>' => true, '<' => true,
'=' => true, '>=' => true, '<=' => true, '<>' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true,
'|' => true, ':' => true, '|' => true, ':' => true,
]; ];
/** /**
@ -189,7 +189,7 @@ class Calculation
* *
* @var string * @var string
*/ */
private static $localeLanguage = 'en_us'; // US English (default locale) private static $localeLanguage = 'en_us'; // US English (default locale)
/** /**
* List of available locale settings * List of available locale settings
@ -198,7 +198,7 @@ class Calculation
* @var string[] * @var string[]
*/ */
private static $validLocaleLanguages = [ private static $validLocaleLanguages = [
'en', // English (default language) 'en', // English (default language)
]; ];
/** /**
@ -2279,7 +2279,7 @@ class Calculation
// Retrieve the list of locale or language specific function names // Retrieve the list of locale or language specific function names
$localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeFunctions as $localeFunction) { foreach ($localeFunctions as $localeFunction) {
list($localeFunction) = explode('##', $localeFunction); // Strip out comments list($localeFunction) = explode('##', $localeFunction); // Strip out comments
if (strpos($localeFunction, '=') !== false) { if (strpos($localeFunction, '=') !== false) {
list($fName, $lfName) = explode('=', $localeFunction); list($fName, $lfName) = explode('=', $localeFunction);
$fName = trim($fName); $fName = trim($fName);
@ -2304,7 +2304,7 @@ class Calculation
if (file_exists($configFile)) { if (file_exists($configFile)) {
$localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($localeSettings as $localeSetting) { foreach ($localeSettings as $localeSetting) {
list($localeSetting) = explode('##', $localeSetting); // Strip out comments list($localeSetting) = explode('##', $localeSetting); // Strip out comments
if (strpos($localeSetting, '=') !== false) { if (strpos($localeSetting, '=') !== false) {
list($settingName, $settingValue) = explode('=', $localeSetting); list($settingName, $settingValue) = explode('=', $localeSetting);
$settingName = strtoupper(trim($settingName)); $settingName = strtoupper(trim($settingName));
@ -3034,12 +3034,12 @@ class Calculation
// These operators always work on two values // These operators always work on two values
// Array key is the operator, the value indicates whether this is a left or right associative operator // Array key is the operator, the value indicates whether this is a left or right associative operator
private static $operatorAssociativity = [ private static $operatorAssociativity = [
'^' => 0, // Exponentiation '^' => 0, // Exponentiation
'*' => 0, '/' => 0, // Multiplication and Division '*' => 0, '/' => 0, // Multiplication and Division
'+' => 0, '-' => 0, // Addition and Subtraction '+' => 0, '-' => 0, // Addition and Subtraction
'&' => 0, // Concatenation '&' => 0, // Concatenation
'|' => 0, ':' => 0, // Intersect and Range '|' => 0, ':' => 0, // Intersect and Range
'>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0, // Comparison '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0, // Comparison
]; ];
// Comparison (Boolean) Operators // Comparison (Boolean) Operators
@ -3050,15 +3050,15 @@ class Calculation
// This list includes all valid operators, whether binary (including boolean) or unary (such as %) // This list includes all valid operators, whether binary (including boolean) or unary (such as %)
// Array key is the operator, the value is its precedence // Array key is the operator, the value is its precedence
private static $operatorPrecedence = [ private static $operatorPrecedence = [
':' => 8, // Range ':' => 8, // Range
'|' => 7, // Intersect '|' => 7, // Intersect
'~' => 6, // Negation '~' => 6, // Negation
'%' => 5, // Percentage '%' => 5, // Percentage
'^' => 4, // Exponentiation '^' => 4, // Exponentiation
'*' => 3, '/' => 3, // Multiplication and Division '*' => 3, '/' => 3, // Multiplication and Division
'+' => 2, '-' => 2, // Addition and Subtraction '+' => 2, '-' => 2, // Addition and Subtraction
'&' => 1, // Concatenation '&' => 1, // Concatenation
'>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0, // Comparison '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0, // Comparison
]; ];
// Convert infix to postfix notation // Convert infix to postfix notation
@ -3085,9 +3085,9 @@ class Calculation
$index = 0; $index = 0;
$stack = new Calculation\Token\Stack(); $stack = new Calculation\Token\Stack();
$output = []; $output = [];
$expectingOperator = false; // We use this test in syntax-checking the expression to determine when a $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a
// - is a negation or + is a positive operator rather than an operation // - is a negation or + is a positive operator rather than an operation
$expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand
// should be null in a function call // should be null in a function call
// The guts of the lexical parser // The guts of the lexical parser
// Loop through the formula extracting each operator and operand in turn // Loop through the formula extracting each operator and operand in turn
@ -3107,26 +3107,26 @@ class Calculation
if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus? if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus?
//echo 'Element is a Negation operator', PHP_EOL; //echo 'Element is a Negation operator', PHP_EOL;
$stack->push('Unary Operator', '~'); // Put a negation on the stack $stack->push('Unary Operator', '~'); // Put a negation on the stack
++$index; // and drop the negation symbol ++$index; // and drop the negation symbol
} elseif ($opCharacter == '%' && $expectingOperator) { } elseif ($opCharacter == '%' && $expectingOperator) {
//echo 'Element is a Percentage operator', PHP_EOL; //echo 'Element is a Percentage operator', PHP_EOL;
$stack->push('Unary Operator', '%'); // Put a percentage on the stack $stack->push('Unary Operator', '%'); // Put a percentage on the stack
++$index; ++$index;
} elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded? } elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded?
//echo 'Element is a Positive number, not Plus operator', PHP_EOL; //echo 'Element is a Positive number, not Plus operator', PHP_EOL;
++$index; // Drop the redundant plus symbol ++$index; // Drop the redundant plus symbol
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal
return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression return $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
} elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? } elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
//echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL; //echo 'Element with value '.$opCharacter.' is an Operator', PHP_EOL;
while ($stack->count() > 0 && while ($stack->count() > 0 &&
($o2 = $stack->last()) && ($o2 = $stack->last()) &&
isset(self::$operators[$o2['value']]) && isset(self::$operators[$o2['value']]) &&
@(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) { @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) {
$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
} }
$stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack $stack->push('Binary Operator', $opCharacter); // Finally put our current operator onto the stack
++$index; ++$index;
$expectingOperator = false; $expectingOperator = false;
} elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis? } elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis?
@ -3141,10 +3141,10 @@ class Calculation
} }
$d = $stack->last(2); $d = $stack->last(2);
if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function?
$functionName = $matches[1]; // Get the function name $functionName = $matches[1]; // Get the function name
//echo 'Closed Function is '.$functionName, PHP_EOL; //echo 'Closed Function is '.$functionName, PHP_EOL;
$d = $stack->pop(); $d = $stack->pop();
$argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack) $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack)
//if ($argumentCount == 0) { //if ($argumentCount == 0) {
// echo 'With no arguments', PHP_EOL; // echo 'With no arguments', PHP_EOL;
//} elseif ($argumentCount == 1) { //} elseif ($argumentCount == 1) {
@ -3152,8 +3152,8 @@ class Calculation
//} else { //} else {
// echo 'With '.$argumentCount.' arguments', PHP_EOL; // echo 'With '.$argumentCount.' arguments', PHP_EOL;
//} //}
$output[] = $d; // Dump the argument count on the output $output[] = $d; // Dump the argument count on the output
$output[] = $stack->pop(); // Pop the function and push onto the output $output[] = $stack->pop(); // Pop the function and push onto the output
if (isset(self::$controlFunctions[$functionName])) { if (isset(self::$controlFunctions[$functionName])) {
//echo 'Built-in function '.$functionName, PHP_EOL; //echo 'Built-in function '.$functionName, PHP_EOL;
$expectedArgumentCount = self::$controlFunctions[$functionName]['argumentCount']; $expectedArgumentCount = self::$controlFunctions[$functionName]['argumentCount'];
@ -3217,7 +3217,7 @@ class Calculation
if ($o2 === null) { if ($o2 === null) {
return $this->raiseFormulaError('Formula Error: Unexpected ,'); return $this->raiseFormulaError('Formula Error: Unexpected ,');
} else { } else {
$output[] = $o2; // pop the argument expression stuff and push onto the output $output[] = $o2; // pop the argument expression stuff and push onto the output
} }
} }
// If we've a comma when we're expecting an operand, then what we actually have is a null operand; // If we've a comma when we're expecting an operand, then what we actually have is a null operand;
@ -3231,8 +3231,8 @@ class Calculation
return $this->raiseFormulaError('Formula Error: Unexpected ,'); return $this->raiseFormulaError('Formula Error: Unexpected ,');
} }
$d = $stack->pop(); $d = $stack->pop();
$stack->push($d['type'], ++$d['value'], $d['reference']); // increment the argument count $stack->push($d['type'], ++$d['value'], $d['reference']); // increment the argument count
$stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again
$expectingOperator = false; $expectingOperator = false;
$expectingOperand = true; $expectingOperand = true;
++$index; ++$index;
@ -3311,13 +3311,13 @@ class Calculation
if ((is_integer($startRowColRef)) && (ctype_digit($val)) && if ((is_integer($startRowColRef)) && (ctype_digit($val)) &&
($startRowColRef <= 1048576) && ($val <= 1048576)) { ($startRowColRef <= 1048576) && ($val <= 1048576)) {
// Row range // Row range
$endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 $endRowColRef = ($pCellParent !== null) ? $pCellParent->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 ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
(strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) { (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
// Column range // Column range
$endRowColRef = ($pCellParent !== null) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 $endRowColRef = ($pCellParent !== null) ? $pCellParent->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';
$val = $rangeWS2 . $val . $endRowColRef; $val = $rangeWS2 . $val . $endRowColRef;
} }
@ -3395,9 +3395,9 @@ class Calculation
($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
$expectingOperator = false; $expectingOperator = false;
} }
} }
@ -3405,7 +3405,7 @@ class Calculation
while (($op = $stack->pop()) !== null) { // pop everything off the stack and push onto output while (($op = $stack->pop()) !== null) { // pop everything off the stack and push onto output
if ((is_array($op) && $op['value'] == '(') || ($op === '(')) { if ((is_array($op) && $op['value'] == '(') || ($op === '(')) {
return $this->raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced return $this->raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced
} }
$output[] = $op; $output[] = $op;
} }

View File

@ -424,7 +424,7 @@ class DateTime
return (float) \PhpSpreadsheet\Shared\Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second); return (float) \PhpSpreadsheet\Shared\Date::formattedPHPToExcel($calendar, 1, $date, $hour, $minute, $second);
case Functions::RETURNDATE_PHP_NUMERIC: case Functions::RETURNDATE_PHP_NUMERIC:
return (integer) \PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600 return (integer) \PhpSpreadsheet\Shared\Date::excelToTimestamp(\PhpSpreadsheet\Shared\Date::formattedPHPToExcel(1970, 1, 1, $hour, $minute, $second)); // -2147468400; // -2147472000 + 3600
case Functions::RETURNDATE_PHP_OBJECT: case Functions::RETURNDATE_PHP_OBJECT:
$dayAdjust = 0; $dayAdjust = 0;
if ($hour < 0) { if ($hour < 0) {
@ -1036,7 +1036,7 @@ class DateTime
$startDoW = self::DAYOFWEEK($startDate, 3); $startDoW = self::DAYOFWEEK($startDate, 3);
if (self::DAYOFWEEK($startDate, 3) >= 5) { if (self::DAYOFWEEK($startDate, 3) >= 5) {
$startDate += ($decrementing) ? -$startDoW + 4: 7 - $startDoW; $startDate += ($decrementing) ? -$startDoW + 4 : 7 - $startDoW;
($decrementing) ? $endDays++ : $endDays--; ($decrementing) ? $endDays++ : $endDays--;
} }
@ -1046,7 +1046,7 @@ class DateTime
// Adjust the calculated end date if it falls over a weekend // Adjust the calculated end date if it falls over a weekend
$endDoW = self::DAYOFWEEK($endDate, 3); $endDoW = self::DAYOFWEEK($endDate, 3);
if ($endDoW >= 5) { if ($endDoW >= 5) {
$endDate += ($decrementing) ? -$endDoW + 4: 7 - $endDoW; $endDate += ($decrementing) ? -$endDoW + 4 : 7 - $endDoW;
} }
// Test any extra holiday parameters // Test any extra holiday parameters

View File

@ -180,9 +180,9 @@ class Financial
$firstinterest = Functions::flattenSingleValue($firstinterest); $firstinterest = Functions::flattenSingleValue($firstinterest);
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$rate = Functions::flattenSingleValue($rate); $rate = Functions::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par); $par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par);
$frequency = (is_null($frequency)) ? 1 : Functions::flattenSingleValue($frequency); $frequency = (is_null($frequency)) ? 1 : Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis); $basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis);
// Validate // Validate
if ((is_numeric($rate)) && (is_numeric($par))) { if ((is_numeric($rate)) && (is_numeric($par))) {
@ -230,8 +230,8 @@ class Financial
$issue = Functions::flattenSingleValue($issue); $issue = Functions::flattenSingleValue($issue);
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$rate = Functions::flattenSingleValue($rate); $rate = Functions::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par); $par = (is_null($par)) ? 1000 : Functions::flattenSingleValue($par);
$basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis); $basis = (is_null($basis)) ? 0 : Functions::flattenSingleValue($basis);
// Validate // Validate
if ((is_numeric($rate)) && (is_numeric($par))) { if ((is_numeric($rate)) && (is_numeric($par))) {
@ -290,7 +290,7 @@ class Financial
$salvage = Functions::flattenSingleValue($salvage); $salvage = Functions::flattenSingleValue($salvage);
$period = floor(Functions::flattenSingleValue($period)); $period = floor(Functions::flattenSingleValue($period));
$rate = Functions::flattenSingleValue($rate); $rate = Functions::flattenSingleValue($rate);
$basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis); $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
// The depreciation coefficients are: // The depreciation coefficients are:
// Life of assets (1/rate) Depreciation coefficient // Life of assets (1/rate) Depreciation coefficient
@ -617,7 +617,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $frequency = (int) Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis); $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -672,7 +672,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $frequency = (int) Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis); $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -743,7 +743,7 @@ class Financial
$settlement = Functions::flattenSingleValue($settlement); $settlement = Functions::flattenSingleValue($settlement);
$maturity = Functions::flattenSingleValue($maturity); $maturity = Functions::flattenSingleValue($maturity);
$frequency = (int) Functions::flattenSingleValue($frequency); $frequency = (int) Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis); $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -1619,7 +1619,7 @@ class Financial
$yield = (float) Functions::flattenSingleValue($yield); $yield = (float) Functions::flattenSingleValue($yield);
$redemption = (float) Functions::flattenSingleValue($redemption); $redemption = (float) Functions::flattenSingleValue($redemption);
$frequency = (int) Functions::flattenSingleValue($frequency); $frequency = (int) Functions::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis); $basis = (is_null($basis)) ? 0 : (int) Functions::flattenSingleValue($basis);
if (is_string($settlement = DateTime::getDateValue($settlement))) { if (is_string($settlement = DateTime::getDateValue($settlement))) {
return Functions::VALUE(); return Functions::VALUE();
@ -1828,9 +1828,9 @@ class Financial
$nper = (int) Functions::flattenSingleValue($nper); $nper = (int) Functions::flattenSingleValue($nper);
$pmt = Functions::flattenSingleValue($pmt); $pmt = Functions::flattenSingleValue($pmt);
$pv = Functions::flattenSingleValue($pv); $pv = Functions::flattenSingleValue($pv);
$fv = (is_null($fv)) ? 0.0 : Functions::flattenSingleValue($fv); $fv = (is_null($fv)) ? 0.0 : Functions::flattenSingleValue($fv);
$type = (is_null($type)) ? 0 : (int) Functions::flattenSingleValue($type); $type = (is_null($type)) ? 0 : (int) Functions::flattenSingleValue($type);
$guess = (is_null($guess)) ? 0.1 : Functions::flattenSingleValue($guess); $guess = (is_null($guess)) ? 0.1 : Functions::flattenSingleValue($guess);
$rate = $guess; $rate = $guess;
if (abs($rate) < FINANCIAL_PRECISION) { if (abs($rate) < FINANCIAL_PRECISION) {

View File

@ -237,8 +237,8 @@ class Logical
*/ */
public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false) public static function statementIf($condition = true, $returnIfTrue = 0, $returnIfFalse = false)
{ {
$condition = (is_null($condition)) ? true : (boolean) Functions::flattenSingleValue($condition); $condition = (is_null($condition)) ? true : (boolean) Functions::flattenSingleValue($condition);
$returnIfTrue = (is_null($returnIfTrue)) ? 0 : Functions::flattenSingleValue($returnIfTrue); $returnIfTrue = (is_null($returnIfTrue)) ? 0 : Functions::flattenSingleValue($returnIfTrue);
$returnIfFalse = (is_null($returnIfFalse)) ? false : Functions::flattenSingleValue($returnIfFalse); $returnIfFalse = (is_null($returnIfFalse)) ? false : Functions::flattenSingleValue($returnIfFalse);
return ($condition) ? $returnIfTrue : $returnIfFalse; return ($condition) ? $returnIfTrue : $returnIfFalse;

View File

@ -260,7 +260,7 @@ class LookupRef
$args = func_get_args(); $args = func_get_args();
$pCell = array_pop($args); $pCell = array_pop($args);
$linkURL = (is_null($linkURL)) ? '' : Functions::flattenSingleValue($linkURL); $linkURL = (is_null($linkURL)) ? '' : Functions::flattenSingleValue($linkURL);
$displayName = (is_null($displayName)) ? '' : Functions::flattenSingleValue($displayName); $displayName = (is_null($displayName)) ? '' : Functions::flattenSingleValue($displayName);
if ((!is_object($pCell)) || (trim($linkURL) == '')) { if ((!is_object($pCell)) || (trim($linkURL) == '')) {

View File

@ -913,7 +913,7 @@ class MathTrig
public static function ROMAN($aValue, $style = 0) public static function ROMAN($aValue, $style = 0)
{ {
$aValue = Functions::flattenSingleValue($aValue); $aValue = Functions::flattenSingleValue($aValue);
$style = (is_null($style)) ? 0 : (integer) Functions::flattenSingleValue($style); $style = (is_null($style)) ? 0 : (integer) Functions::flattenSingleValue($style);
if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) { if ((!is_numeric($aValue)) || ($aValue < 0) || ($aValue >= 4000)) {
return Functions::VALUE(); return Functions::VALUE();
} }

View File

@ -520,8 +520,8 @@ class Statistical
]; ];
// Define lower and upper region break-points. // Define lower and upper region break-points.
$p_low = 0.02425; //Use lower region approx. below this $p_low = 0.02425; //Use lower region approx. below this
$p_high = 1 - $p_low; //Use upper region approx. above this $p_high = 1 - $p_low; //Use upper region approx. above this
if (0 < $p && $p < $p_low) { if (0 < $p && $p < $p_low) {
// Rational approximation for lower region. // Rational approximation for lower region.

View File

@ -35,14 +35,14 @@ class DataSeries
const TYPE_PIECHART = 'pieChart'; const TYPE_PIECHART = 'pieChart';
const TYPE_PIECHART_3D = 'pie3DChart'; const TYPE_PIECHART_3D = 'pie3DChart';
const TYPE_DOUGHTNUTCHART = 'doughnutChart'; const TYPE_DOUGHTNUTCHART = 'doughnutChart';
const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym const TYPE_DONUTCHART = self::TYPE_DOUGHTNUTCHART; // Synonym
const TYPE_SCATTERCHART = 'scatterChart'; const TYPE_SCATTERCHART = 'scatterChart';
const TYPE_SURFACECHART = 'surfaceChart'; const TYPE_SURFACECHART = 'surfaceChart';
const TYPE_SURFACECHART_3D = 'surface3DChart'; const TYPE_SURFACECHART_3D = 'surface3DChart';
const TYPE_RADARCHART = 'radarChart'; const TYPE_RADARCHART = 'radarChart';
const TYPE_BUBBLECHART = 'bubbleChart'; const TYPE_BUBBLECHART = 'bubbleChart';
const TYPE_STOCKCHART = 'stockChart'; const TYPE_STOCKCHART = 'stockChart';
const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym const TYPE_CANDLECHART = self::TYPE_STOCKCHART; // Synonym
const GROUPING_CLUSTERED = 'clustered'; const GROUPING_CLUSTERED = 'clustered';
const GROUPING_STACKED = 'stacked'; const GROUPING_STACKED = 'stacked';

View File

@ -29,12 +29,12 @@ namespace PhpSpreadsheet\Chart;
class Legend class Legend
{ {
/** Legend positions */ /** Legend positions */
const XL_LEGEND_POSITION_BOTTOM = -4107; // Below the chart. const XL_LEGEND_POSITION_BOTTOM = -4107; // Below the chart.
const XL_LEGEND_POSITION_CORNER = 2; // In the upper right-hand corner of the chart border. const XL_LEGEND_POSITION_CORNER = 2; // In the upper right-hand corner of the chart border.
const XL_LEGEND_POSITION_CUSTOM = -4161; // A custom position. const XL_LEGEND_POSITION_CUSTOM = -4161; // A custom position.
const XL_LEGEND_POSITION_LEFT = -4131; // Left of the chart. const XL_LEGEND_POSITION_LEFT = -4131; // Left of the chart.
const XL_LEGEND_POSITION_RIGHT = -4152; // Right of the chart. const XL_LEGEND_POSITION_RIGHT = -4152; // Right of the chart.
const XL_LEGEND_POSITION_TOP = -4160; // Above the chart. const XL_LEGEND_POSITION_TOP = -4160; // Above the chart.
const POSITION_RIGHT = 'r'; const POSITION_RIGHT = 'r';
const POSITION_LEFT = 'l'; const POSITION_LEFT = 'l';

View File

@ -33,10 +33,10 @@ class JpGraph
private static $height = 480; private static $height = 480;
private static $colourSet = [ private static $colourSet = [
'mediumpurple1', 'palegreen3', 'gold1', 'cadetblue1', 'mediumpurple1', 'palegreen3', 'gold1', 'cadetblue1',
'darkmagenta', 'coral', 'dodgerblue3', 'eggplant', 'darkmagenta', 'coral', 'dodgerblue3', 'eggplant',
'mediumblue', 'magenta', 'sandybrown', 'cyan', 'mediumblue', 'magenta', 'sandybrown', 'cyan',
'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen', 'firebrick1', 'forestgreen', 'deeppink4', 'darkolivegreen',
'goldenrod2', 'goldenrod2',
]; ];
@ -178,21 +178,21 @@ class JpGraph
$legendOverlay = $legend->getOverlay(); $legendOverlay = $legend->getOverlay();
switch ($legendPosition) { switch ($legendPosition) {
case 'r': case 'r':
$this->graph->legend->SetPos(0.01, 0.5, 'right', 'center'); // right $this->graph->legend->SetPos(0.01, 0.5, 'right', 'center'); // right
$this->graph->legend->SetColumns(1); $this->graph->legend->SetColumns(1);
break; break;
case 'l': case 'l':
$this->graph->legend->SetPos(0.01, 0.5, 'left', 'center'); // left $this->graph->legend->SetPos(0.01, 0.5, 'left', 'center'); // left
$this->graph->legend->SetColumns(1); $this->graph->legend->SetColumns(1);
break; break;
case 't': case 't':
$this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top $this->graph->legend->SetPos(0.5, 0.01, 'center', 'top'); // top
break; break;
case 'b': case 'b':
$this->graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); // bottom $this->graph->legend->SetPos(0.5, 0.99, 'center', 'bottom'); // bottom
break; break;
default: default:
$this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right $this->graph->legend->SetPos(0.01, 0.01, 'right', 'top'); // top-right
$this->graph->legend->SetColumns(1); $this->graph->legend->SetColumns(1);
break; break;
} }

View File

@ -260,7 +260,7 @@ class CSV extends BaseReader implements IReader
// Set our starting row based on whether we're in contiguous mode or not // Set our starting row based on whether we're in contiguous mode or not
$currentRow = 1; $currentRow = 1;
if ($this->contiguous) { if ($this->contiguous) {
$currentRow = ($this->contiguousRow == -1) ? $sheet->getHighestRow(): $this->contiguousRow; $currentRow = ($this->contiguousRow == -1) ? $sheet->getHighestRow() : $this->contiguousRow;
} }
// Loop through each line of the file in turn // Loop through each line of the file in turn

View File

@ -136,7 +136,7 @@ class Excel2007 extends BaseReader implements IReader
'SimpleXMLElement', 'SimpleXMLElement',
\PhpSpreadsheet\Settings::getLibXmlLoaderOptions() \PhpSpreadsheet\Settings::getLibXmlLoaderOptions()
) )
); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main" ); //~ http://schemas.openxmlformats.org/spreadsheetml/2006/main"
if ($xmlWorkbook->sheets) { if ($xmlWorkbook->sheets) {
foreach ($xmlWorkbook->sheets->sheet as $eleSheet) { foreach ($xmlWorkbook->sheets->sheet as $eleSheet) {
@ -541,7 +541,7 @@ class Excel2007 extends BaseReader implements IReader
} }
if (!is_null($macros)) { if (!is_null($macros)) {
$macrosCode = $this->getFromZipArchive($zip, 'xl/vbaProject.bin');//vbaProject.bin always in 'xl' dir and always named vbaProject.bin $macrosCode = $this->getFromZipArchive($zip, 'xl/vbaProject.bin'); //vbaProject.bin always in 'xl' dir and always named vbaProject.bin
if ($macrosCode !== false) { if ($macrosCode !== false) {
$excel->setMacrosCode($macrosCode); $excel->setMacrosCode($macrosCode);
$excel->setHasMacros(true); $excel->setHasMacros(true);
@ -1313,7 +1313,7 @@ class Excel2007 extends BaseReader implements IReader
foreach (\PhpSpreadsheet\Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) { foreach (\PhpSpreadsheet\Cell::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) {
$cell = $docSheet->getCell($cellReference); $cell = $docSheet->getCell($cellReference);
if (isset($linkRel['id'])) { if (isset($linkRel['id'])) {
$hyperlinkUrl = $hyperlinks[ (string) $linkRel['id'] ]; $hyperlinkUrl = $hyperlinks[(string) $linkRel['id']];
if (isset($hyperlink['location'])) { if (isset($hyperlink['location'])) {
$hyperlinkUrl .= '#' . (string) $hyperlink['location']; $hyperlinkUrl .= '#' . (string) $hyperlink['location'];
} }
@ -1740,10 +1740,10 @@ class Excel2007 extends BaseReader implements IReader
} }
break; break;
case '_xlnm.Print_Area': case '_xlnm.Print_Area':
$rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma? $rangeSets = explode(',', $extractedRange); // FIXME: what if sheetname contains comma?
$newRangeSets = []; $newRangeSets = [];
foreach ($rangeSets as $rangeSet) { foreach ($rangeSets as $rangeSet) {
$range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark? $range = explode('!', $rangeSet); // FIXME: what if sheetname contains exclamation mark?
$rangeSet = isset($range[1]) ? $range[1] : $range[0]; $rangeSet = isset($range[1]) ? $range[1] : $range[0];
if (strpos($rangeSet, ':') === false) { if (strpos($rangeSet, ':') === false) {
$rangeSet = $rangeSet . ':' . $rangeSet; $rangeSet = $rangeSet . ':' . $rangeSet;

View File

@ -1122,7 +1122,7 @@ class Excel5 extends BaseReader implements IReader
// $range should look like one of these // $range should look like one of these
// Foo!$C$7:$J$66 // Foo!$C$7:$J$66
// Bar!$A$1:$IV$2 // Bar!$A$1:$IV$2
$explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark? $explodes = explode('!', $range); // FIXME: what if sheetname contains exclamation mark?
$sheetName = trim($explodes[0], "'"); $sheetName = trim($explodes[0], "'");
if (count($explodes) == 2) { if (count($explodes) == 2) {
if (strpos($explodes[1], ':') === false) { if (strpos($explodes[1], ':') === false) {

View File

@ -104,7 +104,7 @@ class Gnumeric extends BaseReader implements IReader
$worksheetNames = []; $worksheetNames = [];
while ($xml->read()) { while ($xml->read()) {
if ($xml->name == 'gnm:SheetName' && $xml->nodeType == XMLReader::ELEMENT) { if ($xml->name == 'gnm:SheetName' && $xml->nodeType == XMLReader::ELEMENT) {
$xml->read(); // Move onto the value node $xml->read(); // Move onto the value node
$worksheetNames[] = (string) $xml->value; $worksheetNames[] = (string) $xml->value;
} elseif ($xml->name == 'gnm:Sheets') { } elseif ($xml->name == 'gnm:Sheets') {
// break out of the loop once we've got our sheet names rather than parse the entire file // break out of the loop once we've got our sheet names rather than parse the entire file
@ -145,14 +145,14 @@ class Gnumeric extends BaseReader implements IReader
while ($xml->read()) { while ($xml->read()) {
if ($xml->name == 'gnm:Name' && $xml->nodeType == XMLReader::ELEMENT) { if ($xml->name == 'gnm:Name' && $xml->nodeType == XMLReader::ELEMENT) {
$xml->read(); // Move onto the value node $xml->read(); // Move onto the value node
$tmpInfo['worksheetName'] = (string) $xml->value; $tmpInfo['worksheetName'] = (string) $xml->value;
} elseif ($xml->name == 'gnm:MaxCol' && $xml->nodeType == XMLReader::ELEMENT) { } elseif ($xml->name == 'gnm:MaxCol' && $xml->nodeType == XMLReader::ELEMENT) {
$xml->read(); // Move onto the value node $xml->read(); // Move onto the value node
$tmpInfo['lastColumnIndex'] = (int) $xml->value; $tmpInfo['lastColumnIndex'] = (int) $xml->value;
$tmpInfo['totalColumns'] = (int) $xml->value + 1; $tmpInfo['totalColumns'] = (int) $xml->value + 1;
} elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) { } elseif ($xml->name == 'gnm:MaxRow' && $xml->nodeType == XMLReader::ELEMENT) {
$xml->read(); // Move onto the value node $xml->read(); // Move onto the value node
$tmpInfo['totalRows'] = (int) $xml->value + 1; $tmpInfo['totalRows'] = (int) $xml->value + 1;
break; break;
} }
@ -351,7 +351,7 @@ class Gnumeric extends BaseReader implements IReader
if (isset($sheet->PrintInformation->Margins)) { if (isset($sheet->PrintInformation->Margins)) {
foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) { foreach ($sheet->PrintInformation->Margins->children('gnm', true) as $key => $margin) {
$marginAttributes = $margin->attributes(); $marginAttributes = $margin->attributes();
$marginSize = 72 / 100; // Default $marginSize = 72 / 100; // Default
switch ($marginAttributes['PrefUnit']) { switch ($marginAttributes['PrefUnit']) {
case 'mm': case 'mm':
$marginSize = intval($marginAttributes['Points']) / 100; $marginSize = intval($marginAttributes['Points']) / 100;
@ -437,7 +437,7 @@ class Gnumeric extends BaseReader implements IReader
break; break;
case '20': // Boolean case '20': // Boolean
$type = \PhpSpreadsheet\Cell\DataType::TYPE_BOOL; $type = \PhpSpreadsheet\Cell\DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? true: false; $cell = ($cell == 'TRUE') ? true : false;
break; break;
case '30': // Integer case '30': // Integer
$cell = intval($cell); $cell = intval($cell);

View File

@ -626,10 +626,10 @@ class OOCalc extends BaseReader implements IReader
foreach ($temp as &$value) { foreach ($temp as &$value) {
// Only replace in alternate array entries (i.e. non-quoted blocks) // Only replace in alternate array entries (i.e. non-quoted blocks)
if ($tKey = !$tKey) { if ($tKey = !$tKey) {
$value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value); // Cell range reference in another sheet $value = preg_replace('/\[([^\.]+)\.([^\.]+):\.([^\.]+)\]/Ui', '$1!$2:$3', $value); // Cell range reference in another sheet
$value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); // Cell reference in another sheet $value = preg_replace('/\[([^\.]+)\.([^\.]+)\]/Ui', '$1!$2', $value); // Cell reference in another sheet
$value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference $value = preg_replace('/\[\.([^\.]+):\.([^\.]+)\]/Ui', '$1:$2', $value); // Cell range reference
$value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference $value = preg_replace('/\[\.([^\.]+)\]/Ui', '$1', $value); // Simple cell reference
$value = \PhpSpreadsheet\Calculation::translateSeparator(';', ',', $value, $inBraces); $value = \PhpSpreadsheet\Calculation::translateSeparator(';', ',', $value, $inBraces);
} }
} }

View File

@ -219,8 +219,8 @@ class SYLK extends BaseReader implements IReader
} }
$spreadsheet->setActiveSheetIndex($this->sheetIndex); $spreadsheet->setActiveSheetIndex($this->sheetIndex);
$fromFormats = ['\-', '\ ']; $fromFormats = ['\-', '\ '];
$toFormats = ['-', ' ']; $toFormats = ['-', ' '];
// Loop through file // Loop through file
$rowData = []; $rowData = [];

View File

@ -169,8 +169,7 @@ class ReferenceHelper
{ {
$aBreaks = $pSheet->getBreaks(); $aBreaks = $pSheet->getBreaks();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aBreaks, ['self', 'cellReverseSort']) : uksort($aBreaks, ['self', 'cellReverseSort']) : uksort($aBreaks, ['self', 'cellSort']);
uksort($aBreaks, ['self', 'cellSort']);
foreach ($aBreaks as $key => $value) { foreach ($aBreaks as $key => $value) {
if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) { if (self::cellAddressInDeleteRange($key, $beforeRow, $pNumRows, $beforeColumnIndex, $pNumCols)) {
@ -230,8 +229,7 @@ class ReferenceHelper
{ {
$aHyperlinkCollection = $pSheet->getHyperlinkCollection(); $aHyperlinkCollection = $pSheet->getHyperlinkCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aHyperlinkCollection, ['self', 'cellReverseSort']) : uksort($aHyperlinkCollection, ['self', 'cellReverseSort']) : uksort($aHyperlinkCollection, ['self', 'cellSort']);
uksort($aHyperlinkCollection, ['self', 'cellSort']);
foreach ($aHyperlinkCollection as $key => $value) { foreach ($aHyperlinkCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
@ -256,8 +254,7 @@ class ReferenceHelper
{ {
$aDataValidationCollection = $pSheet->getDataValidationCollection(); $aDataValidationCollection = $pSheet->getDataValidationCollection();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aDataValidationCollection, ['self', 'cellReverseSort']) : uksort($aDataValidationCollection, ['self', 'cellReverseSort']) : uksort($aDataValidationCollection, ['self', 'cellSort']);
uksort($aDataValidationCollection, ['self', 'cellSort']);
foreach ($aDataValidationCollection as $key => $value) { foreach ($aDataValidationCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
@ -303,8 +300,7 @@ class ReferenceHelper
{ {
$aProtectedCells = $pSheet->getProtectedCells(); $aProtectedCells = $pSheet->getProtectedCells();
($pNumCols > 0 || $pNumRows > 0) ? ($pNumCols > 0 || $pNumRows > 0) ?
uksort($aProtectedCells, ['self', 'cellReverseSort']) : uksort($aProtectedCells, ['self', 'cellReverseSort']) : uksort($aProtectedCells, ['self', 'cellSort']);
uksort($aProtectedCells, ['self', 'cellSort']);
foreach ($aProtectedCells as $key => $value) { foreach ($aProtectedCells as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {

View File

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

View File

@ -29,8 +29,8 @@ namespace PhpSpreadsheet\Shared;
class Date class Date
{ {
/** constants */ /** constants */
const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0 const CALENDAR_WINDOWS_1900 = 1900; // Base date of 1st Jan 1900 = 1.0
const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0 const CALENDAR_MAC_1904 = 1904; // Base date of 2nd Jan 1904 = 1.0
/* /*
* Names of the months of the year, indexed by shortname * Names of the months of the year, indexed by shortname

View File

@ -233,8 +233,8 @@ class Excel5
$y1 = $offsetY; $y1 = $offsetY;
// Initialise end cell to the same as the start cell // Initialise end cell to the same as the start cell
$col_end = $col_start; // Col containing lower right corner of object $col_end = $col_start; // Col containing lower right corner of object
$row_end = $row_start; // Row containing bottom right corner of object $row_end = $row_start; // Row containing bottom right corner of object
// Zero the specified offset if greater than the cell dimensions // Zero the specified offset if greater than the cell dimensions
if ($x1 >= self::sizeCol($sheet, \PhpSpreadsheet\Cell::stringFromColumnIndex($col_start))) { if ($x1 >= self::sizeCol($sheet, \PhpSpreadsheet\Cell::stringFromColumnIndex($col_start))) {

View File

@ -45,8 +45,8 @@ class Font
const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80; const CHARSET_ANSI_JAPANESE_SHIFTJIS = 0x80;
const CHARSET_ANSI_KOREAN_HANGUL = 0x81; const CHARSET_ANSI_KOREAN_HANGUL = 0x81;
const CHARSET_ANSI_KOREAN_JOHAB = 0x82; const CHARSET_ANSI_KOREAN_JOHAB = 0x82;
const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86; // gb2312 const CHARSET_ANSI_CHINESE_SIMIPLIFIED = 0x86; // gb2312
const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88; // big5 const CHARSET_ANSI_CHINESE_TRADITIONAL = 0x88; // big5
const CHARSET_ANSI_GREEK = 0xA1; const CHARSET_ANSI_GREEK = 0xA1;
const CHARSET_ANSI_TURKISH = 0xA2; const CHARSET_ANSI_TURKISH = 0xA2;
const CHARSET_ANSI_VIETNAMESE = 0xA3; const CHARSET_ANSI_VIETNAMESE = 0xA3;

View File

@ -184,7 +184,7 @@ class PPS
. \PhpSpreadsheet\Shared\OLE::localDateToOLE($this->Time2nd) // 116 . \PhpSpreadsheet\Shared\OLE::localDateToOLE($this->Time2nd) // 116
. pack('V', isset($this->startBlock) ? $this->startBlock : 0) // 120 . pack('V', isset($this->startBlock) ? $this->startBlock : 0) // 120
. pack('V', $this->Size) // 124 . pack('V', $this->Size) // 124
. pack('V', 0); // 128 . pack('V', 0); // 128
return $ret; return $ret;
} }

View File

@ -63,11 +63,11 @@ class Root extends \PhpSpreadsheet\Shared\OLE\PPS
// Initial Setting for saving // Initial Setting for saving
$this->_BIG_BLOCK_SIZE = pow( $this->_BIG_BLOCK_SIZE = pow(
2, 2,
(isset($this->_BIG_BLOCK_SIZE))? self::adjust2($this->_BIG_BLOCK_SIZE) : 9 (isset($this->_BIG_BLOCK_SIZE)) ? self::adjust2($this->_BIG_BLOCK_SIZE) : 9
); );
$this->_SMALL_BLOCK_SIZE = pow( $this->_SMALL_BLOCK_SIZE = pow(
2, 2,
(isset($this->_SMALL_BLOCK_SIZE))? self::adjust2($this->_SMALL_BLOCK_SIZE) : 6 (isset($this->_SMALL_BLOCK_SIZE)) ? self::adjust2($this->_SMALL_BLOCK_SIZE) : 6
); );
if (is_resource($filename)) { if (is_resource($filename)) {
@ -130,21 +130,21 @@ class Root extends \PhpSpreadsheet\Shared\OLE\PPS
$raList[$i]->Size = $raList[$i]->getDataLen(); $raList[$i]->Size = $raList[$i]->getDataLen();
if ($raList[$i]->Size < \PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL) { if ($raList[$i]->Size < \PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL) {
$iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) $iSBcnt += floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0); + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) ? 1 : 0);
} else { } else {
$iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) + $iBBcnt += (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0)); (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) ? 1 : 0));
} }
} }
} }
$iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE; $iSmallLen = $iSBcnt * $this->_SMALL_BLOCK_SIZE;
$iSlCnt = floor($this->_BIG_BLOCK_SIZE / \PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE); $iSlCnt = floor($this->_BIG_BLOCK_SIZE / \PhpSpreadsheet\Shared\OLE::OLE_LONG_INT_SIZE);
$iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt)? 1:0); $iSBDcnt = floor($iSBcnt / $iSlCnt) + (($iSBcnt % $iSlCnt) ? 1 : 0);
$iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) + $iBBcnt += (floor($iSmallLen / $this->_BIG_BLOCK_SIZE) +
(($iSmallLen % $this->_BIG_BLOCK_SIZE)? 1: 0)); (($iSmallLen % $this->_BIG_BLOCK_SIZE) ? 1 : 0));
$iCnt = count($raList); $iCnt = count($raList);
$iBdCnt = $this->_BIG_BLOCK_SIZE / \PhpSpreadsheet\Shared\OLE::OLE_PPS_SIZE; $iBdCnt = $this->_BIG_BLOCK_SIZE / \PhpSpreadsheet\Shared\OLE::OLE_PPS_SIZE;
$iPPScnt = (floor($iCnt / $iBdCnt) + (($iCnt % $iBdCnt)? 1: 0)); $iPPScnt = (floor($iCnt / $iBdCnt) + (($iCnt % $iBdCnt) ? 1 : 0));
return [$iSBDcnt, $iBBcnt, $iPPScnt]; return [$iSBDcnt, $iBBcnt, $iPPScnt];
} }
@ -160,7 +160,7 @@ class Root extends \PhpSpreadsheet\Shared\OLE\PPS
{ {
$iWk = log($i2) / log(2); $iWk = log($i2) / log(2);
return ($iWk > floor($iWk))? floor($iWk) + 1:$iWk; return ($iWk > floor($iWk)) ? floor($iWk) + 1 : $iWk;
} }
/** /**
@ -181,16 +181,16 @@ class Root extends \PhpSpreadsheet\Shared\OLE\PPS
$iBdExL = 0; $iBdExL = 0;
$iAll = $iBBcnt + $iPPScnt + $iSBDcnt; $iAll = $iBBcnt + $iPPScnt + $iSBDcnt;
$iAllW = $iAll; $iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0); $iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt) ? 1 : 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW + $iBdCntW) % $iBlCnt)? 1: 0); $iBdCnt = floor(($iAll + $iBdCntW) / $iBlCnt) + ((($iAllW + $iBdCntW) % $iBlCnt) ? 1 : 0);
// Calculate BD count // Calculate BD count
if ($iBdCnt > $i1stBdL) { if ($iBdCnt > $i1stBdL) {
while (1) { while (1) {
++$iBdExL; ++$iBdExL;
++$iAllW; ++$iAllW;
$iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt)? 1: 0); $iBdCntW = floor($iAllW / $iBlCnt) + (($iAllW % $iBlCnt) ? 1 : 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW + $iBdCntW) % $iBlCnt)? 1: 0); $iBdCnt = floor(($iAllW + $iBdCntW) / $iBlCnt) + ((($iAllW + $iBdCntW) % $iBlCnt) ? 1 : 0);
if ($iBdCnt <= ($iBdExL * $iBlCnt + $i1stBdL)) { if ($iBdCnt <= ($iBdExL * $iBlCnt + $i1stBdL)) {
break; break;
} }
@ -278,7 +278,7 @@ class Root extends \PhpSpreadsheet\Shared\OLE\PPS
$raList[$i]->startBlock = $iStBlk; $raList[$i]->startBlock = $iStBlk;
$iStBlk += $iStBlk +=
(floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) + (floor($raList[$i]->Size / $this->_BIG_BLOCK_SIZE) +
(($raList[$i]->Size % $this->_BIG_BLOCK_SIZE)? 1: 0)); (($raList[$i]->Size % $this->_BIG_BLOCK_SIZE) ? 1 : 0));
} }
// Close file for each PPS, and unlink it // Close file for each PPS, and unlink it
//if (isset($raList[$i]->_PPS_FILE)) { //if (isset($raList[$i]->_PPS_FILE)) {
@ -310,7 +310,7 @@ class Root extends \PhpSpreadsheet\Shared\OLE\PPS
} }
if ($raList[$i]->Size < \PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL) { if ($raList[$i]->Size < \PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL) {
$iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE) $iSmbCnt = floor($raList[$i]->Size / $this->_SMALL_BLOCK_SIZE)
+ (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE)? 1: 0); + (($raList[$i]->Size % $this->_SMALL_BLOCK_SIZE) ? 1 : 0);
// Add to SBD // Add to SBD
$jB = $iSmbCnt - 1; $jB = $iSmbCnt - 1;
for ($j = 0; $j < $jB; ++$j) { for ($j = 0; $j < $jB; ++$j) {
@ -384,15 +384,15 @@ class Root extends \PhpSpreadsheet\Shared\OLE\PPS
$iBdExL = 0; $iBdExL = 0;
$iAll = $iBsize + $iPpsCnt + $iSbdSize; $iAll = $iBsize + $iPpsCnt + $iSbdSize;
$iAllW = $iAll; $iAllW = $iAll;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0); $iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt) ? 1 : 0);
$iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW + $iBdCntW) % $iBbCnt)? 1: 0); $iBdCnt = floor(($iAll + $iBdCntW) / $iBbCnt) + ((($iAllW + $iBdCntW) % $iBbCnt) ? 1 : 0);
// Calculate BD count // Calculate BD count
if ($iBdCnt > $i1stBdL) { if ($iBdCnt > $i1stBdL) {
while (1) { while (1) {
++$iBdExL; ++$iBdExL;
++$iAllW; ++$iAllW;
$iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt)? 1: 0); $iBdCntW = floor($iAllW / $iBbCnt) + (($iAllW % $iBbCnt) ? 1 : 0);
$iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW + $iBdCntW) % $iBbCnt)? 1: 0); $iBdCnt = floor(($iAllW + $iBdCntW) / $iBbCnt) + ((($iAllW + $iBdCntW) % $iBbCnt) ? 1 : 0);
if ($iBdCnt <= ($iBdExL * $iBbCnt + $i1stBdL)) { if ($iBdCnt <= ($iBdExL * $iBbCnt + $i1stBdL)) {
break; break;
} }

View File

@ -2592,7 +2592,7 @@ class PclZip
// ----- Set the file properties // ----- Set the file properties
$p_header['size'] = 0; $p_header['size'] = 0;
//$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
$p_header['external'] = 0x00000010; // Value for a folder : to be checked $p_header['external'] = 0x00000010; // Value for a folder : to be checked
// ----- Call the header generation // ----- Call the header generation
if (($v_result = $this->privWriteFileHeader($p_header)) != 1) { if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
@ -4980,7 +4980,7 @@ function PclZipUtilPathReduction($p_dir)
if ($v_skip > 0) { if ($v_skip > 0) {
--$v_skip; --$v_skip;
} else { } else {
$v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1)?'/' . $v_result:''); $v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? '/' . $v_result : '');
} }
} }
} }

View File

@ -41,14 +41,14 @@ class PasswordHasher
public static function hashPassword($pPassword = '') public static function hashPassword($pPassword = '')
{ {
$password = 0x0000; $password = 0x0000;
$charPos = 1; // char position $charPos = 1; // char position
// split the plain text password in its component characters // split the plain text password in its component characters
$chars = preg_split('//', $pPassword, -1, PREG_SPLIT_NO_EMPTY); $chars = preg_split('//', $pPassword, -1, PREG_SPLIT_NO_EMPTY);
foreach ($chars as $char) { foreach ($chars as $char) {
$value = ord($char) << $charPos++; // shifted ASCII value $value = ord($char) << $charPos++; // shifted ASCII value
$rotated_bits = $value >> 15; // rotated bits beyond bit 15 $rotated_bits = $value >> 15; // rotated bits beyond bit 15
$value &= 0x7fff; // first 15 bits $value &= 0x7fff; // first 15 bits
$password ^= ($value | $rotated_bits); $password ^= ($value | $rotated_bits);
} }

View File

@ -621,7 +621,7 @@ class Style extends Style\Supervisor implements IComparable
$this->numberFormat->getHashCode() . $this->numberFormat->getHashCode() .
$hashConditionals . $hashConditionals .
$this->protection->getHashCode() . $this->protection->getHashCode() .
($this->quotePrefix ? 't' : 'f') . ($this->quotePrefix ? 't' : 'f') .
__CLASS__ __CLASS__
); );
} }

View File

@ -34,14 +34,14 @@ class Alignment extends Supervisor implements \PhpSpreadsheet\IComparable
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous'; const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
const HORIZONTAL_JUSTIFY = 'justify'; const HORIZONTAL_JUSTIFY = 'justify';
const HORIZONTAL_FILL = 'fill'; const HORIZONTAL_FILL = 'fill';
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
/* Vertical alignment styles */ /* Vertical alignment styles */
const VERTICAL_BOTTOM = 'bottom'; const VERTICAL_BOTTOM = 'bottom';
const VERTICAL_TOP = 'top'; const VERTICAL_TOP = 'top';
const VERTICAL_CENTER = 'center'; const VERTICAL_CENTER = 'center';
const VERTICAL_JUSTIFY = 'justify'; const VERTICAL_JUSTIFY = 'justify';
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
/* Read order */ /* Read order */
const READORDER_CONTEXT = 0; const READORDER_CONTEXT = 0;

View File

@ -362,62 +362,62 @@ class Color extends Supervisor implements \PhpSpreadsheet\IComparable
// Indexed colors // Indexed colors
if (is_null(self::$indexedColors)) { if (is_null(self::$indexedColors)) {
self::$indexedColors = [ self::$indexedColors = [
1 => 'FF000000', // System Colour #1 - Black 1 => 'FF000000', // System Colour #1 - Black
2 => 'FFFFFFFF', // System Colour #2 - White 2 => 'FFFFFFFF', // System Colour #2 - White
3 => 'FFFF0000', // System Colour #3 - Red 3 => 'FFFF0000', // System Colour #3 - Red
4 => 'FF00FF00', // System Colour #4 - Green 4 => 'FF00FF00', // System Colour #4 - Green
5 => 'FF0000FF', // System Colour #5 - Blue 5 => 'FF0000FF', // System Colour #5 - Blue
6 => 'FFFFFF00', // System Colour #6 - Yellow 6 => 'FFFFFF00', // System Colour #6 - Yellow
7 => 'FFFF00FF', // System Colour #7- Magenta 7 => 'FFFF00FF', // System Colour #7- Magenta
8 => 'FF00FFFF', // System Colour #8- Cyan 8 => 'FF00FFFF', // System Colour #8- Cyan
9 => 'FF800000', // Standard Colour #9 9 => 'FF800000', // Standard Colour #9
10 => 'FF008000', // Standard Colour #10 10 => 'FF008000', // Standard Colour #10
11 => 'FF000080', // Standard Colour #11 11 => 'FF000080', // Standard Colour #11
12 => 'FF808000', // Standard Colour #12 12 => 'FF808000', // Standard Colour #12
13 => 'FF800080', // Standard Colour #13 13 => 'FF800080', // Standard Colour #13
14 => 'FF008080', // Standard Colour #14 14 => 'FF008080', // Standard Colour #14
15 => 'FFC0C0C0', // Standard Colour #15 15 => 'FFC0C0C0', // Standard Colour #15
16 => 'FF808080', // Standard Colour #16 16 => 'FF808080', // Standard Colour #16
17 => 'FF9999FF', // Chart Fill Colour #17 17 => 'FF9999FF', // Chart Fill Colour #17
18 => 'FF993366', // Chart Fill Colour #18 18 => 'FF993366', // Chart Fill Colour #18
19 => 'FFFFFFCC', // Chart Fill Colour #19 19 => 'FFFFFFCC', // Chart Fill Colour #19
20 => 'FFCCFFFF', // Chart Fill Colour #20 20 => 'FFCCFFFF', // Chart Fill Colour #20
21 => 'FF660066', // Chart Fill Colour #21 21 => 'FF660066', // Chart Fill Colour #21
22 => 'FFFF8080', // Chart Fill Colour #22 22 => 'FFFF8080', // Chart Fill Colour #22
23 => 'FF0066CC', // Chart Fill Colour #23 23 => 'FF0066CC', // Chart Fill Colour #23
24 => 'FFCCCCFF', // Chart Fill Colour #24 24 => 'FFCCCCFF', // Chart Fill Colour #24
25 => 'FF000080', // Chart Line Colour #25 25 => 'FF000080', // Chart Line Colour #25
26 => 'FFFF00FF', // Chart Line Colour #26 26 => 'FFFF00FF', // Chart Line Colour #26
27 => 'FFFFFF00', // Chart Line Colour #27 27 => 'FFFFFF00', // Chart Line Colour #27
28 => 'FF00FFFF', // Chart Line Colour #28 28 => 'FF00FFFF', // Chart Line Colour #28
29 => 'FF800080', // Chart Line Colour #29 29 => 'FF800080', // Chart Line Colour #29
30 => 'FF800000', // Chart Line Colour #30 30 => 'FF800000', // Chart Line Colour #30
31 => 'FF008080', // Chart Line Colour #31 31 => 'FF008080', // Chart Line Colour #31
32 => 'FF0000FF', // Chart Line Colour #32 32 => 'FF0000FF', // Chart Line Colour #32
33 => 'FF00CCFF', // Standard Colour #33 33 => 'FF00CCFF', // Standard Colour #33
34 => 'FFCCFFFF', // Standard Colour #34 34 => 'FFCCFFFF', // Standard Colour #34
35 => 'FFCCFFCC', // Standard Colour #35 35 => 'FFCCFFCC', // Standard Colour #35
36 => 'FFFFFF99', // Standard Colour #36 36 => 'FFFFFF99', // Standard Colour #36
37 => 'FF99CCFF', // Standard Colour #37 37 => 'FF99CCFF', // Standard Colour #37
38 => 'FFFF99CC', // Standard Colour #38 38 => 'FFFF99CC', // Standard Colour #38
39 => 'FFCC99FF', // Standard Colour #39 39 => 'FFCC99FF', // Standard Colour #39
40 => 'FFFFCC99', // Standard Colour #40 40 => 'FFFFCC99', // Standard Colour #40
41 => 'FF3366FF', // Standard Colour #41 41 => 'FF3366FF', // Standard Colour #41
42 => 'FF33CCCC', // Standard Colour #42 42 => 'FF33CCCC', // Standard Colour #42
43 => 'FF99CC00', // Standard Colour #43 43 => 'FF99CC00', // Standard Colour #43
44 => 'FFFFCC00', // Standard Colour #44 44 => 'FFFFCC00', // Standard Colour #44
45 => 'FFFF9900', // Standard Colour #45 45 => 'FFFF9900', // Standard Colour #45
46 => 'FFFF6600', // Standard Colour #46 46 => 'FFFF6600', // Standard Colour #46
47 => 'FF666699', // Standard Colour #47 47 => 'FF666699', // Standard Colour #47
48 => 'FF969696', // Standard Colour #48 48 => 'FF969696', // Standard Colour #48
49 => 'FF003366', // Standard Colour #49 49 => 'FF003366', // Standard Colour #49
50 => 'FF339966', // Standard Colour #50 50 => 'FF339966', // Standard Colour #50
51 => 'FF003300', // Standard Colour #51 51 => 'FF003300', // Standard Colour #51
52 => 'FF333300', // Standard Colour #52 52 => 'FF333300', // Standard Colour #52
53 => 'FF993300', // Standard Colour #53 53 => 'FF993300', // Standard Colour #53
54 => 'FF993366', // Standard Colour #54 54 => 'FF993366', // Standard Colour #54
55 => 'FF333399', // Standard Colour #55 55 => 'FF333399', // Standard Colour #55
56 => 'FF333333', // Standard Colour #56 56 => 'FF333333', // Standard Colour #56
]; ];
} }

View File

@ -286,7 +286,7 @@ class NumberFormat extends Supervisor implements \PhpSpreadsheet\IComparable
self::$builtInFormats[11] = '0.00E+00'; self::$builtInFormats[11] = '0.00E+00';
self::$builtInFormats[12] = '# ?/?'; self::$builtInFormats[12] = '# ?/?';
self::$builtInFormats[13] = '# ??/??'; self::$builtInFormats[13] = '# ??/??';
self::$builtInFormats[14] = 'm/d/yyyy'; // Despite ECMA 'mm-dd-yy'; self::$builtInFormats[14] = 'm/d/yyyy'; // Despite ECMA 'mm-dd-yy';
self::$builtInFormats[15] = 'd-mmm-yy'; self::$builtInFormats[15] = 'd-mmm-yy';
self::$builtInFormats[16] = 'd-mmm'; self::$builtInFormats[16] = 'd-mmm';
self::$builtInFormats[17] = 'mmm-yy'; self::$builtInFormats[17] = 'mmm-yy';
@ -294,17 +294,17 @@ class NumberFormat extends Supervisor implements \PhpSpreadsheet\IComparable
self::$builtInFormats[19] = 'h:mm:ss AM/PM'; self::$builtInFormats[19] = 'h:mm:ss AM/PM';
self::$builtInFormats[20] = 'h:mm'; self::$builtInFormats[20] = 'h:mm';
self::$builtInFormats[21] = 'h:mm:ss'; self::$builtInFormats[21] = 'h:mm:ss';
self::$builtInFormats[22] = 'm/d/yyyy h:mm'; // Despite ECMA 'm/d/yy h:mm'; self::$builtInFormats[22] = 'm/d/yyyy h:mm'; // Despite ECMA 'm/d/yy h:mm';
self::$builtInFormats[37] = '#,##0_);(#,##0)'; // Despite ECMA '#,##0 ;(#,##0)'; self::$builtInFormats[37] = '#,##0_);(#,##0)'; // Despite ECMA '#,##0 ;(#,##0)';
self::$builtInFormats[38] = '#,##0_);[Red](#,##0)'; // Despite ECMA '#,##0 ;[Red](#,##0)'; self::$builtInFormats[38] = '#,##0_);[Red](#,##0)'; // Despite ECMA '#,##0 ;[Red](#,##0)';
self::$builtInFormats[39] = '#,##0.00_);(#,##0.00)'; // Despite ECMA '#,##0.00;(#,##0.00)'; self::$builtInFormats[39] = '#,##0.00_);(#,##0.00)'; // Despite ECMA '#,##0.00;(#,##0.00)';
self::$builtInFormats[40] = '#,##0.00_);[Red](#,##0.00)'; // Despite ECMA '#,##0.00;[Red](#,##0.00)'; self::$builtInFormats[40] = '#,##0.00_);[Red](#,##0.00)'; // Despite ECMA '#,##0.00;[Red](#,##0.00)';
self::$builtInFormats[44] = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'; self::$builtInFormats[44] = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
self::$builtInFormats[45] = 'mm:ss'; self::$builtInFormats[45] = 'mm:ss';
self::$builtInFormats[46] = '[h]:mm:ss'; self::$builtInFormats[46] = '[h]:mm:ss';
self::$builtInFormats[47] = 'mm:ss.0'; // Despite ECMA 'mmss.0'; self::$builtInFormats[47] = 'mm:ss.0'; // Despite ECMA 'mmss.0';
self::$builtInFormats[48] = '##0.0E+0'; self::$builtInFormats[48] = '##0.0E+0';
self::$builtInFormats[49] = '@'; self::$builtInFormats[49] = '@';

View File

@ -2962,7 +2962,7 @@ class Worksheet implements IComparable
if ($this->getCodeName() == $pValue) { if ($this->getCodeName() == $pValue) {
return $this; return $this;
} }
$pValue = str_replace(' ', '_', $pValue);//Excel does this automatically without flinching, we are doing the same $pValue = str_replace(' ', '_', $pValue); //Excel does this automatically without flinching, we are doing the same
// Syntax check // Syntax check
// throw an exception if not valid // throw an exception if not valid
self::checkSheetCodeName($pValue); self::checkSheetCodeName($pValue);
@ -2991,7 +2991,7 @@ class Worksheet implements IComparable
} }
} }
$pValue = $pValue . '_' . $i;// ok, we have a valid name $pValue = $pValue . '_' . $i; // ok, we have a valid name
//codeName is'nt used in formula : no need to call for an update //codeName is'nt used in formula : no need to call for an update
//return $this->setTitle($altTitle, $updateFormulaCellReferences); //return $this->setTitle($altTitle, $updateFormulaCellReferences);
} }

View File

@ -456,7 +456,7 @@ class AutoFilter
* @var array * @var array
*/ */
private static $fromReplace = ['\*', '\?', '~~', '~.*', '~.?']; private static $fromReplace = ['\*', '\?', '~~', '~.*', '~.?'];
private static $toReplace = ['.*', '.', '~', '\*', '\?']; private static $toReplace = ['.*', '.', '~', '\*', '\?'];
/** /**
* Convert a dynamic rule daterange to a custom filter range expression for ease of calculation * Convert a dynamic rule daterange to a custom filter range expression for ease of calculation

View File

@ -137,8 +137,7 @@ class BaseDrawing implements \PhpSpreadsheet\IComparable
$this->rotation = 0; $this->rotation = 0;
$this->shadow = new Drawing\Shadow(); $this->shadow = new Drawing\Shadow();
// Set image index // Set image index++self::$imageCounter;
++self::$imageCounter;
$this->imageIndex = self::$imageCounter; $this->imageIndex = self::$imageCounter;
} }

View File

@ -116,10 +116,10 @@ class CSV extends BaseWriter implements IWriter
} }
if ($this->excelCompatibility) { if ($this->excelCompatibility) {
$this->setUseBOM(true); // Enforce UTF-8 BOM Header $this->setUseBOM(true); // Enforce UTF-8 BOM Header
$this->setIncludeSeparatorLine(true); // Set separator line $this->setIncludeSeparatorLine(true); // Set separator line
$this->setEnclosure('"'); // Set enclosure to " $this->setEnclosure('"'); // Set enclosure to "
$this->setDelimiter(';'); // Set delimiter to a semi-colon $this->setDelimiter(';'); // Set delimiter to a semi-colon
$this->setLineEnding("\r\n"); $this->setLineEnding("\r\n");
} }
if ($this->useBOM) { if ($this->useBOM) {

View File

@ -139,8 +139,8 @@ class Excel2007 extends BaseWriter implements IWriter
$this->writerParts[$writer] = new $class($this); $this->writerParts[$writer] = new $class($this);
} }
$hashTablesArray = ['stylesConditionalHashTable', 'fillHashTable', 'fontHashTable', $hashTablesArray = ['stylesConditionalHashTable', 'fillHashTable', 'fontHashTable',
'bordersHashTable', 'numFmtHashTable', 'drawingHashTable', 'bordersHashTable', 'numFmtHashTable', 'drawingHashTable',
'styleHashTable', 'styleHashTable',
]; ];
@ -237,7 +237,7 @@ class Excel2007 extends BaseWriter implements IWriter
$macrosCode = $this->spreadSheet->getMacrosCode(); $macrosCode = $this->spreadSheet->getMacrosCode();
if (!is_null($macrosCode)) { if (!is_null($macrosCode)) {
// we have the code ? // we have the code ?
$objZip->addFromString('xl/vbaProject.bin', $macrosCode);//allways in 'xl', allways named vbaProject.bin $objZip->addFromString('xl/vbaProject.bin', $macrosCode); //allways in 'xl', allways named vbaProject.bin
if ($this->spreadSheet->hasMacrosCertificate()) { if ($this->spreadSheet->hasMacrosCertificate()) {
//signed macros ? //signed macros ?
// Yes : add the certificate file and the related rels file // Yes : add the certificate file and the related rels file
@ -252,7 +252,7 @@ class Excel2007 extends BaseWriter implements IWriter
$objZip->addFromString($tmpRibbonTarget, $this->spreadSheet->getRibbonXMLData('data')); $objZip->addFromString($tmpRibbonTarget, $this->spreadSheet->getRibbonXMLData('data'));
if ($this->spreadSheet->hasRibbonBinObjects()) { if ($this->spreadSheet->hasRibbonBinObjects()) {
$tmpRootPath = dirname($tmpRibbonTarget) . '/'; $tmpRootPath = dirname($tmpRibbonTarget) . '/';
$ribbonBinObjects = $this->spreadSheet->getRibbonBinObjects('data');//the files to write $ribbonBinObjects = $this->spreadSheet->getRibbonBinObjects('data'); //the files to write
foreach ($ribbonBinObjects as $aPath => $aContent) { foreach ($ribbonBinObjects as $aPath => $aContent) {
$objZip->addFromString($tmpRootPath . $aPath, $aContent); $objZip->addFromString($tmpRootPath . $aPath, $aContent);
} }

View File

@ -157,7 +157,7 @@ class ContentTypes extends WriterPart
// we need to write "Extension" but not already write for media content // we need to write "Extension" but not already write for media content
$tabRibbonTypes = array_diff($spreadsheet->getRibbonBinObjects('types'), array_keys($aMediaContentTypes)); $tabRibbonTypes = array_diff($spreadsheet->getRibbonBinObjects('types'), array_keys($aMediaContentTypes));
foreach ($tabRibbonTypes as $aRibbonType) { foreach ($tabRibbonTypes as $aRibbonType) {
$mimeType = 'image/.' . $aRibbonType;//we wrote $mimeType like customUI Editor $mimeType = 'image/.' . $aRibbonType; //we wrote $mimeType like customUI Editor
$this->writeDefaultContentType($objWriter, $aRibbonType, $mimeType); $this->writeDefaultContentType($objWriter, $aRibbonType, $mimeType);
} }
} }

View File

@ -166,7 +166,7 @@ class Rels extends WriterPart
'http://schemas.microsoft.com/office/2006/relationships/vbaProject', 'http://schemas.microsoft.com/office/2006/relationships/vbaProject',
'vbaProject.bin' 'vbaProject.bin'
); );
++$i;//increment i if needed for an another relation ++$i; //increment i if needed for an another relation
} }
$objWriter->endElement(); $objWriter->endElement();

View File

@ -40,7 +40,7 @@ class StringTable extends WriterPart
// Create string lookup table // Create string lookup table
$aStringTable = []; $aStringTable = [];
$cellCollection = null; $cellCollection = null;
$aFlippedStringTable = null; // For faster lookup $aFlippedStringTable = null; // For faster lookup
// Is an existing table given? // Is an existing table given?
if (($pExistingTable !== null) && is_array($pExistingTable)) { if (($pExistingTable !== null) && is_array($pExistingTable)) {

View File

@ -621,7 +621,7 @@ class Style extends WriterPart
/** @var \PhpSpreadsheet\Style $style */ /** @var \PhpSpreadsheet\Style $style */
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) { if (!array_key_exists($style->getFill()->getHashCode(), $aFills)) {
$aFills[ $style->getFill()->getHashCode() ] = $style->getFill(); $aFills[$style->getFill()->getHashCode()] = $style->getFill();
} }
} }
@ -644,7 +644,7 @@ class Style extends WriterPart
/** @var \PhpSpreadsheet\Style $style */ /** @var \PhpSpreadsheet\Style $style */
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) { if (!array_key_exists($style->getFont()->getHashCode(), $aFonts)) {
$aFonts[ $style->getFont()->getHashCode() ] = $style->getFont(); $aFonts[$style->getFont()->getHashCode()] = $style->getFont();
} }
} }
@ -667,7 +667,7 @@ class Style extends WriterPart
/** @var \PhpSpreadsheet\Style $style */ /** @var \PhpSpreadsheet\Style $style */
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) { if (!array_key_exists($style->getBorders()->getHashCode(), $aBorders)) {
$aBorders[ $style->getBorders()->getHashCode() ] = $style->getBorders(); $aBorders[$style->getBorders()->getHashCode()] = $style->getBorders();
} }
} }
@ -690,7 +690,7 @@ class Style extends WriterPart
/** @var \PhpSpreadsheet\Style $style */ /** @var \PhpSpreadsheet\Style $style */
foreach ($aStyles as $style) { foreach ($aStyles as $style) {
if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) { if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !array_key_exists($style->getNumberFormat()->getHashCode(), $aNumFmts)) {
$aNumFmts[ $style->getNumberFormat()->getHashCode() ] = $style->getNumberFormat(); $aNumFmts[$style->getNumberFormat()->getHashCode()] = $style->getNumberFormat();
} }
} }

View File

@ -566,10 +566,10 @@ class Worksheet extends WriterPart
$objWriter->writeAttribute('operator', $dv->getOperator()); $objWriter->writeAttribute('operator', $dv->getOperator());
} }
$objWriter->writeAttribute('allowBlank', ($dv->getAllowBlank() ? '1' : '0')); $objWriter->writeAttribute('allowBlank', ($dv->getAllowBlank() ? '1' : '0'));
$objWriter->writeAttribute('showDropDown', (!$dv->getShowDropDown() ? '1' : '0')); $objWriter->writeAttribute('showDropDown', (!$dv->getShowDropDown() ? '1' : '0'));
$objWriter->writeAttribute('showInputMessage', ($dv->getShowInputMessage() ? '1' : '0')); $objWriter->writeAttribute('showInputMessage', ($dv->getShowInputMessage() ? '1' : '0'));
$objWriter->writeAttribute('showErrorMessage', ($dv->getShowErrorMessage() ? '1' : '0')); $objWriter->writeAttribute('showErrorMessage', ($dv->getShowErrorMessage() ? '1' : '0'));
if ($dv->getErrorTitle() !== '') { if ($dv->getErrorTitle() !== '') {
$objWriter->writeAttribute('errorTitle', $dv->getErrorTitle()); $objWriter->writeAttribute('errorTitle', $dv->getErrorTitle());
@ -707,7 +707,7 @@ class Worksheet extends WriterPart
// printOptions // printOptions
$objWriter->startElement('printOptions'); $objWriter->startElement('printOptions');
$objWriter->writeAttribute('gridLines', ($pSheet->getPrintGridlines() ? 'true': 'false')); $objWriter->writeAttribute('gridLines', ($pSheet->getPrintGridlines() ? 'true' : 'false'));
$objWriter->writeAttribute('gridLinesSet', 'true'); $objWriter->writeAttribute('gridLinesSet', 'true');
if ($pSheet->getPageSetup()->getHorizontalCentered()) { if ($pSheet->getPageSetup()->getHorizontalCentered()) {
@ -800,7 +800,7 @@ class Worksheet extends WriterPart
// Top 10 Filter Rule // Top 10 Filter Rule
$objWriter->writeAttribute('val', $rule->getValue()); $objWriter->writeAttribute('val', $rule->getValue());
$objWriter->writeAttribute('percent', (($rule->getOperator() === \PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0')); $objWriter->writeAttribute('percent', (($rule->getOperator() === \PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_PERCENT) ? '1' : '0'));
$objWriter->writeAttribute('top', (($rule->getGrouping() === \PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1': '0')); $objWriter->writeAttribute('top', (($rule->getGrouping() === \PhpSpreadsheet\Worksheet\AutoFilter\Column\Rule::AUTOFILTER_COLUMN_RULE_TOPTEN_TOP) ? '1' : '0'));
} else { } else {
// Filter, DateGroupItem or CustomFilter // Filter, DateGroupItem or CustomFilter
$objWriter->startElement($rule->getRuleType()); $objWriter->startElement($rule->getRuleType());
@ -1079,8 +1079,7 @@ class Worksheet extends WriterPart
break; break;
case 'f': // Formula case 'f': // Formula
$calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ? $calculatedValue = ($this->getParentWriter()->getPreCalculateFormulas()) ?
$pCell->getCalculatedValue() : $pCell->getCalculatedValue() : $cellValue;
$cellValue;
if (is_string($calculatedValue)) { if (is_string($calculatedValue)) {
$objWriter->writeAttribute('t', 'str'); $objWriter->writeAttribute('t', 'str');
} }

View File

@ -110,9 +110,9 @@ class BIFFwriter
$teststr = pack('d', 1.2345); $teststr = pack('d', 1.2345);
$number = pack('C8', 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F); $number = pack('C8', 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
if ($number == $teststr) { if ($number == $teststr) {
$byte_order = 0; // Little Endian $byte_order = 0; // Little Endian
} elseif ($number == strrev($teststr)) { } elseif ($number == strrev($teststr)) {
$byte_order = 1; // Big Endian $byte_order = 1; // Big Endian
} else { } else {
// Give up. I'll fix this in a later version. // Give up. I'll fix this in a later version.
throw new \PhpSpreadsheet\Writer\Exception('Required floating point format not supported on this platform.'); throw new \PhpSpreadsheet\Writer\Exception('Required floating point format not supported on this platform.');
@ -162,16 +162,16 @@ class BIFFwriter
*/ */
protected function storeBof($type) protected function storeBof($type)
{ {
$record = 0x0809; // Record identifier (BIFF5-BIFF8) $record = 0x0809; // Record identifier (BIFF5-BIFF8)
$length = 0x0010; $length = 0x0010;
// by inspection of real files, MS Office Excel 2007 writes the following // by inspection of real files, MS Office Excel 2007 writes the following
$unknown = pack('VV', 0x000100D1, 0x00000406); $unknown = pack('VV', 0x000100D1, 0x00000406);
$build = 0x0DBB; // Excel 97 $build = 0x0DBB; // Excel 97
$year = 0x07CC; // Excel 97 $year = 0x07CC; // Excel 97
$version = 0x0600; // BIFF8 $version = 0x0600; // BIFF8
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vvvv', $version, $type, $build, $year); $data = pack('vvvv', $version, $type, $build, $year);
@ -183,8 +183,8 @@ class BIFFwriter
*/ */
protected function storeEof() protected function storeEof()
{ {
$record = 0x000A; // Record identifier $record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow $length = 0x0000; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$this->append($header); $this->append($header);
@ -195,8 +195,8 @@ class BIFFwriter
*/ */
public function writeEof() public function writeEof()
{ {
$record = 0x000A; // Record identifier $record = 0x000A; // Record identifier
$length = 0x0000; // Number of bytes to follow $length = 0x0000; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
return $this->writeData($header); return $this->writeData($header);
@ -216,13 +216,13 @@ class BIFFwriter
private function addContinue($data) private function addContinue($data)
{ {
$limit = $this->limit; $limit = $this->limit;
$record = 0x003C; // Record identifier $record = 0x003C; // Record identifier
// The first 2080/8224 bytes remain intact. However, we have to change // The first 2080/8224 bytes remain intact. However, we have to change
// the length field of the record. // the length field of the record.
$tmp = substr($data, 0, 2) . pack('v', $limit) . substr($data, 4, $limit); $tmp = substr($data, 0, 2) . pack('v', $limit) . substr($data, 4, $limit);
$header = pack('vv', $record, $limit); // Headers for continue records $header = pack('vv', $record, $limit); // Headers for continue records
// Retrieve chunks of 2080/8224 bytes +4 for the header. // Retrieve chunks of 2080/8224 bytes +4 for the header.
$data_length = strlen($data); $data_length = strlen($data);

View File

@ -114,11 +114,11 @@ class Parser
public function __construct() public function __construct()
{ {
$this->currentCharacter = 0; $this->currentCharacter = 0;
$this->currentToken = ''; // The token we are working on. $this->currentToken = ''; // The token we are working on.
$this->formula = ''; // The formula to parse. $this->formula = ''; // The formula to parse.
$this->lookAhead = ''; // The character ahead of the current char. $this->lookAhead = ''; // The character ahead of the current char.
$this->parseTree = ''; // The parse tree to be generated. $this->parseTree = ''; // The parse tree to be generated.
$this->initializeHashes(); // Initialize the hashes: ptg's and function's ptg's $this->initializeHashes(); // Initialize the hashes: ptg's and function's ptg's
$this->externalSheets = []; $this->externalSheets = [];
$this->references = []; $this->references = [];
} }
@ -242,256 +242,256 @@ class Parser
// //
$this->functions = [ $this->functions = [
// function ptg args class vol // function ptg args class vol
'COUNT' => [0, -1, 0, 0], 'COUNT' => [0, -1, 0, 0],
'IF' => [1, -1, 1, 0], 'IF' => [1, -1, 1, 0],
'ISNA' => [2, 1, 1, 0], 'ISNA' => [2, 1, 1, 0],
'ISERROR' => [3, 1, 1, 0], 'ISERROR' => [3, 1, 1, 0],
'SUM' => [4, -1, 0, 0], 'SUM' => [4, -1, 0, 0],
'AVERAGE' => [5, -1, 0, 0], 'AVERAGE' => [5, -1, 0, 0],
'MIN' => [6, -1, 0, 0], 'MIN' => [6, -1, 0, 0],
'MAX' => [7, -1, 0, 0], 'MAX' => [7, -1, 0, 0],
'ROW' => [8, -1, 0, 0], 'ROW' => [8, -1, 0, 0],
'COLUMN' => [9, -1, 0, 0], 'COLUMN' => [9, -1, 0, 0],
'NA' => [10, 0, 0, 0], 'NA' => [10, 0, 0, 0],
'NPV' => [11, -1, 1, 0], 'NPV' => [11, -1, 1, 0],
'STDEV' => [12, -1, 0, 0], 'STDEV' => [12, -1, 0, 0],
'DOLLAR' => [13, -1, 1, 0], 'DOLLAR' => [13, -1, 1, 0],
'FIXED' => [14, -1, 1, 0], 'FIXED' => [14, -1, 1, 0],
'SIN' => [15, 1, 1, 0], 'SIN' => [15, 1, 1, 0],
'COS' => [16, 1, 1, 0], 'COS' => [16, 1, 1, 0],
'TAN' => [17, 1, 1, 0], 'TAN' => [17, 1, 1, 0],
'ATAN' => [18, 1, 1, 0], 'ATAN' => [18, 1, 1, 0],
'PI' => [19, 0, 1, 0], 'PI' => [19, 0, 1, 0],
'SQRT' => [20, 1, 1, 0], 'SQRT' => [20, 1, 1, 0],
'EXP' => [21, 1, 1, 0], 'EXP' => [21, 1, 1, 0],
'LN' => [22, 1, 1, 0], 'LN' => [22, 1, 1, 0],
'LOG10' => [23, 1, 1, 0], 'LOG10' => [23, 1, 1, 0],
'ABS' => [24, 1, 1, 0], 'ABS' => [24, 1, 1, 0],
'INT' => [25, 1, 1, 0], 'INT' => [25, 1, 1, 0],
'SIGN' => [26, 1, 1, 0], 'SIGN' => [26, 1, 1, 0],
'ROUND' => [27, 2, 1, 0], 'ROUND' => [27, 2, 1, 0],
'LOOKUP' => [28, -1, 0, 0], 'LOOKUP' => [28, -1, 0, 0],
'INDEX' => [29, -1, 0, 1], 'INDEX' => [29, -1, 0, 1],
'REPT' => [30, 2, 1, 0], 'REPT' => [30, 2, 1, 0],
'MID' => [31, 3, 1, 0], 'MID' => [31, 3, 1, 0],
'LEN' => [32, 1, 1, 0], 'LEN' => [32, 1, 1, 0],
'VALUE' => [33, 1, 1, 0], 'VALUE' => [33, 1, 1, 0],
'TRUE' => [34, 0, 1, 0], 'TRUE' => [34, 0, 1, 0],
'FALSE' => [35, 0, 1, 0], 'FALSE' => [35, 0, 1, 0],
'AND' => [36, -1, 0, 0], 'AND' => [36, -1, 0, 0],
'OR' => [37, -1, 0, 0], 'OR' => [37, -1, 0, 0],
'NOT' => [38, 1, 1, 0], 'NOT' => [38, 1, 1, 0],
'MOD' => [39, 2, 1, 0], 'MOD' => [39, 2, 1, 0],
'DCOUNT' => [40, 3, 0, 0], 'DCOUNT' => [40, 3, 0, 0],
'DSUM' => [41, 3, 0, 0], 'DSUM' => [41, 3, 0, 0],
'DAVERAGE' => [42, 3, 0, 0], 'DAVERAGE' => [42, 3, 0, 0],
'DMIN' => [43, 3, 0, 0], 'DMIN' => [43, 3, 0, 0],
'DMAX' => [44, 3, 0, 0], 'DMAX' => [44, 3, 0, 0],
'DSTDEV' => [45, 3, 0, 0], 'DSTDEV' => [45, 3, 0, 0],
'VAR' => [46, -1, 0, 0], 'VAR' => [46, -1, 0, 0],
'DVAR' => [47, 3, 0, 0], 'DVAR' => [47, 3, 0, 0],
'TEXT' => [48, 2, 1, 0], 'TEXT' => [48, 2, 1, 0],
'LINEST' => [49, -1, 0, 0], 'LINEST' => [49, -1, 0, 0],
'TREND' => [50, -1, 0, 0], 'TREND' => [50, -1, 0, 0],
'LOGEST' => [51, -1, 0, 0], 'LOGEST' => [51, -1, 0, 0],
'GROWTH' => [52, -1, 0, 0], 'GROWTH' => [52, -1, 0, 0],
'PV' => [56, -1, 1, 0], 'PV' => [56, -1, 1, 0],
'FV' => [57, -1, 1, 0], 'FV' => [57, -1, 1, 0],
'NPER' => [58, -1, 1, 0], 'NPER' => [58, -1, 1, 0],
'PMT' => [59, -1, 1, 0], 'PMT' => [59, -1, 1, 0],
'RATE' => [60, -1, 1, 0], 'RATE' => [60, -1, 1, 0],
'MIRR' => [61, 3, 0, 0], 'MIRR' => [61, 3, 0, 0],
'IRR' => [62, -1, 0, 0], 'IRR' => [62, -1, 0, 0],
'RAND' => [63, 0, 1, 1], 'RAND' => [63, 0, 1, 1],
'MATCH' => [64, -1, 0, 0], 'MATCH' => [64, -1, 0, 0],
'DATE' => [65, 3, 1, 0], 'DATE' => [65, 3, 1, 0],
'TIME' => [66, 3, 1, 0], 'TIME' => [66, 3, 1, 0],
'DAY' => [67, 1, 1, 0], 'DAY' => [67, 1, 1, 0],
'MONTH' => [68, 1, 1, 0], 'MONTH' => [68, 1, 1, 0],
'YEAR' => [69, 1, 1, 0], 'YEAR' => [69, 1, 1, 0],
'WEEKDAY' => [70, -1, 1, 0], 'WEEKDAY' => [70, -1, 1, 0],
'HOUR' => [71, 1, 1, 0], 'HOUR' => [71, 1, 1, 0],
'MINUTE' => [72, 1, 1, 0], 'MINUTE' => [72, 1, 1, 0],
'SECOND' => [73, 1, 1, 0], 'SECOND' => [73, 1, 1, 0],
'NOW' => [74, 0, 1, 1], 'NOW' => [74, 0, 1, 1],
'AREAS' => [75, 1, 0, 1], 'AREAS' => [75, 1, 0, 1],
'ROWS' => [76, 1, 0, 1], 'ROWS' => [76, 1, 0, 1],
'COLUMNS' => [77, 1, 0, 1], 'COLUMNS' => [77, 1, 0, 1],
'OFFSET' => [78, -1, 0, 1], 'OFFSET' => [78, -1, 0, 1],
'SEARCH' => [82, -1, 1, 0], 'SEARCH' => [82, -1, 1, 0],
'TRANSPOSE' => [83, 1, 1, 0], 'TRANSPOSE' => [83, 1, 1, 0],
'TYPE' => [86, 1, 1, 0], 'TYPE' => [86, 1, 1, 0],
'ATAN2' => [97, 2, 1, 0], 'ATAN2' => [97, 2, 1, 0],
'ASIN' => [98, 1, 1, 0], 'ASIN' => [98, 1, 1, 0],
'ACOS' => [99, 1, 1, 0], 'ACOS' => [99, 1, 1, 0],
'CHOOSE' => [100, -1, 1, 0], 'CHOOSE' => [100, -1, 1, 0],
'HLOOKUP' => [101, -1, 0, 0], 'HLOOKUP' => [101, -1, 0, 0],
'VLOOKUP' => [102, -1, 0, 0], 'VLOOKUP' => [102, -1, 0, 0],
'ISREF' => [105, 1, 0, 0], 'ISREF' => [105, 1, 0, 0],
'LOG' => [109, -1, 1, 0], 'LOG' => [109, -1, 1, 0],
'CHAR' => [111, 1, 1, 0], 'CHAR' => [111, 1, 1, 0],
'LOWER' => [112, 1, 1, 0], 'LOWER' => [112, 1, 1, 0],
'UPPER' => [113, 1, 1, 0], 'UPPER' => [113, 1, 1, 0],
'PROPER' => [114, 1, 1, 0], 'PROPER' => [114, 1, 1, 0],
'LEFT' => [115, -1, 1, 0], 'LEFT' => [115, -1, 1, 0],
'RIGHT' => [116, -1, 1, 0], 'RIGHT' => [116, -1, 1, 0],
'EXACT' => [117, 2, 1, 0], 'EXACT' => [117, 2, 1, 0],
'TRIM' => [118, 1, 1, 0], 'TRIM' => [118, 1, 1, 0],
'REPLACE' => [119, 4, 1, 0], 'REPLACE' => [119, 4, 1, 0],
'SUBSTITUTE' => [120, -1, 1, 0], 'SUBSTITUTE' => [120, -1, 1, 0],
'CODE' => [121, 1, 1, 0], 'CODE' => [121, 1, 1, 0],
'FIND' => [124, -1, 1, 0], 'FIND' => [124, -1, 1, 0],
'CELL' => [125, -1, 0, 1], 'CELL' => [125, -1, 0, 1],
'ISERR' => [126, 1, 1, 0], 'ISERR' => [126, 1, 1, 0],
'ISTEXT' => [127, 1, 1, 0], 'ISTEXT' => [127, 1, 1, 0],
'ISNUMBER' => [128, 1, 1, 0], 'ISNUMBER' => [128, 1, 1, 0],
'ISBLANK' => [129, 1, 1, 0], 'ISBLANK' => [129, 1, 1, 0],
'T' => [130, 1, 0, 0], 'T' => [130, 1, 0, 0],
'N' => [131, 1, 0, 0], 'N' => [131, 1, 0, 0],
'DATEVALUE' => [140, 1, 1, 0], 'DATEVALUE' => [140, 1, 1, 0],
'TIMEVALUE' => [141, 1, 1, 0], 'TIMEVALUE' => [141, 1, 1, 0],
'SLN' => [142, 3, 1, 0], 'SLN' => [142, 3, 1, 0],
'SYD' => [143, 4, 1, 0], 'SYD' => [143, 4, 1, 0],
'DDB' => [144, -1, 1, 0], 'DDB' => [144, -1, 1, 0],
'INDIRECT' => [148, -1, 1, 1], 'INDIRECT' => [148, -1, 1, 1],
'CALL' => [150, -1, 1, 0], 'CALL' => [150, -1, 1, 0],
'CLEAN' => [162, 1, 1, 0], 'CLEAN' => [162, 1, 1, 0],
'MDETERM' => [163, 1, 2, 0], 'MDETERM' => [163, 1, 2, 0],
'MINVERSE' => [164, 1, 2, 0], 'MINVERSE' => [164, 1, 2, 0],
'MMULT' => [165, 2, 2, 0], 'MMULT' => [165, 2, 2, 0],
'IPMT' => [167, -1, 1, 0], 'IPMT' => [167, -1, 1, 0],
'PPMT' => [168, -1, 1, 0], 'PPMT' => [168, -1, 1, 0],
'COUNTA' => [169, -1, 0, 0], 'COUNTA' => [169, -1, 0, 0],
'PRODUCT' => [183, -1, 0, 0], 'PRODUCT' => [183, -1, 0, 0],
'FACT' => [184, 1, 1, 0], 'FACT' => [184, 1, 1, 0],
'DPRODUCT' => [189, 3, 0, 0], 'DPRODUCT' => [189, 3, 0, 0],
'ISNONTEXT' => [190, 1, 1, 0], 'ISNONTEXT' => [190, 1, 1, 0],
'STDEVP' => [193, -1, 0, 0], 'STDEVP' => [193, -1, 0, 0],
'VARP' => [194, -1, 0, 0], 'VARP' => [194, -1, 0, 0],
'DSTDEVP' => [195, 3, 0, 0], 'DSTDEVP' => [195, 3, 0, 0],
'DVARP' => [196, 3, 0, 0], 'DVARP' => [196, 3, 0, 0],
'TRUNC' => [197, -1, 1, 0], 'TRUNC' => [197, -1, 1, 0],
'ISLOGICAL' => [198, 1, 1, 0], 'ISLOGICAL' => [198, 1, 1, 0],
'DCOUNTA' => [199, 3, 0, 0], 'DCOUNTA' => [199, 3, 0, 0],
'USDOLLAR' => [204, -1, 1, 0], 'USDOLLAR' => [204, -1, 1, 0],
'FINDB' => [205, -1, 1, 0], 'FINDB' => [205, -1, 1, 0],
'SEARCHB' => [206, -1, 1, 0], 'SEARCHB' => [206, -1, 1, 0],
'REPLACEB' => [207, 4, 1, 0], 'REPLACEB' => [207, 4, 1, 0],
'LEFTB' => [208, -1, 1, 0], 'LEFTB' => [208, -1, 1, 0],
'RIGHTB' => [209, -1, 1, 0], 'RIGHTB' => [209, -1, 1, 0],
'MIDB' => [210, 3, 1, 0], 'MIDB' => [210, 3, 1, 0],
'LENB' => [211, 1, 1, 0], 'LENB' => [211, 1, 1, 0],
'ROUNDUP' => [212, 2, 1, 0], 'ROUNDUP' => [212, 2, 1, 0],
'ROUNDDOWN' => [213, 2, 1, 0], 'ROUNDDOWN' => [213, 2, 1, 0],
'ASC' => [214, 1, 1, 0], 'ASC' => [214, 1, 1, 0],
'DBCS' => [215, 1, 1, 0], 'DBCS' => [215, 1, 1, 0],
'RANK' => [216, -1, 0, 0], 'RANK' => [216, -1, 0, 0],
'ADDRESS' => [219, -1, 1, 0], 'ADDRESS' => [219, -1, 1, 0],
'DAYS360' => [220, -1, 1, 0], 'DAYS360' => [220, -1, 1, 0],
'TODAY' => [221, 0, 1, 1], 'TODAY' => [221, 0, 1, 1],
'VDB' => [222, -1, 1, 0], 'VDB' => [222, -1, 1, 0],
'MEDIAN' => [227, -1, 0, 0], 'MEDIAN' => [227, -1, 0, 0],
'SUMPRODUCT' => [228, -1, 2, 0], 'SUMPRODUCT' => [228, -1, 2, 0],
'SINH' => [229, 1, 1, 0], 'SINH' => [229, 1, 1, 0],
'COSH' => [230, 1, 1, 0], 'COSH' => [230, 1, 1, 0],
'TANH' => [231, 1, 1, 0], 'TANH' => [231, 1, 1, 0],
'ASINH' => [232, 1, 1, 0], 'ASINH' => [232, 1, 1, 0],
'ACOSH' => [233, 1, 1, 0], 'ACOSH' => [233, 1, 1, 0],
'ATANH' => [234, 1, 1, 0], 'ATANH' => [234, 1, 1, 0],
'DGET' => [235, 3, 0, 0], 'DGET' => [235, 3, 0, 0],
'INFO' => [244, 1, 1, 1], 'INFO' => [244, 1, 1, 1],
'DB' => [247, -1, 1, 0], 'DB' => [247, -1, 1, 0],
'FREQUENCY' => [252, 2, 0, 0], 'FREQUENCY' => [252, 2, 0, 0],
'ERROR.TYPE' => [261, 1, 1, 0], 'ERROR.TYPE' => [261, 1, 1, 0],
'REGISTER.ID' => [267, -1, 1, 0], 'REGISTER.ID' => [267, -1, 1, 0],
'AVEDEV' => [269, -1, 0, 0], 'AVEDEV' => [269, -1, 0, 0],
'BETADIST' => [270, -1, 1, 0], 'BETADIST' => [270, -1, 1, 0],
'GAMMALN' => [271, 1, 1, 0], 'GAMMALN' => [271, 1, 1, 0],
'BETAINV' => [272, -1, 1, 0], 'BETAINV' => [272, -1, 1, 0],
'BINOMDIST' => [273, 4, 1, 0], 'BINOMDIST' => [273, 4, 1, 0],
'CHIDIST' => [274, 2, 1, 0], 'CHIDIST' => [274, 2, 1, 0],
'CHIINV' => [275, 2, 1, 0], 'CHIINV' => [275, 2, 1, 0],
'COMBIN' => [276, 2, 1, 0], 'COMBIN' => [276, 2, 1, 0],
'CONFIDENCE' => [277, 3, 1, 0], 'CONFIDENCE' => [277, 3, 1, 0],
'CRITBINOM' => [278, 3, 1, 0], 'CRITBINOM' => [278, 3, 1, 0],
'EVEN' => [279, 1, 1, 0], 'EVEN' => [279, 1, 1, 0],
'EXPONDIST' => [280, 3, 1, 0], 'EXPONDIST' => [280, 3, 1, 0],
'FDIST' => [281, 3, 1, 0], 'FDIST' => [281, 3, 1, 0],
'FINV' => [282, 3, 1, 0], 'FINV' => [282, 3, 1, 0],
'FISHER' => [283, 1, 1, 0], 'FISHER' => [283, 1, 1, 0],
'FISHERINV' => [284, 1, 1, 0], 'FISHERINV' => [284, 1, 1, 0],
'FLOOR' => [285, 2, 1, 0], 'FLOOR' => [285, 2, 1, 0],
'GAMMADIST' => [286, 4, 1, 0], 'GAMMADIST' => [286, 4, 1, 0],
'GAMMAINV' => [287, 3, 1, 0], 'GAMMAINV' => [287, 3, 1, 0],
'CEILING' => [288, 2, 1, 0], 'CEILING' => [288, 2, 1, 0],
'HYPGEOMDIST' => [289, 4, 1, 0], 'HYPGEOMDIST' => [289, 4, 1, 0],
'LOGNORMDIST' => [290, 3, 1, 0], 'LOGNORMDIST' => [290, 3, 1, 0],
'LOGINV' => [291, 3, 1, 0], 'LOGINV' => [291, 3, 1, 0],
'NEGBINOMDIST' => [292, 3, 1, 0], 'NEGBINOMDIST' => [292, 3, 1, 0],
'NORMDIST' => [293, 4, 1, 0], 'NORMDIST' => [293, 4, 1, 0],
'NORMSDIST' => [294, 1, 1, 0], 'NORMSDIST' => [294, 1, 1, 0],
'NORMINV' => [295, 3, 1, 0], 'NORMINV' => [295, 3, 1, 0],
'NORMSINV' => [296, 1, 1, 0], 'NORMSINV' => [296, 1, 1, 0],
'STANDARDIZE' => [297, 3, 1, 0], 'STANDARDIZE' => [297, 3, 1, 0],
'ODD' => [298, 1, 1, 0], 'ODD' => [298, 1, 1, 0],
'PERMUT' => [299, 2, 1, 0], 'PERMUT' => [299, 2, 1, 0],
'POISSON' => [300, 3, 1, 0], 'POISSON' => [300, 3, 1, 0],
'TDIST' => [301, 3, 1, 0], 'TDIST' => [301, 3, 1, 0],
'WEIBULL' => [302, 4, 1, 0], 'WEIBULL' => [302, 4, 1, 0],
'SUMXMY2' => [303, 2, 2, 0], 'SUMXMY2' => [303, 2, 2, 0],
'SUMX2MY2' => [304, 2, 2, 0], 'SUMX2MY2' => [304, 2, 2, 0],
'SUMX2PY2' => [305, 2, 2, 0], 'SUMX2PY2' => [305, 2, 2, 0],
'CHITEST' => [306, 2, 2, 0], 'CHITEST' => [306, 2, 2, 0],
'CORREL' => [307, 2, 2, 0], 'CORREL' => [307, 2, 2, 0],
'COVAR' => [308, 2, 2, 0], 'COVAR' => [308, 2, 2, 0],
'FORECAST' => [309, 3, 2, 0], 'FORECAST' => [309, 3, 2, 0],
'FTEST' => [310, 2, 2, 0], 'FTEST' => [310, 2, 2, 0],
'INTERCEPT' => [311, 2, 2, 0], 'INTERCEPT' => [311, 2, 2, 0],
'PEARSON' => [312, 2, 2, 0], 'PEARSON' => [312, 2, 2, 0],
'RSQ' => [313, 2, 2, 0], 'RSQ' => [313, 2, 2, 0],
'STEYX' => [314, 2, 2, 0], 'STEYX' => [314, 2, 2, 0],
'SLOPE' => [315, 2, 2, 0], 'SLOPE' => [315, 2, 2, 0],
'TTEST' => [316, 4, 2, 0], 'TTEST' => [316, 4, 2, 0],
'PROB' => [317, -1, 2, 0], 'PROB' => [317, -1, 2, 0],
'DEVSQ' => [318, -1, 0, 0], 'DEVSQ' => [318, -1, 0, 0],
'GEOMEAN' => [319, -1, 0, 0], 'GEOMEAN' => [319, -1, 0, 0],
'HARMEAN' => [320, -1, 0, 0], 'HARMEAN' => [320, -1, 0, 0],
'SUMSQ' => [321, -1, 0, 0], 'SUMSQ' => [321, -1, 0, 0],
'KURT' => [322, -1, 0, 0], 'KURT' => [322, -1, 0, 0],
'SKEW' => [323, -1, 0, 0], 'SKEW' => [323, -1, 0, 0],
'ZTEST' => [324, -1, 0, 0], 'ZTEST' => [324, -1, 0, 0],
'LARGE' => [325, 2, 0, 0], 'LARGE' => [325, 2, 0, 0],
'SMALL' => [326, 2, 0, 0], 'SMALL' => [326, 2, 0, 0],
'QUARTILE' => [327, 2, 0, 0], 'QUARTILE' => [327, 2, 0, 0],
'PERCENTILE' => [328, 2, 0, 0], 'PERCENTILE' => [328, 2, 0, 0],
'PERCENTRANK' => [329, -1, 0, 0], 'PERCENTRANK' => [329, -1, 0, 0],
'MODE' => [330, -1, 2, 0], 'MODE' => [330, -1, 2, 0],
'TRIMMEAN' => [331, 2, 0, 0], 'TRIMMEAN' => [331, 2, 0, 0],
'TINV' => [332, 2, 1, 0], 'TINV' => [332, 2, 1, 0],
'CONCATENATE' => [336, -1, 1, 0], 'CONCATENATE' => [336, -1, 1, 0],
'POWER' => [337, 2, 1, 0], 'POWER' => [337, 2, 1, 0],
'RADIANS' => [342, 1, 1, 0], 'RADIANS' => [342, 1, 1, 0],
'DEGREES' => [343, 1, 1, 0], 'DEGREES' => [343, 1, 1, 0],
'SUBTOTAL' => [344, -1, 0, 0], 'SUBTOTAL' => [344, -1, 0, 0],
'SUMIF' => [345, -1, 0, 0], 'SUMIF' => [345, -1, 0, 0],
'COUNTIF' => [346, 2, 0, 0], 'COUNTIF' => [346, 2, 0, 0],
'COUNTBLANK' => [347, 1, 0, 0], 'COUNTBLANK' => [347, 1, 0, 0],
'ISPMT' => [350, 4, 1, 0], 'ISPMT' => [350, 4, 1, 0],
'DATEDIF' => [351, 3, 1, 0], 'DATEDIF' => [351, 3, 1, 0],
'DATESTRING' => [352, 1, 1, 0], 'DATESTRING' => [352, 1, 1, 0],
'NUMBERSTRING' => [353, 2, 1, 0], 'NUMBERSTRING' => [353, 2, 1, 0],
'ROMAN' => [354, -1, 1, 0], 'ROMAN' => [354, -1, 1, 0],
'GETPIVOTDATA' => [358, -1, 0, 0], 'GETPIVOTDATA' => [358, -1, 0, 0],
'HYPERLINK' => [359, -1, 1, 0], 'HYPERLINK' => [359, -1, 1, 0],
'PHONETIC' => [360, 1, 0, 0], 'PHONETIC' => [360, 1, 0, 0],
'AVERAGEA' => [361, -1, 0, 0], 'AVERAGEA' => [361, -1, 0, 0],
'MAXA' => [362, -1, 0, 0], 'MAXA' => [362, -1, 0, 0],
'MINA' => [363, -1, 0, 0], 'MINA' => [363, -1, 0, 0],
'STDEVPA' => [364, -1, 0, 0], 'STDEVPA' => [364, -1, 0, 0],
'VARPA' => [365, -1, 0, 0], 'VARPA' => [365, -1, 0, 0],
'STDEVA' => [366, -1, 0, 0], 'STDEVA' => [366, -1, 0, 0],
'VARA' => [367, -1, 0, 0], 'VARA' => [367, -1, 0, 0],
'BAHTTEXT' => [368, 1, 0, 0], 'BAHTTEXT' => [368, 1, 0, 0],
]; ];
} }
@ -1318,12 +1318,12 @@ class Parser
private function fact() private function fact()
{ {
if ($this->currentToken == '(') { if ($this->currentToken == '(') {
$this->advance(); // eat the "(" $this->advance(); // eat the "("
$result = $this->parenthesizedExpression(); $result = $this->parenthesizedExpression();
if ($this->currentToken != ')') { if ($this->currentToken != ')') {
throw new \PhpSpreadsheet\Writer\Exception("')' token expected."); throw new \PhpSpreadsheet\Writer\Exception("')' token expected.");
} }
$this->advance(); // eat the ")" $this->advance(); // eat the ")"
return $result; return $result;
} }
// if it's a reference // if it's a reference
@ -1372,7 +1372,7 @@ class Parser
// If it's a number or a percent // If it's a number or a percent
if ($this->lookAhead == '%') { if ($this->lookAhead == '%') {
$result = $this->createTree('ptgPercent', $this->currentToken, ''); $result = $this->createTree('ptgPercent', $this->currentToken, '');
$this->advance(); // Skip the percentage operator once we've pre-built that tree $this->advance(); // Skip the percentage operator once we've pre-built that tree
} else { } else {
$result = $this->createTree($this->currentToken, '', ''); $result = $this->createTree($this->currentToken, '', '');
} }
@ -1400,12 +1400,12 @@ class Parser
$function = strtoupper($this->currentToken); $function = strtoupper($this->currentToken);
$result = ''; // initialize result $result = ''; // initialize result
$this->advance(); $this->advance();
$this->advance(); // eat the "(" $this->advance(); // eat the "("
while ($this->currentToken != ')') { while ($this->currentToken != ')') {
/**/ /**/
if ($num_args > 0) { if ($num_args > 0) {
if ($this->currentToken == ',' || $this->currentToken == ';') { if ($this->currentToken == ',' || $this->currentToken == ';') {
$this->advance(); // eat the "," or ";" $this->advance(); // eat the "," or ";"
} else { } else {
throw new \PhpSpreadsheet\Writer\Exception("Syntax error: comma expected in function $function, arg #{$num_args}"); throw new \PhpSpreadsheet\Writer\Exception("Syntax error: comma expected in function $function, arg #{$num_args}");
} }
@ -1427,7 +1427,7 @@ class Parser
} }
$result = $this->createTree($function, $result, $num_args); $result = $this->createTree($function, $result, $num_args);
$this->advance(); // eat the ")" $this->advance(); // eat the ")"
return $result; return $result;
} }

View File

@ -219,11 +219,11 @@ class Workbook extends BIFFwriter
for ($i = 0; $i < $countSheets; ++$i) { for ($i = 0; $i < $countSheets; ++$i) {
$phpSheet = $spreadsheet->getSheet($i); $phpSheet = $spreadsheet->getSheet($i);
$this->parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser $this->parser->setExtSheet($phpSheet->getTitle(), $i); // Register worksheet name with parser
$supbook_index = 0x00; $supbook_index = 0x00;
$ref = pack('vvv', $supbook_index, $i, $i); $ref = pack('vvv', $supbook_index, $i, $i);
$this->parser->references[] = $ref; // Register reference with parser $this->parser->references[] = $ref; // Register reference with parser
// Sheet tab colors? // Sheet tab colors?
if ($phpSheet->isTabColorSet()) { if ($phpSheet->isTabColorSet()) {
@ -467,7 +467,7 @@ class Workbook extends BIFFwriter
*/ */
private function calcSheetOffsets() private function calcSheetOffsets()
{ {
$boundsheet_length = 10; // fixed length for a BOUNDSHEET record $boundsheet_length = 10; // fixed length for a BOUNDSHEET record
// size of Workbook globals part 1 + 3 // size of Workbook globals part 1 + 3
$offset = $this->_datasize; $offset = $this->_datasize;
@ -831,7 +831,7 @@ class Workbook extends BIFFwriter
$record = 0x0018; $record = 0x0018;
// option flags // option flags
$options = ($isHidden ? 0x21 : 0x00); $options = ($isHidden ? 0x21 : 0x00);
$extra = pack( $extra = pack(
'Cvvvvv', 'Cvvvvv',
@ -861,9 +861,9 @@ class Workbook extends BIFFwriter
*/ */
private function writeCodepage() private function writeCodepage()
{ {
$record = 0x0042; // Record identifier $record = 0x0042; // Record identifier
$length = 0x0002; // Number of bytes to follow $length = 0x0002; // Number of bytes to follow
$cv = $this->codepage; // The code page $cv = $this->codepage; // The code page
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $cv); $data = pack('v', $cv);
@ -876,24 +876,24 @@ class Workbook extends BIFFwriter
*/ */
private function writeWindow1() private function writeWindow1()
{ {
$record = 0x003D; // Record identifier $record = 0x003D; // Record identifier
$length = 0x0012; // Number of bytes to follow $length = 0x0012; // Number of bytes to follow
$xWn = 0x0000; // Horizontal position of window $xWn = 0x0000; // Horizontal position of window
$yWn = 0x0000; // Vertical position of window $yWn = 0x0000; // Vertical position of window
$dxWn = 0x25BC; // Width of window $dxWn = 0x25BC; // Width of window
$dyWn = 0x1572; // Height of window $dyWn = 0x1572; // Height of window
$grbit = 0x0038; // Option flags $grbit = 0x0038; // Option flags
// not supported by PhpSpreadsheet, so there is only one selected sheet, the active // not supported by PhpSpreadsheet, so there is only one selected sheet, the active
$ctabsel = 1; // Number of workbook tabs selected $ctabsel = 1; // Number of workbook tabs selected
$wTabRatio = 0x0258; // Tab to scrollbar ratio $wTabRatio = 0x0258; // Tab to scrollbar ratio
// not supported by PhpSpreadsheet, set to 0 // not supported by PhpSpreadsheet, set to 0
$itabFirst = 0; // 1st displayed worksheet $itabFirst = 0; // 1st displayed worksheet
$itabCur = $this->spreadsheet->getActiveSheetIndex(); // Active worksheet $itabCur = $this->spreadsheet->getActiveSheetIndex(); // Active worksheet
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vvvvvvvvv', $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio); $data = pack('vvvvvvvvv', $xWn, $yWn, $dxWn, $dyWn, $grbit, $itabCur, $itabFirst, $ctabsel, $wTabRatio);
@ -909,7 +909,7 @@ class Workbook extends BIFFwriter
private function writeBoundSheet($sheet, $offset) private function writeBoundSheet($sheet, $offset)
{ {
$sheetname = $sheet->getTitle(); $sheetname = $sheet->getTitle();
$record = 0x0085; // Record identifier $record = 0x0085; // Record identifier
// sheet state // sheet state
switch ($sheet->getSheetState()) { switch ($sheet->getSheetState()) {
@ -930,7 +930,7 @@ class Workbook extends BIFFwriter
// sheet type // sheet type
$st = 0x00; $st = 0x00;
$grbit = 0x0000; // Visibility and sheet type $grbit = 0x0000; // Visibility and sheet type
$data = pack('VCC', $offset, $ss, $st); $data = pack('VCC', $offset, $ss, $st);
$data .= \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($sheetname); $data .= \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($sheetname);
@ -945,8 +945,8 @@ class Workbook extends BIFFwriter
*/ */
private function writeSupbookInternal() private function writeSupbookInternal()
{ {
$record = 0x01AE; // Record identifier $record = 0x01AE; // Record identifier
$length = 0x0004; // Bytes to follow $length = 0x0004; // Bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vv', $this->spreadsheet->getSheetCount(), 0x0401); $data = pack('vv', $this->spreadsheet->getSheetCount(), 0x0401);
@ -961,10 +961,10 @@ class Workbook extends BIFFwriter
private function writeExternalsheetBiff8() private function writeExternalsheetBiff8()
{ {
$totalReferences = count($this->parser->references); $totalReferences = count($this->parser->references);
$record = 0x0017; // Record identifier $record = 0x0017; // Record identifier
$length = 2 + 6 * $totalReferences; // Number of bytes to follow $length = 2 + 6 * $totalReferences; // Number of bytes to follow
$supbook_index = 0; // FIXME: only using internal SUPBOOK record $supbook_index = 0; // FIXME: only using internal SUPBOOK record
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $totalReferences); $data = pack('v', $totalReferences);
for ($i = 0; $i < $totalReferences; ++$i) { for ($i = 0; $i < $totalReferences; ++$i) {
@ -979,12 +979,12 @@ class Workbook extends BIFFwriter
*/ */
private function writeStyle() private function writeStyle()
{ {
$record = 0x0293; // Record identifier $record = 0x0293; // Record identifier
$length = 0x0004; // Bytes to follow $length = 0x0004; // Bytes to follow
$ixfe = 0x8000; // Index to cell style XF $ixfe = 0x8000; // Index to cell style XF
$BuiltIn = 0x00; // Built-in style $BuiltIn = 0x00; // Built-in style
$iLevel = 0xff; // Outline style level $iLevel = 0xff; // Outline style level
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vCC', $ixfe, $BuiltIn, $iLevel); $data = pack('vCC', $ixfe, $BuiltIn, $iLevel);
@ -999,10 +999,10 @@ class Workbook extends BIFFwriter
*/ */
private function writeNumberFormat($format, $ifmt) private function writeNumberFormat($format, $ifmt)
{ {
$record = 0x041E; // Record identifier $record = 0x041E; // Record identifier
$numberFormatString = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($format); $numberFormatString = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($format);
$length = 2 + strlen($numberFormatString); // Number of bytes to follow $length = 2 + strlen($numberFormatString); // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $ifmt) . $numberFormatString; $data = pack('v', $ifmt) . $numberFormatString;
@ -1014,12 +1014,12 @@ class Workbook extends BIFFwriter
*/ */
private function writeDateMode() private function writeDateMode()
{ {
$record = 0x0022; // Record identifier $record = 0x0022; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$f1904 = (\PhpSpreadsheet\Shared\Date::getExcelCalendar() == \PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904) $f1904 = (\PhpSpreadsheet\Shared\Date::getExcelCalendar() == \PhpSpreadsheet\Shared\Date::CALENDAR_MAC_1904)
? 1 ? 1
: 0; // Flag for 1904 date system : 0; // Flag for 1904 date system
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $f1904); $data = pack('v', $f1904);
@ -1040,8 +1040,8 @@ class Workbook extends BIFFwriter
*/ */
private function writeExternalCount($cxals) private function writeExternalCount($cxals)
{ {
$record = 0x0016; // Record identifier $record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow $length = 0x0002; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $cxals); $data = pack('v', $cxals);
@ -1059,11 +1059,11 @@ class Workbook extends BIFFwriter
*/ */
private function writeExternalSheet($sheetname) private function writeExternalSheet($sheetname)
{ {
$record = 0x0017; // Record identifier $record = 0x0017; // Record identifier
$length = 0x02 + strlen($sheetname); // Number of bytes to follow $length = 0x02 + strlen($sheetname); // Number of bytes to follow
$cch = strlen($sheetname); // Length of sheet name $cch = strlen($sheetname); // Length of sheet name
$rgch = 0x03; // Filename encoding $rgch = 0x03; // Filename encoding
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('CC', $cch, $rgch); $data = pack('CC', $cch, $rgch);
@ -1083,20 +1083,20 @@ class Workbook extends BIFFwriter
*/ */
private function writeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax) private function writeNameShort($index, $type, $rowmin, $rowmax, $colmin, $colmax)
{ {
$record = 0x0018; // Record identifier $record = 0x0018; // Record identifier
$length = 0x0024; // Number of bytes to follow $length = 0x0024; // Number of bytes to follow
$grbit = 0x0020; // Option flags $grbit = 0x0020; // Option flags
$chKey = 0x00; // Keyboard shortcut $chKey = 0x00; // Keyboard shortcut
$cch = 0x01; // Length of text name $cch = 0x01; // Length of text name
$cce = 0x0015; // Length of text definition $cce = 0x0015; // Length of text definition
$ixals = $index + 1; // Sheet index $ixals = $index + 1; // Sheet index
$itab = $ixals; // Equal to ixals $itab = $ixals; // Equal to ixals
$cchCustMenu = 0x00; // Length of cust menu text $cchCustMenu = 0x00; // Length of cust menu text
$cchDescription = 0x00; // Length of description text $cchDescription = 0x00; // Length of description text
$cchHelptopic = 0x00; // Length of help topic text $cchHelptopic = 0x00; // Length of help topic text
$cchStatustext = 0x00; // Length of status bar text $cchStatustext = 0x00; // Length of status bar text
$rgch = $type; // Built-in name type $rgch = $type; // Built-in name type
$unknown03 = 0x3b; $unknown03 = 0x3b;
$unknown04 = 0xffff - $index; $unknown04 = 0xffff - $index;
@ -1147,19 +1147,19 @@ class Workbook extends BIFFwriter
*/ */
private function writeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax) private function writeNameLong($index, $type, $rowmin, $rowmax, $colmin, $colmax)
{ {
$record = 0x0018; // Record identifier $record = 0x0018; // Record identifier
$length = 0x003d; // Number of bytes to follow $length = 0x003d; // Number of bytes to follow
$grbit = 0x0020; // Option flags $grbit = 0x0020; // Option flags
$chKey = 0x00; // Keyboard shortcut $chKey = 0x00; // Keyboard shortcut
$cch = 0x01; // Length of text name $cch = 0x01; // Length of text name
$cce = 0x002e; // Length of text definition $cce = 0x002e; // Length of text definition
$ixals = $index + 1; // Sheet index $ixals = $index + 1; // Sheet index
$itab = $ixals; // Equal to ixals $itab = $ixals; // Equal to ixals
$cchCustMenu = 0x00; // Length of cust menu text $cchCustMenu = 0x00; // Length of cust menu text
$cchDescription = 0x00; // Length of description text $cchDescription = 0x00; // Length of description text
$cchHelptopic = 0x00; // Length of help topic text $cchHelptopic = 0x00; // Length of help topic text
$cchStatustext = 0x00; // Length of status bar text $cchStatustext = 0x00; // Length of status bar text
$rgch = $type; // Built-in name type $rgch = $type; // Built-in name type
$unknown01 = 0x29; $unknown01 = 0x29;
$unknown02 = 0x002b; $unknown02 = 0x002b;
@ -1222,8 +1222,8 @@ class Workbook extends BIFFwriter
*/ */
private function writeCountry() private function writeCountry()
{ {
$record = 0x008C; // Record identifier $record = 0x008C; // Record identifier
$length = 4; // Number of bytes to follow $length = 4; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
/* using the same country code always for simplicity */ /* using the same country code always for simplicity */
@ -1239,8 +1239,8 @@ class Workbook extends BIFFwriter
*/ */
private function writeRecalcId() private function writeRecalcId()
{ {
$record = 0x01C1; // Record identifier $record = 0x01C1; // Record identifier
$length = 8; // Number of bytes to follow $length = 8; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
@ -1257,10 +1257,10 @@ class Workbook extends BIFFwriter
{ {
$aref = $this->palette; $aref = $this->palette;
$record = 0x0092; // Record identifier $record = 0x0092; // Record identifier
$length = 2 + 4 * count($aref); // Number of bytes to follow $length = 2 + 4 * count($aref); // Number of bytes to follow
$ccv = count($aref); // Number of RGB values to follow $ccv = count($aref); // Number of RGB values to follow
$data = ''; // The RGB data $data = ''; // The RGB data
// Pack the RGB data // Pack the RGB data
foreach ($aref as $color) { foreach ($aref as $color) {

View File

@ -542,7 +542,7 @@ class Worksheet extends BIFFwriter
} }
$firstCellCoordinates = \PhpSpreadsheet\Cell::coordinateFromString($firstCell); // e.g. array(0, 1) $firstCellCoordinates = \PhpSpreadsheet\Cell::coordinateFromString($firstCell); // e.g. array(0, 1)
$lastCellCoordinates = \PhpSpreadsheet\Cell::coordinateFromString($lastCell); // e.g. array(1, 6) $lastCellCoordinates = \PhpSpreadsheet\Cell::coordinateFromString($lastCell); // e.g. array(1, 6)
return pack('vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, \PhpSpreadsheet\Cell::columnIndexFromString($firstCellCoordinates[0]) - 1, \PhpSpreadsheet\Cell::columnIndexFromString($lastCellCoordinates[0]) - 1); return pack('vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, \PhpSpreadsheet\Cell::columnIndexFromString($firstCellCoordinates[0]) - 1, \PhpSpreadsheet\Cell::columnIndexFromString($lastCellCoordinates[0]) - 1);
} }
@ -616,8 +616,8 @@ class Worksheet extends BIFFwriter
*/ */
private function writeNumber($row, $col, $num, $xfIndex) private function writeNumber($row, $col, $num, $xfIndex)
{ {
$record = 0x0203; // Record identifier $record = 0x0203; // Record identifier
$length = 0x000E; // Number of bytes to follow $length = 0x000E; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vvv', $row, $col, $xfIndex); $data = pack('vvv', $row, $col, $xfIndex);
@ -655,8 +655,8 @@ class Worksheet extends BIFFwriter
*/ */
private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun) private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun)
{ {
$record = 0x00FD; // Record identifier $record = 0x00FD; // Record identifier
$length = 0x000A; // Bytes to follow $length = 0x000A; // Bytes to follow
$str = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($str, $arrcRun); $str = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeShort($str, $arrcRun);
/* check if string is already present */ /* check if string is already present */
@ -687,8 +687,8 @@ class Worksheet extends BIFFwriter
private function writeLabel($row, $col, $str, $xfIndex) private function writeLabel($row, $col, $str, $xfIndex)
{ {
$strlen = strlen($str); $strlen = strlen($str);
$record = 0x0204; // Record identifier $record = 0x0204; // Record identifier
$length = 0x0008 + $strlen; // Bytes to follow $length = 0x0008 + $strlen; // Bytes to follow
$str_error = 0; $str_error = 0;
@ -722,8 +722,8 @@ class Worksheet extends BIFFwriter
*/ */
private function writeLabelSst($row, $col, $str, $xfIndex) private function writeLabelSst($row, $col, $str, $xfIndex)
{ {
$record = 0x00FD; // Record identifier $record = 0x00FD; // Record identifier
$length = 0x000A; // Bytes to follow $length = 0x000A; // Bytes to follow
$str = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($str); $str = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($str);
@ -749,8 +749,8 @@ class Worksheet extends BIFFwriter
private function writeNote($row, $col, $note) private function writeNote($row, $col, $note)
{ {
$note_length = strlen($note); $note_length = strlen($note);
$record = 0x001C; // Record identifier $record = 0x001C; // Record identifier
$max_length = 2048; // Maximun length for a NOTE record $max_length = 2048; // Maximun length for a NOTE record
// Length for this record is no more than 2048 + 6 // Length for this record is no more than 2048 + 6
$length = 0x0006 + min($note_length, 2048); $length = 0x0006 + min($note_length, 2048);
@ -787,8 +787,8 @@ class Worksheet extends BIFFwriter
*/ */
public function writeBlank($row, $col, $xfIndex) public function writeBlank($row, $col, $xfIndex)
{ {
$record = 0x0201; // Record identifier $record = 0x0201; // Record identifier
$length = 0x0006; // Number of bytes to follow $length = 0x0006; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vvv', $row, $col, $xfIndex); $data = pack('vvv', $row, $col, $xfIndex);
@ -836,7 +836,7 @@ class Worksheet extends BIFFwriter
*/ */
private function writeFormula($row, $col, $formula, $xfIndex, $calculatedValue) private function writeFormula($row, $col, $formula, $xfIndex, $calculatedValue)
{ {
$record = 0x0006; // Record identifier $record = 0x0006; // Record identifier
// Initialize possible additional value for STRING record that should be written after the FORMULA record? // Initialize possible additional value for STRING record that should be written after the FORMULA record?
$stringValue = null; $stringValue = null;
@ -871,8 +871,8 @@ class Worksheet extends BIFFwriter
$num = pack('d', 0x00); $num = pack('d', 0x00);
} }
$grbit = 0x03; // Option flags $grbit = 0x03; // Option flags
$unknown = 0x0000; // Must be zero $unknown = 0x0000; // Must be zero
// Strip the '=' or '@' sign at the beginning of the formula string // Strip the '=' or '@' sign at the beginning of the formula string
if ($formula{0} == '=') { if ($formula{0} == '=') {
@ -889,8 +889,8 @@ class Worksheet extends BIFFwriter
$error = $this->parser->parse($formula); $error = $this->parser->parse($formula);
$formula = $this->parser->toReversePolish(); $formula = $this->parser->toReversePolish();
$formlen = strlen($formula); // Length of the binary string $formlen = strlen($formula); // Length of the binary string
$length = 0x16 + $formlen; // Length of the record data $length = 0x16 + $formlen; // Length of the record data
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
@ -917,7 +917,7 @@ class Worksheet extends BIFFwriter
*/ */
private function writeStringRecord($stringValue) private function writeStringRecord($stringValue)
{ {
$record = 0x0207; // Record identifier $record = 0x0207; // Record identifier
$data = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($stringValue); $data = \PhpSpreadsheet\Shared\StringHelper::UTF8toBIFF8UnicodeLong($stringValue);
$length = strlen($data); $length = strlen($data);
@ -994,8 +994,8 @@ class Worksheet extends BIFFwriter
*/ */
public function writeUrlWeb($row1, $col1, $row2, $col2, $url) public function writeUrlWeb($row1, $col1, $row2, $col2, $url)
{ {
$record = 0x01B8; // Record identifier $record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow $length = 0x00000; // Bytes to follow
// Pack the undocumented parts of the hyperlink stream // Pack the undocumented parts of the hyperlink stream
$unknown1 = pack('H*', 'D0C9EA79F9BACE118C8200AA004BA90B02000000'); $unknown1 = pack('H*', 'D0C9EA79F9BACE118C8200AA004BA90B02000000');
@ -1039,8 +1039,8 @@ class Worksheet extends BIFFwriter
*/ */
public function writeUrlInternal($row1, $col1, $row2, $col2, $url) public function writeUrlInternal($row1, $col1, $row2, $col2, $url)
{ {
$record = 0x01B8; // Record identifier $record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow $length = 0x00000; // Bytes to follow
// Strip URL type // Strip URL type
$url = preg_replace('/^internal:/', '', $url); $url = preg_replace('/^internal:/', '', $url);
@ -1098,8 +1098,8 @@ class Worksheet extends BIFFwriter
return; //($this->writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format)); return; //($this->writeUrlExternal_net($row1, $col1, $row2, $col2, $url, $str, $format));
} }
$record = 0x01B8; // Record identifier $record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow $length = 0x00000; // Bytes to follow
// Strip URL type and change Unix dir separator to Dos style (if needed) // Strip URL type and change Unix dir separator to Dos style (if needed)
// //
@ -1158,7 +1158,7 @@ class Worksheet extends BIFFwriter
$dir_short_len . $dir_short_len .
$dir_short . $dir_short .
$unknown3 . $unknown3 .
$stream_len;/*. $stream_len; /*.
$dir_long_len . $dir_long_len .
$unknown4 . $unknown4 .
$dir_long . $dir_long .
@ -1187,14 +1187,14 @@ class Worksheet extends BIFFwriter
*/ */
private function writeRow($row, $height, $xfIndex, $hidden = false, $level = 0) private function writeRow($row, $height, $xfIndex, $hidden = false, $level = 0)
{ {
$record = 0x0208; // Record identifier $record = 0x0208; // Record identifier
$length = 0x0010; // Number of bytes to follow $length = 0x0010; // Number of bytes to follow
$colMic = 0x0000; // First defined column $colMic = 0x0000; // First defined column
$colMac = 0x0000; // Last defined column $colMac = 0x0000; // Last defined column
$irwMac = 0x0000; // Used by Excel to optimise loading $irwMac = 0x0000; // Used by Excel to optimise loading
$reserved = 0x0000; // Reserved $reserved = 0x0000; // Reserved
$grbit = 0x0000; // Option flags $grbit = 0x0000; // Option flags
$ixfe = $xfIndex; $ixfe = $xfIndex;
if ($height < 0) { if ($height < 0) {
@ -1203,9 +1203,9 @@ class Worksheet extends BIFFwriter
// Use writeRow($row, null, $XF) to set XF format without setting height // Use writeRow($row, null, $XF) to set XF format without setting height
if ($height != null) { if ($height != null) {
$miyRw = $height * 20; // row height $miyRw = $height * 20; // row height
} else { } else {
$miyRw = 0xff; // default row height is 256 $miyRw = 0xff; // default row height is 256
} }
// Set the options flags. fUnsynced is used to show that the font and row // Set the options flags. fUnsynced is used to show that the font and row
@ -1250,26 +1250,26 @@ class Worksheet extends BIFFwriter
*/ */
private function writeWindow2() private function writeWindow2()
{ {
$record = 0x023E; // Record identifier $record = 0x023E; // Record identifier
$length = 0x0012; $length = 0x0012;
$grbit = 0x00B6; // Option flags $grbit = 0x00B6; // Option flags
$rwTop = 0x0000; // Top row visible in window $rwTop = 0x0000; // Top row visible in window
$colLeft = 0x0000; // Leftmost column visible in window $colLeft = 0x0000; // Leftmost column visible in window
// The options flags that comprise $grbit // The options flags that comprise $grbit
$fDspFmla = 0; // 0 - bit $fDspFmla = 0; // 0 - bit
$fDspGrid = $this->phpSheet->getShowGridlines() ? 1 : 0; // 1 $fDspGrid = $this->phpSheet->getShowGridlines() ? 1 : 0; // 1
$fDspRwCol = $this->phpSheet->getShowRowColHeaders() ? 1 : 0; // 2 $fDspRwCol = $this->phpSheet->getShowRowColHeaders() ? 1 : 0; // 2
$fFrozen = $this->phpSheet->getFreezePane() ? 1 : 0; // 3 $fFrozen = $this->phpSheet->getFreezePane() ? 1 : 0; // 3
$fDspZeros = 1; // 4 $fDspZeros = 1; // 4
$fDefaultHdr = 1; // 5 $fDefaultHdr = 1; // 5
$fArabic = $this->phpSheet->getRightToLeft() ? 1 : 0; // 6 $fArabic = $this->phpSheet->getRightToLeft() ? 1 : 0; // 6
$fDspGuts = $this->outlineOn; // 7 $fDspGuts = $this->outlineOn; // 7
$fFrozenNoSplit = 0; // 0 - bit $fFrozenNoSplit = 0; // 0 - bit
// no support in PhpSpreadsheet for selected sheet, therefore sheet is only selected if it is the active sheet // no support in PhpSpreadsheet for selected sheet, therefore sheet is only selected if it is the active sheet
$fSelected = ($this->phpSheet === $this->phpSheet->getParent()->getActiveSheet()) ? 1 : 0; $fSelected = ($this->phpSheet === $this->phpSheet->getParent()->getActiveSheet()) ? 1 : 0;
$fPaged = 1; // 2 $fPaged = 1; // 2
$fPageBreakPreview = $this->phpSheet->getSheetView()->getView() === \PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW; $fPageBreakPreview = $this->phpSheet->getSheetView()->getView() === \PhpSpreadsheet\Worksheet\SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW;
$grbit = $fDspFmla; $grbit = $fDspFmla;
@ -1312,8 +1312,8 @@ class Worksheet extends BIFFwriter
// convert to twips // convert to twips
$defaultRowHeight = (int) 20 * $defaultRowHeight; $defaultRowHeight = (int) 20 * $defaultRowHeight;
$record = 0x0225; // Record identifier $record = 0x0225; // Record identifier
$length = 0x0004; // Number of bytes to follow $length = 0x0004; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vv', 1, $defaultRowHeight); $data = pack('vv', 1, $defaultRowHeight);
@ -1327,8 +1327,8 @@ class Worksheet extends BIFFwriter
{ {
$defaultColWidth = 8; $defaultColWidth = 8;
$record = 0x0055; // Record identifier $record = 0x0055; // Record identifier
$length = 0x0002; // Number of bytes to follow $length = 0x0002; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $defaultColWidth); $data = pack('v', $defaultColWidth);
@ -1377,13 +1377,13 @@ class Worksheet extends BIFFwriter
} else { } else {
$level = 0; $level = 0;
} }
$record = 0x007D; // Record identifier $record = 0x007D; // Record identifier
$length = 0x000C; // Number of bytes to follow $length = 0x000C; // Number of bytes to follow
$coldx *= 256; // Convert to units of 1/256 of a char $coldx *= 256; // Convert to units of 1/256 of a char
$ixfe = $xfIndex; $ixfe = $xfIndex;
$reserved = 0x0000; // Reserved $reserved = 0x0000; // Reserved
$level = max(0, min($level, 7)); $level = max(0, min($level, 7));
$grbit |= $level << 8; $grbit |= $level << 8;
@ -1424,20 +1424,20 @@ class Worksheet extends BIFFwriter
$rwFirst = min($rwFirst, 65535); $rwFirst = min($rwFirst, 65535);
$rwLast = min($rwLast, 65535); $rwLast = min($rwLast, 65535);
$record = 0x001D; // Record identifier $record = 0x001D; // Record identifier
$length = 0x000F; // Number of bytes to follow $length = 0x000F; // Number of bytes to follow
$pnn = $this->activePane; // Pane position $pnn = $this->activePane; // Pane position
$rwAct = $rwFirst; // Active row $rwAct = $rwFirst; // Active row
$colAct = $colFirst; // Active column $colAct = $colFirst; // Active column
$irefAct = 0; // Active cell ref $irefAct = 0; // Active cell ref
$cref = 1; // Number of refs $cref = 1; // Number of refs
if (!isset($rwLast)) { if (!isset($rwLast)) {
$rwLast = $rwFirst; // Last row in reference $rwLast = $rwFirst; // Last row in reference
} }
if (!isset($colLast)) { if (!isset($colLast)) {
$colLast = $colFirst; // Last col in reference $colLast = $colFirst; // Last col in reference
} }
// Swap last row/col for first row/col as necessary // Swap last row/col for first row/col as necessary
@ -1621,7 +1621,7 @@ class Worksheet extends BIFFwriter
$length = strlen($recordData); $length = strlen($recordData);
$record = 0x0868; // Record identifier $record = 0x0868; // Record identifier
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$this->append($header . $recordData); $this->append($header . $recordData);
} }
@ -1641,8 +1641,8 @@ class Worksheet extends BIFFwriter
*/ */
private function writeExterncount($count) private function writeExterncount($count)
{ {
$record = 0x0016; // Record identifier $record = 0x0016; // Record identifier
$length = 0x0002; // Number of bytes to follow $length = 0x0002; // Number of bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $count); $data = pack('v', $count);
@ -1659,20 +1659,20 @@ class Worksheet extends BIFFwriter
*/ */
private function writeExternsheet($sheetname) private function writeExternsheet($sheetname)
{ {
$record = 0x0017; // Record identifier $record = 0x0017; // Record identifier
// References to the current sheet are encoded differently to references to // References to the current sheet are encoded differently to references to
// external sheets. // external sheets.
// //
if ($this->phpSheet->getTitle() == $sheetname) { if ($this->phpSheet->getTitle() == $sheetname) {
$sheetname = ''; $sheetname = '';
$length = 0x02; // The following 2 bytes $length = 0x02; // The following 2 bytes
$cch = 1; // The following byte $cch = 1; // The following byte
$rgch = 0x02; // Self reference $rgch = 0x02; // Self reference
} else { } else {
$length = 0x02 + strlen($sheetname); $length = 0x02 + strlen($sheetname);
$cch = strlen($sheetname); $cch = strlen($sheetname);
$rgch = 0x03; // Reference to a sheet in the current workbook $rgch = 0x03; // Reference to a sheet in the current workbook
} }
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
@ -1707,8 +1707,8 @@ class Worksheet extends BIFFwriter
} else { } else {
$pnnAct = null; $pnnAct = null;
} }
$record = 0x0041; // Record identifier $record = 0x0041; // Record identifier
$length = 0x000A; // Number of bytes to follow $length = 0x000A; // Number of bytes to follow
// Code specific to frozen or thawed panes. // Code specific to frozen or thawed panes.
if ($this->phpSheet->getFreezePane()) { if ($this->phpSheet->getFreezePane()) {
@ -1767,38 +1767,38 @@ class Worksheet extends BIFFwriter
*/ */
private function writeSetup() private function writeSetup()
{ {
$record = 0x00A1; // Record identifier $record = 0x00A1; // Record identifier
$length = 0x0022; // Number of bytes to follow $length = 0x0022; // Number of bytes to follow
$iPaperSize = $this->phpSheet->getPageSetup()->getPaperSize(); // Paper size $iPaperSize = $this->phpSheet->getPageSetup()->getPaperSize(); // Paper size
$iScale = $this->phpSheet->getPageSetup()->getScale() ? $iScale = $this->phpSheet->getPageSetup()->getScale() ?
$this->phpSheet->getPageSetup()->getScale() : 100; // Print scaling factor $this->phpSheet->getPageSetup()->getScale() : 100; // Print scaling factor
$iPageStart = 0x01; // Starting page number $iPageStart = 0x01; // Starting page number
$iFitWidth = (int) $this->phpSheet->getPageSetup()->getFitToWidth(); // Fit to number of pages wide $iFitWidth = (int) $this->phpSheet->getPageSetup()->getFitToWidth(); // Fit to number of pages wide
$iFitHeight = (int) $this->phpSheet->getPageSetup()->getFitToHeight(); // Fit to number of pages high $iFitHeight = (int) $this->phpSheet->getPageSetup()->getFitToHeight(); // Fit to number of pages high
$grbit = 0x00; // Option flags $grbit = 0x00; // Option flags
$iRes = 0x0258; // Print resolution $iRes = 0x0258; // Print resolution
$iVRes = 0x0258; // Vertical print resolution $iVRes = 0x0258; // Vertical print resolution
$numHdr = $this->phpSheet->getPageMargins()->getHeader(); // Header Margin $numHdr = $this->phpSheet->getPageMargins()->getHeader(); // Header Margin
$numFtr = $this->phpSheet->getPageMargins()->getFooter(); // Footer Margin $numFtr = $this->phpSheet->getPageMargins()->getFooter(); // Footer Margin
$iCopies = 0x01; // Number of copies $iCopies = 0x01; // Number of copies
$fLeftToRight = 0x0; // Print over then down $fLeftToRight = 0x0; // Print over then down
// Page orientation // Page orientation
$fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == \PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? $fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == \PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ?
0x0 : 0x1; 0x0 : 0x1;
$fNoPls = 0x0; // Setup not read from printer $fNoPls = 0x0; // Setup not read from printer
$fNoColor = 0x0; // Print black and white $fNoColor = 0x0; // Print black and white
$fDraft = 0x0; // Print draft quality $fDraft = 0x0; // Print draft quality
$fNotes = 0x0; // Print notes $fNotes = 0x0; // Print notes
$fNoOrient = 0x0; // Orientation not set $fNoOrient = 0x0; // Orientation not set
$fUsePage = 0x0; // Use custom starting page $fUsePage = 0x0; // Use custom starting page
$grbit = $fLeftToRight; $grbit = $fLeftToRight;
$grbit |= $fLandscape << 1; $grbit |= $fLandscape << 1;
@ -1828,7 +1828,7 @@ class Worksheet extends BIFFwriter
*/ */
private function writeHeader() private function writeHeader()
{ {
$record = 0x0014; // Record identifier $record = 0x0014; // Record identifier
/* removing for now /* removing for now
// need to fix character count (multibyte!) // need to fix character count (multibyte!)
@ -1852,7 +1852,7 @@ class Worksheet extends BIFFwriter
*/ */
private function writeFooter() private function writeFooter()
{ {
$record = 0x0015; // Record identifier $record = 0x0015; // Record identifier
/* removing for now /* removing for now
// need to fix character count (multibyte!) // need to fix character count (multibyte!)
@ -1876,10 +1876,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writeHcenter() private function writeHcenter()
{ {
$record = 0x0083; // Record identifier $record = 0x0083; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$fHCenter = $this->phpSheet->getPageSetup()->getHorizontalCentered() ? 1 : 0; // Horizontal centering $fHCenter = $this->phpSheet->getPageSetup()->getHorizontalCentered() ? 1 : 0; // Horizontal centering
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $fHCenter); $data = pack('v', $fHCenter);
@ -1892,10 +1892,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writeVcenter() private function writeVcenter()
{ {
$record = 0x0084; // Record identifier $record = 0x0084; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$fVCenter = $this->phpSheet->getPageSetup()->getVerticalCentered() ? 1 : 0; // Horizontal centering $fVCenter = $this->phpSheet->getPageSetup()->getVerticalCentered() ? 1 : 0; // Horizontal centering
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $fVCenter); $data = pack('v', $fVCenter);
@ -1907,10 +1907,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writeMarginLeft() private function writeMarginLeft()
{ {
$record = 0x0026; // Record identifier $record = 0x0026; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getLeft(); // Margin in inches $margin = $this->phpSheet->getPageMargins()->getLeft(); // Margin in inches
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('d', $margin); $data = pack('d', $margin);
@ -1926,10 +1926,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writeMarginRight() private function writeMarginRight()
{ {
$record = 0x0027; // Record identifier $record = 0x0027; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getRight(); // Margin in inches $margin = $this->phpSheet->getPageMargins()->getRight(); // Margin in inches
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('d', $margin); $data = pack('d', $margin);
@ -1945,10 +1945,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writeMarginTop() private function writeMarginTop()
{ {
$record = 0x0028; // Record identifier $record = 0x0028; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getTop(); // Margin in inches $margin = $this->phpSheet->getPageMargins()->getTop(); // Margin in inches
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('d', $margin); $data = pack('d', $margin);
@ -1964,10 +1964,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writeMarginBottom() private function writeMarginBottom()
{ {
$record = 0x0029; // Record identifier $record = 0x0029; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getBottom(); // Margin in inches $margin = $this->phpSheet->getPageMargins()->getBottom(); // Margin in inches
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('d', $margin); $data = pack('d', $margin);
@ -1983,10 +1983,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writePrintHeaders() private function writePrintHeaders()
{ {
$record = 0x002a; // Record identifier $record = 0x002a; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$fPrintRwCol = $this->_print_headers; // Boolean flag $fPrintRwCol = $this->_print_headers; // Boolean flag
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $fPrintRwCol); $data = pack('v', $fPrintRwCol);
@ -1999,10 +1999,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writePrintGridlines() private function writePrintGridlines()
{ {
$record = 0x002b; // Record identifier $record = 0x002b; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$fPrintGrid = $this->phpSheet->getPrintGridlines() ? 1 : 0; // Boolean flag $fPrintGrid = $this->phpSheet->getPrintGridlines() ? 1 : 0; // Boolean flag
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $fPrintGrid); $data = pack('v', $fPrintGrid);
@ -2015,10 +2015,10 @@ class Worksheet extends BIFFwriter
*/ */
private function writeGridset() private function writeGridset()
{ {
$record = 0x0082; // Record identifier $record = 0x0082; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$fGridSet = !$this->phpSheet->getPrintGridlines(); // Boolean flag $fGridSet = !$this->phpSheet->getPrintGridlines(); // Boolean flag
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $fGridSet); $data = pack('v', $fGridSet);
@ -2030,8 +2030,8 @@ class Worksheet extends BIFFwriter
*/ */
private function writeAutoFilterInfo() private function writeAutoFilterInfo()
{ {
$record = 0x009D; // Record identifier $record = 0x009D; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$rangeBounds = \PhpSpreadsheet\Cell::rangeBoundaries($this->phpSheet->getAutoFilter()->getRange()); $rangeBounds = \PhpSpreadsheet\Cell::rangeBoundaries($this->phpSheet->getAutoFilter()->getRange());
$iNumFilters = 1 + $rangeBounds[1][0] - $rangeBounds[0][0]; $iNumFilters = 1 + $rangeBounds[1][0] - $rangeBounds[0][0];
@ -2050,11 +2050,11 @@ class Worksheet extends BIFFwriter
*/ */
private function writeGuts() private function writeGuts()
{ {
$record = 0x0080; // Record identifier $record = 0x0080; // Record identifier
$length = 0x0008; // Bytes to follow $length = 0x0008; // Bytes to follow
$dxRwGut = 0x0000; // Size of row gutter $dxRwGut = 0x0000; // Size of row gutter
$dxColGut = 0x0000; // Size of col gutter $dxColGut = 0x0000; // Size of col gutter
// determine maximum row outline level // determine maximum row outline level
$maxRowOutlineLevel = 0; $maxRowOutlineLevel = 0;
@ -2094,15 +2094,15 @@ class Worksheet extends BIFFwriter
*/ */
private function writeWsbool() private function writeWsbool()
{ {
$record = 0x0081; // Record identifier $record = 0x0081; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$grbit = 0x0000; $grbit = 0x0000;
// The only option that is of interest is the flag for fit to page. So we // The only option that is of interest is the flag for fit to page. So we
// set all the options in one go. // set all the options in one go.
// //
// Set the option flags // Set the option flags
$grbit |= 0x0001; // Auto page breaks visible $grbit |= 0x0001; // Auto page breaks visible
if ($this->outlineStyle) { if ($this->outlineStyle) {
$grbit |= 0x0020; // Auto outline styles $grbit |= 0x0020; // Auto outline styles
} }
@ -2162,9 +2162,9 @@ class Worksheet extends BIFFwriter
array_shift($hbreaks); array_shift($hbreaks);
} }
$record = 0x001b; // Record identifier $record = 0x001b; // Record identifier
$cbrk = count($hbreaks); // Number of page breaks $cbrk = count($hbreaks); // Number of page breaks
$length = 2 + 6 * $cbrk; // Bytes to follow $length = 2 + 6 * $cbrk; // Bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $cbrk); $data = pack('v', $cbrk);
@ -2189,9 +2189,9 @@ class Worksheet extends BIFFwriter
array_shift($vbreaks); array_shift($vbreaks);
} }
$record = 0x001a; // Record identifier $record = 0x001a; // Record identifier
$cbrk = count($vbreaks); // Number of page breaks $cbrk = count($vbreaks); // Number of page breaks
$length = 2 + 6 * $cbrk; // Bytes to follow $length = 2 + 6 * $cbrk; // Bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $cbrk); $data = pack('v', $cbrk);
@ -2215,10 +2215,10 @@ class Worksheet extends BIFFwriter
return; return;
} }
$record = 0x0012; // Record identifier $record = 0x0012; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$fLock = 1; // Worksheet is protected $fLock = 1; // Worksheet is protected
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $fLock); $data = pack('v', $fLock);
@ -2284,10 +2284,10 @@ class Worksheet extends BIFFwriter
return; return;
} }
$record = 0x0013; // Record identifier $record = 0x0013; // Record identifier
$length = 0x0002; // Bytes to follow $length = 0x0002; // Bytes to follow
$wPassword = hexdec($this->phpSheet->getProtection()->getPassword()); // Encoded password $wPassword = hexdec($this->phpSheet->getProtection()->getPassword()); // Encoded password
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('v', $wPassword); $data = pack('v', $wPassword);
@ -2382,8 +2382,8 @@ class Worksheet extends BIFFwriter
public function positionImage($col_start, $row_start, $x1, $y1, $width, $height) public function positionImage($col_start, $row_start, $x1, $y1, $width, $height)
{ {
// Initialise end cell to the same as the start cell // Initialise end cell to the same as the start cell
$col_end = $col_start; // Col containing lower right corner of object $col_end = $col_start; // Col containing lower right corner of object
$row_end = $row_start; // Row containing bottom right corner of object $row_end = $row_start; // Row containing bottom right corner of object
// Zero the specified offset if greater than the cell dimensions // Zero the specified offset if greater than the cell dimensions
if ($x1 >= \PhpSpreadsheet\Shared\Excel5::sizeCol($this->phpSheet, \PhpSpreadsheet\Cell::stringFromColumnIndex($col_start))) { if ($x1 >= \PhpSpreadsheet\Shared\Excel5::sizeCol($this->phpSheet, \PhpSpreadsheet\Cell::stringFromColumnIndex($col_start))) {
@ -2448,33 +2448,33 @@ class Worksheet extends BIFFwriter
*/ */
private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB) private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB)
{ {
$record = 0x005d; // Record identifier $record = 0x005d; // Record identifier
$length = 0x003c; // Bytes to follow $length = 0x003c; // Bytes to follow
$cObj = 0x0001; // Count of objects in file (set to 1) $cObj = 0x0001; // Count of objects in file (set to 1)
$OT = 0x0008; // Object type. 8 = Picture $OT = 0x0008; // Object type. 8 = Picture
$id = 0x0001; // Object ID $id = 0x0001; // Object ID
$grbit = 0x0614; // Option flags $grbit = 0x0614; // Option flags
$cbMacro = 0x0000; // Length of FMLA structure $cbMacro = 0x0000; // Length of FMLA structure
$Reserved1 = 0x0000; // Reserved $Reserved1 = 0x0000; // Reserved
$Reserved2 = 0x0000; // Reserved $Reserved2 = 0x0000; // Reserved
$icvBack = 0x09; // Background colour $icvBack = 0x09; // Background colour
$icvFore = 0x09; // Foreground colour $icvFore = 0x09; // Foreground colour
$fls = 0x00; // Fill pattern $fls = 0x00; // Fill pattern
$fAuto = 0x00; // Automatic fill $fAuto = 0x00; // Automatic fill
$icv = 0x08; // Line colour $icv = 0x08; // Line colour
$lns = 0xff; // Line style $lns = 0xff; // Line style
$lnw = 0x01; // Line weight $lnw = 0x01; // Line weight
$fAutoB = 0x00; // Automatic border $fAutoB = 0x00; // Automatic border
$frs = 0x0000; // Frame style $frs = 0x0000; // Frame style
$cf = 0x0009; // Image format, 9 = bitmap $cf = 0x0009; // Image format, 9 = bitmap
$Reserved3 = 0x0000; // Reserved $Reserved3 = 0x0000; // Reserved
$cbPictFmla = 0x0000; // Length of FMLA structure $cbPictFmla = 0x0000; // Length of FMLA structure
$Reserved4 = 0x0000; // Reserved $Reserved4 = 0x0000; // Reserved
$grbit2 = 0x0001; // Option flags $grbit2 = 0x0001; // Option flags
$Reserved5 = 0x0000; // Reserved $Reserved5 = 0x0000; // Reserved
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('V', $cObj); $data = pack('V', $cObj);
@ -2636,8 +2636,8 @@ class Worksheet extends BIFFwriter
return; return;
} }
$record = 0x00A0; // Record identifier $record = 0x00A0; // Record identifier
$length = 0x0004; // Bytes to follow $length = 0x0004; // Bytes to follow
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vv', $this->phpSheet->getSheetView()->getZoomScale(), 100); $data = pack('vv', $this->phpSheet->getSheetView()->getZoomScale(), 100);
@ -2682,7 +2682,7 @@ class Worksheet extends BIFFwriter
$nm = count($spOffsets) - 1; // number of shapes excluding first shape $nm = count($spOffsets) - 1; // number of shapes excluding first shape
for ($i = 1; $i <= $nm; ++$i) { for ($i = 1; $i <= $nm; ++$i) {
// MSODRAWING record // MSODRAWING record
$record = 0x00EC; // Record identifier $record = 0x00EC; // Record identifier
// chunk of Escher stream for one shape // chunk of Escher stream for one shape
$dataChunk = substr($data, $spOffsets[$i - 1], $spOffsets[$i] - $spOffsets[$i - 1]); $dataChunk = substr($data, $spOffsets[$i - 1], $spOffsets[$i] - $spOffsets[$i - 1]);
@ -2760,20 +2760,20 @@ class Worksheet extends BIFFwriter
// Write data validations? // Write data validations?
if (!empty($dataValidationCollection)) { if (!empty($dataValidationCollection)) {
// DATAVALIDATIONS record // DATAVALIDATIONS record
$record = 0x01B2; // Record identifier $record = 0x01B2; // Record identifier
$length = 0x0012; // Bytes to follow $length = 0x0012; // Bytes to follow
$grbit = 0x0000; // Prompt box at cell, no cached validity data at DV records $grbit = 0x0000; // Prompt box at cell, no cached validity data at DV records
$horPos = 0x00000000; // Horizontal position of prompt box, if fixed position $horPos = 0x00000000; // Horizontal position of prompt box, if fixed position
$verPos = 0x00000000; // Vertical position of prompt box, if fixed position $verPos = 0x00000000; // Vertical position of prompt box, if fixed position
$objId = 0xFFFFFFFF; // Object identifier of drop down arrow object, or -1 if not visible $objId = 0xFFFFFFFF; // Object identifier of drop down arrow object, or -1 if not visible
$header = pack('vv', $record, $length); $header = pack('vv', $record, $length);
$data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection)); $data = pack('vVVVV', $grbit, $horPos, $verPos, $objId, count($dataValidationCollection));
$this->append($header . $data); $this->append($header . $data);
// DATAVALIDATION records // DATAVALIDATION records
$record = 0x01BE; // Record identifier $record = 0x01BE; // Record identifier
foreach ($dataValidationCollection as $cellCoordinate => $dataValidation) { foreach ($dataValidationCollection as $cellCoordinate => $dataValidation) {
// initialize record data // initialize record data
@ -2973,8 +2973,8 @@ class Worksheet extends BIFFwriter
*/ */
private function writePageLayoutView() private function writePageLayoutView()
{ {
$record = 0x088B; // Record identifier $record = 0x088B; // Record identifier
$length = 0x0010; // Bytes to follow $length = 0x0010; // Bytes to follow
$rt = 0x088B; // 2 $rt = 0x088B; // 2
$grbitFrt = 0x0000; // 2 $grbitFrt = 0x0000; // 2
@ -3005,7 +3005,7 @@ class Worksheet extends BIFFwriter
*/ */
private function writeCFRule(\PhpSpreadsheet\Style\Conditional $conditional) private function writeCFRule(\PhpSpreadsheet\Style\Conditional $conditional)
{ {
$record = 0x01B1; // Record identifier $record = 0x01B1; // Record identifier
// $type : Type of the CF // $type : Type of the CF
// $operatorType : Comparison operator // $operatorType : Comparison operator
@ -3125,43 +3125,43 @@ class Worksheet extends BIFFwriter
} }
// Alignment // Alignment
$flags = 0; $flags = 0;
$flags |= (1 == $bAlignHz ? 0x00000001 : 0); $flags |= (1 == $bAlignHz ? 0x00000001 : 0);
$flags |= (1 == $bAlignVt ? 0x00000002 : 0); $flags |= (1 == $bAlignVt ? 0x00000002 : 0);
$flags |= (1 == $bAlignWrapTx ? 0x00000004 : 0); $flags |= (1 == $bAlignWrapTx ? 0x00000004 : 0);
$flags |= (1 == $bTxRotation ? 0x00000008 : 0); $flags |= (1 == $bTxRotation ? 0x00000008 : 0);
// Justify last line flag // Justify last line flag
$flags |= (1 == 1 ? 0x00000010 : 0); $flags |= (1 == 1 ? 0x00000010 : 0);
$flags |= (1 == $bIndent ? 0x00000020 : 0); $flags |= (1 == $bIndent ? 0x00000020 : 0);
$flags |= (1 == $bShrinkToFit ? 0x00000040 : 0); $flags |= (1 == $bShrinkToFit ? 0x00000040 : 0);
// Default // Default
$flags |= (1 == 1 ? 0x00000080 : 0); $flags |= (1 == 1 ? 0x00000080 : 0);
// Protection // Protection
$flags |= (1 == $bProtLocked ? 0x00000100 : 0); $flags |= (1 == $bProtLocked ? 0x00000100 : 0);
$flags |= (1 == $bProtHidden ? 0x00000200 : 0); $flags |= (1 == $bProtHidden ? 0x00000200 : 0);
// Border // Border
$flags |= (1 == $bBorderLeft ? 0x00000400 : 0); $flags |= (1 == $bBorderLeft ? 0x00000400 : 0);
$flags |= (1 == $bBorderRight ? 0x00000800 : 0); $flags |= (1 == $bBorderRight ? 0x00000800 : 0);
$flags |= (1 == $bBorderTop ? 0x00001000 : 0); $flags |= (1 == $bBorderTop ? 0x00001000 : 0);
$flags |= (1 == $bBorderBottom ? 0x00002000 : 0); $flags |= (1 == $bBorderBottom ? 0x00002000 : 0);
$flags |= (1 == 1 ? 0x00004000 : 0); // Top left to Bottom right border $flags |= (1 == 1 ? 0x00004000 : 0); // Top left to Bottom right border
$flags |= (1 == 1 ? 0x00008000 : 0); // Bottom left to Top right border $flags |= (1 == 1 ? 0x00008000 : 0); // Bottom left to Top right border
// Pattern // Pattern
$flags |= (1 == $bFillStyle ? 0x00010000 : 0); $flags |= (1 == $bFillStyle ? 0x00010000 : 0);
$flags |= (1 == $bFillColor ? 0x00020000 : 0); $flags |= (1 == $bFillColor ? 0x00020000 : 0);
$flags |= (1 == $bFillColorBg ? 0x00040000 : 0); $flags |= (1 == $bFillColorBg ? 0x00040000 : 0);
$flags |= (1 == 1 ? 0x00380000 : 0); $flags |= (1 == 1 ? 0x00380000 : 0);
// Font // Font
$flags |= (1 == $bFormatFont ? 0x04000000 : 0); $flags |= (1 == $bFormatFont ? 0x04000000 : 0);
// Alignment: // Alignment:
$flags |= (1 == $bFormatAlign ? 0x08000000 : 0); $flags |= (1 == $bFormatAlign ? 0x08000000 : 0);
// Border // Border
$flags |= (1 == $bFormatBorder ? 0x10000000 : 0); $flags |= (1 == $bFormatBorder ? 0x10000000 : 0);
// Pattern // Pattern
$flags |= (1 == $bFormatFill ? 0x20000000 : 0); $flags |= (1 == $bFormatFill ? 0x20000000 : 0);
// Protection // Protection
$flags |= (1 == $bFormatProt ? 0x40000000 : 0); $flags |= (1 == $bFormatProt ? 0x40000000 : 0);
// Text direction // Text direction
$flags |= (1 == 0 ? 0x80000000 : 0); $flags |= (1 == 0 ? 0x80000000 : 0);
// Data Blocks // Data Blocks
if ($bFormatFont == 1) { if ($bFormatFont == 1) {
@ -3406,11 +3406,11 @@ class Worksheet extends BIFFwriter
// Options flags for modified font attributes // Options flags for modified font attributes
$optionsFlags = 0; $optionsFlags = 0;
$optionsFlagsBold = ($conditional->getStyle()->getFont()->getBold() == null ? 1 : 0); $optionsFlagsBold = ($conditional->getStyle()->getFont()->getBold() == null ? 1 : 0);
$optionsFlags |= (1 == $optionsFlagsBold ? 0x00000002 : 0); $optionsFlags |= (1 == $optionsFlagsBold ? 0x00000002 : 0);
$optionsFlags |= (1 == 1 ? 0x00000008 : 0); $optionsFlags |= (1 == 1 ? 0x00000008 : 0);
$optionsFlags |= (1 == 1 ? 0x00000010 : 0); $optionsFlags |= (1 == 1 ? 0x00000010 : 0);
$optionsFlags |= (1 == 0 ? 0x00000020 : 0); $optionsFlags |= (1 == 0 ? 0x00000020 : 0);
$optionsFlags |= (1 == 1 ? 0x00000080 : 0); $optionsFlags |= (1 == 1 ? 0x00000080 : 0);
$dataBlockFont .= pack('V', $optionsFlags); $dataBlockFont .= pack('V', $optionsFlags);
// Escapement type // Escapement type
$dataBlockFont .= pack('V', $fontEscapement); $dataBlockFont .= pack('V', $fontEscapement);
@ -3781,10 +3781,10 @@ class Worksheet extends BIFFwriter
break; break;
case \PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR: case \PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR:
$blockFillPatternStyle = 0x00; $blockFillPatternStyle = 0x00;
break; // does not exist in BIFF8 break; // does not exist in BIFF8
case \PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH: case \PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH:
$blockFillPatternStyle = 0x00; $blockFillPatternStyle = 0x00;
break; // does not exist in BIFF8 break; // does not exist in BIFF8
default: default:
$blockFillPatternStyle = 0x00; $blockFillPatternStyle = 0x00;
break; break;
@ -4181,8 +4181,8 @@ class Worksheet extends BIFFwriter
*/ */
private function writeCFHeader() private function writeCFHeader()
{ {
$record = 0x01B0; // Record identifier $record = 0x01B0; // Record identifier
$length = 0x0016; // Bytes to follow $length = 0x0016; // Bytes to follow
$numColumnMin = null; $numColumnMin = null;
$numColumnMax = null; $numColumnMax = null;

View File

@ -167,16 +167,16 @@ class Xf
} }
// Flags to indicate if attributes have been set. // Flags to indicate if attributes have been set.
$atr_num = ($this->numberFormatIndex != 0)?1:0; $atr_num = ($this->numberFormatIndex != 0) ? 1 : 0;
$atr_fnt = ($this->fontIndex != 0)?1:0; $atr_fnt = ($this->fontIndex != 0) ? 1 : 0;
$atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0; $atr_alc = ((int) $this->_style->getAlignment()->getWrapText()) ? 1 : 0;
$atr_bdr = (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) || $atr_bdr = (self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) ||
self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) || self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) ||
self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) || self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()) ||
self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()))?1:0; self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle())) ? 1 : 0;
$atr_pat = (($this->foregroundColor != 0x40) || $atr_pat = (($this->foregroundColor != 0x40) ||
($this->backgroundColor != 0x41) || ($this->backgroundColor != 0x41) ||
self::mapFillType($this->_style->getFill()->getFillType()))?1:0; self::mapFillType($this->_style->getFill()->getFillType())) ? 1 : 0;
$atr_prot = self::mapLocked($this->_style->getProtection()->getLocked()) $atr_prot = self::mapLocked($this->_style->getProtection()->getLocked())
| self::mapHidden($this->_style->getProtection()->getHidden()); | self::mapHidden($this->_style->getProtection()->getHidden());
@ -197,13 +197,13 @@ class Xf
$this->_diag_color = 0; $this->_diag_color = 0;
} }
$record = 0x00E0; // Record identifier $record = 0x00E0; // Record identifier
$length = 0x0014; // Number of bytes to follow $length = 0x0014; // Number of bytes to follow
$ifnt = $this->fontIndex; // Index to FONT record $ifnt = $this->fontIndex; // Index to FONT record
$ifmt = $this->numberFormatIndex; // Index to FORMAT record $ifmt = $this->numberFormatIndex; // Index to FORMAT record
$align = $this->mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment $align = $this->mapHAlign($this->_style->getAlignment()->getHorizontal()); // Alignment
$align |= (int) $this->_style->getAlignment()->getWrapText() << 3; $align |= (int) $this->_style->getAlignment()->getWrapText() << 3;
$align |= self::mapVAlign($this->_style->getAlignment()->getVertical()) << 4; $align |= self::mapVAlign($this->_style->getAlignment()->getVertical()) << 4;
$align |= $this->textJustLast << 7; $align |= $this->textJustLast << 7;
@ -215,10 +215,10 @@ class Xf
$used_attrib |= $atr_pat << 6; $used_attrib |= $atr_pat << 6;
$used_attrib |= $atr_prot << 7; $used_attrib |= $atr_prot << 7;
$icv = $this->foregroundColor; // fg and bg pattern colors $icv = $this->foregroundColor; // fg and bg pattern colors
$icv |= $this->backgroundColor << 7; $icv |= $this->backgroundColor << 7;
$border1 = self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color $border1 = self::mapBorderStyle($this->_style->getBorders()->getLeft()->getBorderStyle()); // Border line style and color
$border1 |= self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4; $border1 |= self::mapBorderStyle($this->_style->getBorders()->getRight()->getBorderStyle()) << 4;
$border1 |= self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8; $border1 |= self::mapBorderStyle($this->_style->getBorders()->getTop()->getBorderStyle()) << 8;
$border1 |= self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12; $border1 |= self::mapBorderStyle($this->_style->getBorders()->getBottom()->getBorderStyle()) << 12;
@ -233,7 +233,7 @@ class Xf
$border1 |= $diag_tl_to_rb << 30; $border1 |= $diag_tl_to_rb << 30;
$border1 |= $diag_tr_to_lb << 31; $border1 |= $diag_tr_to_lb << 31;
$border2 = $this->topBorderColor; // Border color $border2 = $this->topBorderColor; // Border color
$border2 |= $this->bottomBorderColor << 7; $border2 |= $this->bottomBorderColor << 7;
$border2 |= $this->_diag_color << 14; $border2 |= $this->_diag_color << 14;
$border2 |= self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21; $border2 |= self::mapBorderStyle($this->_style->getBorders()->getDiagonal()->getBorderStyle()) << 21;
@ -413,8 +413,8 @@ class Xf
\PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10, \PhpSpreadsheet\Style\Fill::FILL_PATTERN_LIGHTTRELLIS => 0x10,
\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125 => 0x11, \PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125 => 0x11,
\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625 => 0x12, \PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY0625 => 0x12,
\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8 \PhpSpreadsheet\Style\Fill::FILL_GRADIENT_LINEAR => 0x00, // does not exist in BIFF8
\PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8 \PhpSpreadsheet\Style\Fill::FILL_GRADIENT_PATH => 0x00, // does not exist in BIFF8
]; ];
/** /**

View File

@ -666,10 +666,10 @@ class HTML extends BaseWriter implements IWriter
if ($drawing->getCoordinates() != $coordinates) { if ($drawing->getCoordinates() != $coordinates) {
continue; continue;
} }
ob_start(); // Let's start output buffering. ob_start(); // Let's start output buffering.
imagepng($drawing->getImageResource()); // This will normally output the image, but because of ob_start(), it won't. imagepng($drawing->getImageResource()); // This will normally output the image, but because of ob_start(), it won't.
$contents = ob_get_contents(); // Instead, output above is saved to $contents $contents = ob_get_contents(); // Instead, output above is saved to $contents
ob_end_clean(); // End the output buffer. ob_end_clean(); // End the output buffer.
$dataUri = 'data:image/jpeg;base64,' . base64_encode($contents); $dataUri = 'data:image/jpeg;base64,' . base64_encode($contents);
@ -1580,7 +1580,7 @@ class HTML extends BaseWriter implements IWriter
if (!in_array($baseCell, $adjustedBaseCells)) { if (!in_array($baseCell, $adjustedBaseCells)) {
// subtract rowspan by 1 // subtract rowspan by 1
--$this->isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan']; --$this->isBaseCell[$sheetIndex][$baseCell[0]][$baseCell[1]]['rowspan'];
$adjustedBaseCells[] = $baseCell; $adjustedBaseCells[] = $baseCell;
} }
} }

View File

@ -67,72 +67,72 @@ abstract class Core extends \PhpSpreadsheet\Writer\HTML
* @var array * @var array
*/ */
protected static $paperSizes = [ protected static $paperSizes = [
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER => 'LETTER', // (8.5 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER => 'LETTER', // (8.5 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER', // (8.5 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER', // (8.5 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID => [792.00, 1224.00], // (11 in. by 17 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID => [792.00, 1224.00], // (11 in. by 17 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEDGER => [1224.00, 792.00], // (17 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEDGER => [1224.00, 792.00], // (17 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL => 'LEGAL', // (8.5 in. by 14 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL => 'LEGAL', // (8.5 in. by 14 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STATEMENT => [396.00, 612.00], // (5.5 in. by 8.5 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STATEMENT => [396.00, 612.00], // (5.5 in. by 8.5 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_EXECUTIVE => 'EXECUTIVE', // (7.25 in. by 10.5 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_EXECUTIVE => 'EXECUTIVE', // (7.25 in. by 10.5 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3 => 'A3', // (297 mm by 420 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3 => 'A3', // (297 mm by 420 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4 => 'A4', // (210 mm by 297 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4 => 'A4', // (210 mm by 297 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_SMALL => 'A4', // (210 mm by 297 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_SMALL => 'A4', // (210 mm by 297 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5 => 'A5', // (148 mm by 210 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5 => 'A5', // (148 mm by 210 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4 => 'B4', // (250 mm by 353 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4 => 'B4', // (250 mm by 353 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5 => 'B5', // (176 mm by 250 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5 => 'B5', // (176 mm by 250 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_FOLIO => 'FOLIO', // (8.5 in. by 13 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_FOLIO => 'FOLIO', // (8.5 in. by 13 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_QUARTO => [609.45, 779.53], // (215 mm by 275 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_QUARTO => [609.45, 779.53], // (215 mm by 275 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_1 => [720.00, 1008.00], // (10 in. by 14 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_1 => [720.00, 1008.00], // (10 in. by 14 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_2 => [792.00, 1224.00], // (11 in. by 17 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_2 => [792.00, 1224.00], // (11 in. by 17 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NOTE => 'LETTER', // (8.5 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NOTE => 'LETTER', // (8.5 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO9_ENVELOPE => [279.00, 639.00], // (3.875 in. by 8.875 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO9_ENVELOPE => [279.00, 639.00], // (3.875 in. by 8.875 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO10_ENVELOPE => [297.00, 684.00], // (4.125 in. by 9.5 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO10_ENVELOPE => [297.00, 684.00], // (4.125 in. by 9.5 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO11_ENVELOPE => [324.00, 747.00], // (4.5 in. by 10.375 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO11_ENVELOPE => [324.00, 747.00], // (4.5 in. by 10.375 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO12_ENVELOPE => [342.00, 792.00], // (4.75 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO12_ENVELOPE => [342.00, 792.00], // (4.75 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO14_ENVELOPE => [360.00, 828.00], // (5 in. by 11.5 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_NO14_ENVELOPE => [360.00, 828.00], // (5 in. by 11.5 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C => [1224.00, 1584.00], // (17 in. by 22 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C => [1224.00, 1584.00], // (17 in. by 22 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_D => [1584.00, 2448.00], // (22 in. by 34 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_D => [1584.00, 2448.00], // (22 in. by 34 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_E => [2448.00, 3168.00], // (34 in. by 44 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_E => [2448.00, 3168.00], // (34 in. by 44 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_DL_ENVELOPE => [311.81, 623.62], // (110 mm by 220 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_DL_ENVELOPE => [311.81, 623.62], // (110 mm by 220 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C5_ENVELOPE => 'C5', // (162 mm by 229 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C5_ENVELOPE => 'C5', // (162 mm by 229 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C3_ENVELOPE => 'C3', // (324 mm by 458 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C3_ENVELOPE => 'C3', // (324 mm by 458 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C4_ENVELOPE => 'C4', // (229 mm by 324 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C4_ENVELOPE => 'C4', // (229 mm by 324 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C6_ENVELOPE => 'C6', // (114 mm by 162 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C6_ENVELOPE => 'C6', // (114 mm by 162 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C65_ENVELOPE => [323.15, 649.13], // (114 mm by 229 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_C65_ENVELOPE => [323.15, 649.13], // (114 mm by 229 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4_ENVELOPE => 'B4', // (250 mm by 353 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B4_ENVELOPE => 'B4', // (250 mm by 353 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5_ENVELOPE => 'B5', // (176 mm by 250 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B5_ENVELOPE => 'B5', // (176 mm by 250 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B6_ENVELOPE => [498.90, 354.33], // (176 mm by 125 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_B6_ENVELOPE => [498.90, 354.33], // (176 mm by 125 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ITALY_ENVELOPE => [311.81, 651.97], // (110 mm by 230 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ITALY_ENVELOPE => [311.81, 651.97], // (110 mm by 230 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_MONARCH_ENVELOPE => [279.00, 540.00], // (3.875 in. by 7.5 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_MONARCH_ENVELOPE => [279.00, 540.00], // (3.875 in. by 7.5 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_6_3_4_ENVELOPE => [261.00, 468.00], // (3.625 in. by 6.5 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_6_3_4_ENVELOPE => [261.00, 468.00], // (3.625 in. by 6.5 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_US_STANDARD_FANFOLD => [1071.00, 792.00], // (14.875 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_US_STANDARD_FANFOLD => [1071.00, 792.00], // (14.875 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD => [612.00, 864.00], // (8.5 in. by 12 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_STANDARD_FANFOLD => [612.00, 864.00], // (8.5 in. by 12 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD => 'FOLIO', // (8.5 in. by 13 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_GERMAN_LEGAL_FANFOLD => 'FOLIO', // (8.5 in. by 13 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B4 => 'B4', // (250 mm by 353 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B4 => 'B4', // (250 mm by 353 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD => [566.93, 419.53], // (200 mm by 148 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JAPANESE_DOUBLE_POSTCARD => [566.93, 419.53], // (200 mm by 148 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_1 => [648.00, 792.00], // (9 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_1 => [648.00, 792.00], // (9 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_2 => [720.00, 792.00], // (10 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_2 => [720.00, 792.00], // (10 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_3 => [1080.00, 792.00], // (15 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_STANDARD_PAPER_3 => [1080.00, 792.00], // (15 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_INVITE_ENVELOPE => [623.62, 623.62], // (220 mm by 220 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_INVITE_ENVELOPE => [623.62, 623.62], // (220 mm by 220 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER => [667.80, 1080.00], // (9.275 in. by 15 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LEGAL_EXTRA_PAPER => [667.80, 1080.00], // (9.275 in. by 15 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER => [841.68, 1296.00], // (11.69 in. by 18 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_TABLOID_EXTRA_PAPER => [841.68, 1296.00], // (11.69 in. by 18 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_EXTRA_PAPER => [668.98, 912.76], // (236 mm by 322 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_EXTRA_PAPER => [668.98, 912.76], // (236 mm by 322 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER => [595.80, 792.00], // (8.275 in. by 11 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_TRANSVERSE_PAPER => [595.80, 792.00], // (8.275 in. by 11 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER => 'A4', // (210 mm by 297 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_TRANSVERSE_PAPER => 'A4', // (210 mm by 297 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_EXTRA_TRANSVERSE_PAPER => [667.80, 864.00], // (9.275 in. by 12 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER => [643.46, 1009.13], // (227 mm by 356 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERA_SUPERA_A4_PAPER => [643.46, 1009.13], // (227 mm by 356 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER => [864.57, 1380.47], // (305 mm by 487 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_SUPERB_SUPERB_A3_PAPER => [864.57, 1380.47], // (305 mm by 487 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_PLUS_PAPER => [612.00, 913.68], // (8.5 in. by 12.69 in.) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER_PLUS_PAPER => [612.00, 913.68], // (8.5 in. by 12.69 in.)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_PLUS_PAPER => [595.28, 935.43], // (210 mm by 330 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A4_PLUS_PAPER => [595.28, 935.43], // (210 mm by 330 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER => 'A5', // (148 mm by 210 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_TRANSVERSE_PAPER => 'A5', // (148 mm by 210 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER => [515.91, 728.50], // (182 mm by 257 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_JIS_B5_TRANSVERSE_PAPER => [515.91, 728.50], // (182 mm by 257 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_EXTRA_PAPER => [912.76, 1261.42], // (322 mm by 445 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_EXTRA_PAPER => [912.76, 1261.42], // (322 mm by 445 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_EXTRA_PAPER => [493.23, 666.14], // (174 mm by 235 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A5_EXTRA_PAPER => [493.23, 666.14], // (174 mm by 235 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER => [569.76, 782.36], // (201 mm by 276 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_ISO_B5_EXTRA_PAPER => [569.76, 782.36], // (201 mm by 276 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A2_PAPER => 'A2', // (420 mm by 594 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A2_PAPER => 'A2', // (420 mm by 594 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER => 'A3', // (297 mm by 420 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_TRANSVERSE_PAPER => 'A3', // (297 mm by 420 mm)
\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER => [912.76, 1261.42], // (322 mm by 445 mm) \PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_A3_EXTRA_TRANSVERSE_PAPER => [912.76, 1261.42], // (322 mm by 445 mm)
]; ];
/** /**

View File

@ -55,7 +55,7 @@ class DomPDF extends Core implements \PhpSpreadsheet\Writer\IWriter
$fileHandle = parent::prepareForSave($pFilename); $fileHandle = parent::prepareForSave($pFilename);
// Default PDF paper size // Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {

View File

@ -55,7 +55,7 @@ class MPDF extends Core implements \PhpSpreadsheet\Writer\IWriter
$fileHandle = parent::prepareForSave($pFilename); $fileHandle = parent::prepareForSave($pFilename);
// Default PDF paper size // Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {

View File

@ -56,7 +56,7 @@ class TcPDF extends Core implements \PhpSpreadsheet\Writer\IWriter
$fileHandle = parent::prepareForSave($pFilename); $fileHandle = parent::prepareForSave($pFilename);
// Default PDF paper size // Default PDF paper size
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.) $paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
// Check for paper size and page orientation // Check for paper size and page orientation
if (is_null($this->getSheetIndex())) { if (is_null($this->getSheetIndex())) {

View File

@ -2,19 +2,19 @@
// DateTime object Result Comments // DateTime object Result Comments
return [ return [
[new DateTime('1900-01-01'), 1.0], // Excel 1900 base calendar date [new DateTime('1900-01-01'), 1.0], // Excel 1900 base calendar date
[new DateTime('1900-02-28'), 59.0], // This and next test show gap for the mythical [new DateTime('1900-02-28'), 59.0], // This and next test show gap for the mythical
[new DateTime('1900-03-01'), 61.0], // MS Excel 1900 Leap Year [new DateTime('1900-03-01'), 61.0], // MS Excel 1900 Leap Year
[new DateTime('1901-12-14'), 714.0], // Unix Timestamp 32-bit Earliest Date [new DateTime('1901-12-14'), 714.0], // Unix Timestamp 32-bit Earliest Date
[new DateTime('1903-12-31'), 1461.0], [new DateTime('1903-12-31'), 1461.0],
[new DateTime('1904-01-01'), 1462.0], // Excel 1904 Calendar Base Date [new DateTime('1904-01-01'), 1462.0], // Excel 1904 Calendar Base Date
[new DateTime('1904-01-02'), 1463.0], [new DateTime('1904-01-02'), 1463.0],
[new DateTime('1960-12-19'), 22269.0], [new DateTime('1960-12-19'), 22269.0],
[new DateTime('1970-01-01'), 25569.0], // Unix Timestamp Base Date [new DateTime('1970-01-01'), 25569.0], // Unix Timestamp Base Date
[new DateTime('1982-12-07'), 30292.0], [new DateTime('1982-12-07'), 30292.0],
[new DateTime('2008-06-12'), 39611.0], [new DateTime('2008-06-12'), 39611.0],
[new DateTime('2038-01-19'), 50424.0], // Unix Timestamp 32-bit Latest Date [new DateTime('2038-01-19'), 50424.0], // Unix Timestamp 32-bit Latest Date
[new DateTime('1903-05-18 13:37:46'), 1234.56789], [new DateTime('1903-05-18 13:37:46'), 1234.56789],
[new DateTime('1933-10-18 16:17:37'), 12345.6789], [new DateTime('1933-10-18 16:17:37'), 12345.6789],
[new DateTime('2099-12-31'), 73050.0], [new DateTime('2099-12-31'), 73050.0],
]; ];

View File

@ -2,18 +2,18 @@
// Excel DateTimeStamp Result Comments // Excel DateTimeStamp Result Comments
return [ return [
[714, -2147472000], // PHP 32-bit Earliest Date 14-Dec-1901 [714, -2147472000], // PHP 32-bit Earliest Date 14-Dec-1901
[1461, -2082931200], // 31-Dec-1903 [1461, -2082931200], // 31-Dec-1903
[1462, -2082844800], // Excel 1904 Calendar Base Date 01-Jan-1904 [1462, -2082844800], // Excel 1904 Calendar Base Date 01-Jan-1904
[1463, -2082758400], // 02-Jan-1904 [1463, -2082758400], // 02-Jan-1904
[22269, -285120000], // 19-Dec-1960 [22269, -285120000], // 19-Dec-1960
[25569, 0], // PHP Base Date 01-Jan-1970 [25569, 0], // PHP Base Date 01-Jan-1970
[30292, 408067200], // 07-Dec-1982 [30292, 408067200], // 07-Dec-1982
[39611, 1213228800], // 12-Jun-2008 [39611, 1213228800], // 12-Jun-2008
[50424, 2147472000], // PHP 32-bit Latest Date 19-Jan-2038 [50424, 2147472000], // PHP 32-bit Latest Date 19-Jan-2038
[1234.56789, -2102494934], // 18-May-1903 13:37:46 [1234.56789, -2102494934], // 18-May-1903 13:37:46
[12345.6789, -1142494943], // 18-Oct-1933 16:17:37 [12345.6789, -1142494943], // 18-Oct-1933 16:17:37
[0.5, 43200], // 12:00:00 [0.5, 43200], // 12:00:00
[0.75, 64800], // 18:00.00 [0.75, 64800], // 18:00.00
[0.12345, 10666], // 02:57:46 [0.12345, 10666], // 02:57:46
]; ];

View File

@ -2,26 +2,26 @@
// Excel DateTimeStamp Timezone Result Comments // Excel DateTimeStamp Timezone Result Comments
return [ return [
[22269, 'America/New_York', -285102000], // 19-Dec-1960 00:00:00 EST => 19-Dec-1960 05:00:00 UTC [22269, 'America/New_York', -285102000], // 19-Dec-1960 00:00:00 EST => 19-Dec-1960 05:00:00 UTC
[25569, 'America/New_York', 18000], // 01-Jan-1970 00:00:00 EST => 01-Jan-1970 05:00:00 UTC PHP Base Date [25569, 'America/New_York', 18000], // 01-Jan-1970 00:00:00 EST => 01-Jan-1970 05:00:00 UTC PHP Base Date
[30292, 'America/New_York', 408085200], // 07-Dec-1982 00:00:00 EST => 07-Dec-1982 05:00:00 UTC [30292, 'America/New_York', 408085200], // 07-Dec-1982 00:00:00 EST => 07-Dec-1982 05:00:00 UTC
[39611, 'America/New_York', 1213243200], // 12-Jun-2008 00:00:00 EDT => 12-Jun-2008 04:00:00 UTC [39611, 'America/New_York', 1213243200], // 12-Jun-2008 00:00:00 EDT => 12-Jun-2008 04:00:00 UTC
[50424, 'America/New_York', 2147490000], // 19-Jan-2038 00:00:00 EST => 19-Jan-2038 05:00:00 UTC PHP 32-bit Latest Date [50424, 'America/New_York', 2147490000], // 19-Jan-2038 00:00:00 EST => 19-Jan-2038 05:00:00 UTC PHP 32-bit Latest Date
[22345.56789, 'America/New_York', -278486534], // 05-Mar-1961 13:37:46 EST => 05-Mar-1961 18:37:46 UTC [22345.56789, 'America/New_York', -278486534], // 05-Mar-1961 13:37:46 EST => 05-Mar-1961 18:37:46 UTC
[22345.6789, 'America/New_York', -278476943], // 05-Mar-1961 16:17:37 EST => 05-Mar-1961 21:17:37 UTC [22345.6789, 'America/New_York', -278476943], // 05-Mar-1961 16:17:37 EST => 05-Mar-1961 21:17:37 UTC
[0.5, 'America/New_York', 61200], // 12:00:00 EST => 17:00:00 UTC [0.5, 'America/New_York', 61200], // 12:00:00 EST => 17:00:00 UTC
[0.75, 'America/New_York', 82800], // 18:00.00 EST => 23:00:00 UTC [0.75, 'America/New_York', 82800], // 18:00.00 EST => 23:00:00 UTC
[0.12345, 'America/New_York', 28666], // 02:57:46 EST => 07:57:46 UTC [0.12345, 'America/New_York', 28666], // 02:57:46 EST => 07:57:46 UTC
[41215, 'America/New_York', 1351828800], // 02-Nov-2012 00:00:00 EDT => 02-Nov-2012 04:00:00 UTC [41215, 'America/New_York', 1351828800], // 02-Nov-2012 00:00:00 EDT => 02-Nov-2012 04:00:00 UTC
[22269, 'Pacific/Auckland', -285163200], // 19-Dec-1960 00:00:00 NZST => 18-Dec-1960 12:00:00 UTC [22269, 'Pacific/Auckland', -285163200], // 19-Dec-1960 00:00:00 NZST => 18-Dec-1960 12:00:00 UTC
[25569, 'Pacific/Auckland', -43200], // 01-Jan-1970 00:00:00 NZST => 31-Dec-1969 12:00:00 UTC PHP Base Date [25569, 'Pacific/Auckland', -43200], // 01-Jan-1970 00:00:00 NZST => 31-Dec-1969 12:00:00 UTC PHP Base Date
[30292, 'Pacific/Auckland', 408020400], // 07-Dec-1982 00:00:00 NZDT => 06-Dec-1982 11:00:00 UTC [30292, 'Pacific/Auckland', 408020400], // 07-Dec-1982 00:00:00 NZDT => 06-Dec-1982 11:00:00 UTC
[39611, 'Pacific/Auckland', 1213185600], // 12-Jun-2008 00:00:00 NZST => 11-Jun-2008 12:00:00 UTC [39611, 'Pacific/Auckland', 1213185600], // 12-Jun-2008 00:00:00 NZST => 11-Jun-2008 12:00:00 UTC
[50423.5, 'Pacific/Auckland', 2147382000], // 18-Jan-2038 12:00:00 NZDT => 17-Jan-2038 23:00:00 UTC PHP 32-bit Latest Date [50423.5, 'Pacific/Auckland', 2147382000], // 18-Jan-2038 12:00:00 NZDT => 17-Jan-2038 23:00:00 UTC PHP 32-bit Latest Date
[22345.56789, 'Pacific/Auckland', -278547734], // 05-Mar-1961 13:37:46 NZST => 05-Mar-1961 01:37:46 UTC [22345.56789, 'Pacific/Auckland', -278547734], // 05-Mar-1961 13:37:46 NZST => 05-Mar-1961 01:37:46 UTC
[22345.6789, 'Pacific/Auckland', -278538143], // 05-Mar-1961 16:17:37 NZST => 05-Mar-1961 04:17:37 UTC [22345.6789, 'Pacific/Auckland', -278538143], // 05-Mar-1961 16:17:37 NZST => 05-Mar-1961 04:17:37 UTC
[0.5, 'Pacific/Auckland', 0], // 12:00:00 NZST => 00:00:00 UTC [0.5, 'Pacific/Auckland', 0], // 12:00:00 NZST => 00:00:00 UTC
[0.75, 'Pacific/Auckland', 21600], // 18:00.00 NZST => 06:00:00 UTC [0.75, 'Pacific/Auckland', 21600], // 18:00.00 NZST => 06:00:00 UTC
[0.12345, 'Pacific/Auckland', -32534], // 02:57:46 NZST => 14:57:46 UTC [0.12345, 'Pacific/Auckland', -32534], // 02:57:46 NZST => 14:57:46 UTC
[41215, 'Pacific/Auckland', 1351767600], // 02-Nov-2012 00:00:00 NZDT => 01-Nov-2012 11:00:00 UTC [41215, 'Pacific/Auckland', 1351767600], // 02-Nov-2012 00:00:00 NZDT => 01-Nov-2012 11:00:00 UTC
]; ];

View File

@ -2,13 +2,13 @@
// Excel DateTimeStamp Result Comments // Excel DateTimeStamp Result Comments
return [ return [
[1462, -1956528000], [1462, -1956528000],
[1463, -1956441600], [1463, -1956441600],
[22269, -158803200], [22269, -158803200],
[25569, 126316800], [25569, 126316800],
[30292, 534384000], [30292, 534384000],
[39611, 1339545600], [39611, 1339545600],
[0.25, 21600], // 06:00:00 [0.25, 21600], // 06:00:00
[0.3333333333333333333, 28800], // 08:00.00 [0.3333333333333333333, 28800], // 08:00.00
[0.54321, 46933], // 02:57:46 [0.54321, 46933], // 02:57:46
]; ];

View File

@ -2,40 +2,40 @@
// Excel Format Code Result // Excel Format Code Result
return [ return [
['General', false], ['General', false],
['@', false], ['@', false],
['0', false], ['0', false],
['0.00', false], ['0.00', false],
['#,##0.00', false], ['#,##0.00', false],
['#,##0.00_-', false], ['#,##0.00_-', false],
['0%', false], ['0%', false],
['0.00%', false], ['0.00%', false],
['yyyy-mm-dd', true], ['yyyy-mm-dd', true],
['yy-mm-dd', true], ['yy-mm-dd', true],
['dd/mm/yy', true], ['dd/mm/yy', true],
['d/m/y', true], ['d/m/y', true],
['d-m-y', true], ['d-m-y', true],
['d-m', true], ['d-m', true],
['m-y', true], ['m-y', true],
['mm-dd-yy', true], ['mm-dd-yy', true],
['d-mmm-yy', true], ['d-mmm-yy', true],
['d-mmm', true], ['d-mmm', true],
['mmm-yy', true], ['mmm-yy', true],
['m/d/yy h:mm', true], ['m/d/yy h:mm', true],
['d/m/y h:mm', true], ['d/m/y h:mm', true],
['h:mm AM/PM', true], ['h:mm AM/PM', true],
['h:mm:ss AM/PM', true], ['h:mm:ss AM/PM', true],
['h:mm', true], ['h:mm', true],
['h:mm:ss', true], ['h:mm:ss', true],
['mm:ss', true], ['mm:ss', true],
['h:mm:ss', true], ['h:mm:ss', true],
['i:s.S', true], ['i:s.S', true],
['h:mm:ss;@', true], ['h:mm:ss;@', true],
['yy/mm/dd;@', true], ['yy/mm/dd;@', true],
['"$" #,##0.00_-', false], ['"$" #,##0.00_-', false],
['$#,##0_-', false], ['$#,##0_-', false],
['[$EUR ]#,##0.00_-', false], ['[$EUR ]#,##0.00_-', false],
['_[$EUR ]#,##0.00_-', false], ['_[$EUR ]#,##0.00_-', false],
['[Green]#,##0.00;[Red]#,##0.00_-', false], ['[Green]#,##0.00;[Red]#,##0.00_-', false],
['#,##0.00 "dollars"', false], ['#,##0.00 "dollars"', false],
]; ];

View File

@ -2,15 +2,15 @@
// Year Month Day Hours Minutes Seconds Result Comments // Year Month Day Hours Minutes Seconds Result Comments
return [ return [
[1901, 12, 14, 714], // PHP 32-bit Earliest Date 14-Dec-1901 [1901, 12, 14, 714], // PHP 32-bit Earliest Date 14-Dec-1901
[1903, 12, 31, 1461], // 31-Dec-1903 [1903, 12, 31, 1461], // 31-Dec-1903
[1904, 1, 1, 1462], // Excel 1904 Calendar Base Date 01-Jan-1904 [1904, 1, 1, 1462], // Excel 1904 Calendar Base Date 01-Jan-1904
[1904, 1, 2, 1463], // 02-Jan-1904 [1904, 1, 2, 1463], // 02-Jan-1904
[1960, 12, 19, 22269], // 19-Dec-1960 [1960, 12, 19, 22269], // 19-Dec-1960
[1970, 1, 1, 25569], // PHP Base Date 01-Jan-1970 [1970, 1, 1, 25569], // PHP Base Date 01-Jan-1970
[1982, 12, 7, 30292], // 07-Dec-1982 [1982, 12, 7, 30292], // 07-Dec-1982
[2008, 6, 12, 39611], // 12-Jun-2008 [2008, 6, 12, 39611], // 12-Jun-2008
[2038, 1, 19, 50424], // PHP 32-bit Latest Date 19-Jan-2038 [2038, 1, 19, 50424], // PHP 32-bit Latest Date 19-Jan-2038
[1903, 5, 18, 13, 37, 46, 1234.56789], // 18-May-1903 13:37:46 [1903, 5, 18, 13, 37, 46, 1234.56789], // 18-May-1903 13:37:46
[1933, 10, 18, 16, 17, 37, 12345.6789], // 18-Oct-1933 16:17:37 [1933, 10, 18, 16, 17, 37, 12345.6789], // 18-Oct-1933 16:17:37
]; ];

View File

@ -2,15 +2,15 @@
// Unix TimeStamp Result Comments // Unix TimeStamp Result Comments
return [ return [
[-2147472000, 714], // PHP 32-bit Earliest Date 14-Dec-1901 [-2147472000, 714], // PHP 32-bit Earliest Date 14-Dec-1901
[-2082931200, 1461], // 31-Dec-1903 [-2082931200, 1461], // 31-Dec-1903
[-2082844800, 1462], // Excel 1904 Calendar Base Date 01-Jan-1904 [-2082844800, 1462], // Excel 1904 Calendar Base Date 01-Jan-1904
[-2082758400, 1463], // 02-Jan-1904 [-2082758400, 1463], // 02-Jan-1904
[-285120000, 22269], // 19-Dec-1960 [-285120000, 22269], // 19-Dec-1960
[0, 25569], // PHP Base Date 01-Jan-1970 [0, 25569], // PHP Base Date 01-Jan-1970
[408067200, 30292], // 07-Dec-1982 [408067200, 30292], // 07-Dec-1982
[1213228800, 39611], // 12-Jun-2008 [1213228800, 39611], // 12-Jun-2008
[2147472000, 50424], // PHP 32-bit Latest Date 19-Jan-2038 [2147472000, 50424], // PHP 32-bit Latest Date 19-Jan-2038
[-2102494934, 1234.56789], // 18-May-1903 13:37:46 [-2102494934, 1234.56789], // 18-May-1903 13:37:46
[-1142494943, 12345.6789], // 18-Oct-1933 16:17:37 [-1142494943, 12345.6789], // 18-Oct-1933 16:17:37
]; ];

View File

@ -2,10 +2,10 @@
// Excel DateTimeStamp Result // Excel DateTimeStamp Result
return [ return [
[-1956528000, 1462], [-1956528000, 1462],
[-1956441600, 1463], [-1956441600, 1463],
[-158803200, 22269], [-158803200, 22269],
[126316800, 25569], [126316800, 25569],
[534384000, 30292], [534384000, 30292],
[1339545600, 39611], [1339545600, 39611],
]; ];