Minor changes, mainly cosmetic

This commit is contained in:
MarkBaker 2022-08-24 08:33:57 +02:00
parent cc17d2fef9
commit 99c6fed1e0
18 changed files with 560 additions and 564 deletions

1014
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,8 @@ $worksheet = $spreadsheet->getActiveSheet();
$data = [ $data = [
['ID', 'First Name', 'Last Name', 'Salary'], ['ID', 'First Name', 'Last Name', 'Salary'],
[72, 'Emily', 'Smith', 64901, null, 'ID', 53, 66, 56], [72, 'Emily', 'Smith', 64901],
[66, 'James', 'Anderson', 70855, null, 'Salary'], [66, 'James', 'Anderson', 70855],
[14, 'Mia', 'Clark', 188657], [14, 'Mia', 'Clark', 188657],
[30, 'John', 'Lewis', 97566], [30, 'John', 'Lewis', 97566],
[53, 'Jessica', 'Walker', 58339], [53, 'Jessica', 'Walker', 58339],
@ -25,11 +25,24 @@ $data = [
$worksheet->fromArray($data, null, 'B2'); $worksheet->fromArray($data, null, 'B2');
$worksheet->getCell('H4')->setValue('=VLOOKUP(H3, B3:E9, 4, FALSE)'); $lookupFields = [
$worksheet->getCell('I4')->setValue('=VLOOKUP(I3, B3:E9, 4, FALSE)'); ['ID', 53, 66, 56],
$worksheet->getCell('J4')->setValue('=VLOOKUP(J3, B3:E9, 4, FALSE)'); ['Name'],
['Salary'],
];
$worksheet->fromArray($lookupFields, null, 'G3');
$worksheet->getCell('H4')->setValue('=VLOOKUP(H3, B3:E9, 2, FALSE) & " " & VLOOKUP(H3, B3:E9, 3, FALSE)');
$worksheet->getCell('I4')->setValue('=VLOOKUP(I3, B3:E9, 2, FALSE) & " " & VLOOKUP(I3, B3:E9, 3, FALSE)');
$worksheet->getCell('J4')->setValue('=VLOOKUP(J3, B3:E9, 2, FALSE) & " " & VLOOKUP(J3, B3:E9, 3, FALSE)');
$worksheet->getCell('H5')->setValue('=VLOOKUP(H3, B3:E9, 4, FALSE)');
$worksheet->getCell('I5')->setValue('=VLOOKUP(I3, B3:E9, 4, FALSE)');
$worksheet->getCell('J5')->setValue('=VLOOKUP(J3, B3:E9, 4, FALSE)');
for ($column = 'H'; $column !== 'K'; ++$column) { for ($column = 'H'; $column !== 'K'; ++$column) {
$cell = $worksheet->getCell("{$column}4"); for ($row = 4; $row <= 5; ++$row) {
$helper->log("{$column}4: {$cell->getValue()} => {$cell->getCalculatedValue()}"); $cell = $worksheet->getCell("{$column}{$row}");
$helper->log("{$column}{$row}: {$cell->getValue()} => {$cell->getCalculatedValue()}");
}
} }

View File

@ -4756,9 +4756,8 @@ class Calculation
break; break;
} }
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
} elseif (($token === '~') || ($token === '%')) { } elseif (($token === '~') || ($token === '%')) {
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
if (($arg = $stack->pop()) === null) { if (($arg = $stack->pop()) === null) {
return $this->raiseFormulaError('Internal error - Operand value missing from stack'); return $this->raiseFormulaError('Internal error - Operand value missing from stack');
} }
@ -4865,9 +4864,8 @@ class Calculation
if (isset($storeKey)) { if (isset($storeKey)) {
$branchStore[$storeKey] = $cellValue; $branchStore[$storeKey] = $cellValue;
} }
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $token ?? '', $matches)) { } elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $token ?? '', $matches)) {
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
if ($pCellParent) { if ($pCellParent) {
$cell->attach($pCellParent); $cell->attach($pCellParent);
} }
@ -4977,8 +4975,8 @@ class Calculation
if (isset($storeKey)) { if (isset($storeKey)) {
$branchStore[$storeKey] = $token; $branchStore[$storeKey] = $token;
} }
// if the token is a named range or formula, evaluate it and push the result onto the stack
} elseif (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '$/miu', $token, $matches)) { } elseif (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '$/miu', $token, $matches)) {
// if the token is a named range or formula, evaluate it and push the result onto the stack
$definedName = $matches[6]; $definedName = $matches[6];
if ($cell === null || $pCellWorksheet === null) { if ($cell === null || $pCellWorksheet === null) {
return $this->raiseFormulaError("undefined name '$token'"); return $this->raiseFormulaError("undefined name '$token'");

View File

@ -17,7 +17,7 @@ class Random
*/ */
public static function rand() public static function rand()
{ {
return (mt_rand(0, 10000000)) / 10000000; return mt_rand(0, 10000000) / 10000000;
} }
/** /**

View File

@ -203,7 +203,7 @@ class Averages extends AggregateBase
$args, $args,
function ($value) { function ($value) {
// Is it a numeric value? // Is it a numeric value?
return (is_numeric($value)) && (!is_string($value)); return is_numeric($value) && (!is_string($value));
} }
); );
} }

View File

@ -101,7 +101,7 @@ class ChiSquared
return 1 - self::distributionRightTail($value, $degrees); return 1 - self::distributionRightTail($value, $degrees);
} }
return (($value ** (($degrees / 2) - 1) * exp(-$value / 2))) / return ($value ** (($degrees / 2) - 1) * exp(-$value / 2)) /
((2 ** ($degrees / 2)) * Gamma::gammaValue($degrees / 2)); ((2 ** ($degrees / 2)) * Gamma::gammaValue($degrees / 2));
} }

View File

@ -1695,8 +1695,8 @@ class Xlsx extends BaseReader
break; break;
// unparsed
case 'application/vnd.ms-excel.controlproperties+xml': case 'application/vnd.ms-excel.controlproperties+xml':
// unparsed
$unparsedLoadedData['override_content_types'][(string) $contentType['PartName']] = (string) $contentType['ContentType']; $unparsedLoadedData['override_content_types'][(string) $contentType['PartName']] = (string) $contentType['ContentType'];
break; break;
@ -1722,7 +1722,6 @@ class Xlsx extends BaseReader
$value->createText(StringHelper::controlCharacterOOXML2PHP((string) $is->t)); $value->createText(StringHelper::controlCharacterOOXML2PHP((string) $is->t));
} else { } else {
if (is_object($is->r)) { if (is_object($is->r)) {
/** @var SimpleXMLElement $run */ /** @var SimpleXMLElement $run */
foreach ($is->r as $run) { foreach ($is->r as $run) {
if (!isset($run->rPr)) { if (!isset($run->rPr)) {