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

@ -120,7 +120,7 @@ $dataSeriesValues[2] // triangle border
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME); ->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
$dataSeriesValues[2]->setScatterLines(false); // points not connected $dataSeriesValues[2]->setScatterLines(false); // points not connected
// Added so that Xaxis shows dates instead of Excel-equivalent-year1900-numbers // Added so that Xaxis shows dates instead of Excel-equivalent-year1900-numbers
$xAxis = new Axis(); $xAxis = new Axis();
//$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE ); //$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE );
$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true); $xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true);

View File

@ -120,7 +120,7 @@ $dataSeriesValues[2] // triangle border
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME); ->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
$dataSeriesValues[2]->setScatterLines(false); // points not connected $dataSeriesValues[2]->setScatterLines(false); // points not connected
// Added so that Xaxis shows dates instead of Excel-equivalent-year1900-numbers // Added so that Xaxis shows dates instead of Excel-equivalent-year1900-numbers
$xAxis = new Axis(); $xAxis = new Axis();
//$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE ); //$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE );
$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true); $xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true);

View File

@ -121,7 +121,7 @@ $dataSeriesValues[2] // triangle border
->getMarkerBorderColor() ->getMarkerBorderColor()
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME); ->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
$dataSeriesValues[2]->setScatterLines(false); // points not connected $dataSeriesValues[2]->setScatterLines(false); // points not connected
// Added so that Xaxis shows dates instead of Excel-equivalent-year1900-numbers // Added so that Xaxis shows dates instead of Excel-equivalent-year1900-numbers
$xAxis = new Axis(); $xAxis = new Axis();
$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true); $xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true);

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

@ -98,9 +98,9 @@ class Logger
$cellReference = implode(' -> ', $this->cellStack->showStack()); $cellReference = implode(' -> ', $this->cellStack->showStack());
if ($this->echoDebugLog) { if ($this->echoDebugLog) {
echo $cellReference, echo $cellReference,
($this->cellStack->count() > 0 ? ' => ' : ''), ($this->cellStack->count() > 0 ? ' => ' : ''),
$message, $message,
PHP_EOL; PHP_EOL;
} }
$this->debugLog[] = $cellReference . $this->debugLog[] = $cellReference .
($this->cellStack->count() > 0 ? ' => ' : '') . ($this->cellStack->count() > 0 ? ' => ' : '') .

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

@ -729,21 +729,21 @@ abstract class JpGraphRendererBase implements IRenderer
switch ($chartType) { switch ($chartType) {
case 'area3DChart': case 'area3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'areaChart': case 'areaChart':
$this->renderPlotLine($i, true, true, $dimensions); $this->renderPlotLine($i, true, true, $dimensions);
break; break;
case 'bar3DChart': case 'bar3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'barChart': case 'barChart':
$this->renderPlotBar($i, $dimensions); $this->renderPlotBar($i, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'lineChart': case 'lineChart':
$this->renderPlotLine($i, false, true, $dimensions); $this->renderPlotLine($i, false, true, $dimensions);
@ -799,35 +799,35 @@ abstract class JpGraphRendererBase implements IRenderer
switch ($chartType) { switch ($chartType) {
case 'area3DChart': case 'area3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'areaChart': case 'areaChart':
$this->renderAreaChart($groupCount, $dimensions); $this->renderAreaChart($groupCount, $dimensions);
break; break;
case 'bar3DChart': case 'bar3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'barChart': case 'barChart':
$this->renderBarChart($groupCount, $dimensions); $this->renderBarChart($groupCount, $dimensions);
break; break;
case 'line3DChart': case 'line3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'lineChart': case 'lineChart':
$this->renderLineChart($groupCount, $dimensions); $this->renderLineChart($groupCount, $dimensions);
break; break;
case 'pie3DChart': case 'pie3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'pieChart': case 'pieChart':
$this->renderPieChart($groupCount, $dimensions, false, false); $this->renderPieChart($groupCount, $dimensions, false, false);
break; break;
case 'doughnut3DChart': case 'doughnut3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'doughnutChart': case 'doughnutChart':
$this->renderPieChart($groupCount, $dimensions, true, true); $this->renderPieChart($groupCount, $dimensions, true, true);
@ -846,7 +846,7 @@ abstract class JpGraphRendererBase implements IRenderer
break; break;
case 'surface3DChart': case 'surface3DChart':
$dimensions = '3d'; $dimensions = '3d';
// no break // no break
case 'surfaceChart': case 'surfaceChart':
$this->renderContourChart($groupCount, $dimensions); $this->renderContourChart($groupCount, $dimensions);

View File

@ -6999,7 +6999,7 @@ class Xls extends BaseReader
} }
break; break;
// Unknown cases // don't know how to deal with // Unknown cases // don't know how to deal with
default: default:
throw new Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula'); throw new Exception('Unrecognized token ' . sprintf('%02X', $id) . ' in formula');

View File

@ -479,7 +479,7 @@ class Xlsx extends BaseReader
$propertyReader->readCustomProperties($this->getFromZipArchive($zip, $relTarget)); $propertyReader->readCustomProperties($this->getFromZipArchive($zip, $relTarget));
break; break;
//Ribbon // Ribbon
case Namespaces::EXTENSIBILITY: case Namespaces::EXTENSIBILITY:
$customUI = $relTarget; $customUI = $relTarget;
if ($customUI) { if ($customUI) {
@ -530,7 +530,7 @@ class Xlsx extends BaseReader
} }
break; break;
// a vbaProject ? (: some macros) // a vbaProject ? (: some macros)
case Namespaces::VBA: case Namespaces::VBA:
$macros = $ele['Target']; $macros = $ele['Target'];
@ -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)) {

View File

@ -495,7 +495,7 @@ class EigenvalueDecomposition
$this->V[$i][$n - 1] = $q * $z + $p * $this->V[$i][$n]; $this->V[$i][$n - 1] = $q * $z + $p * $this->V[$i][$n];
$this->V[$i][$n] = $q * $this->V[$i][$n] - $p * $z; $this->V[$i][$n] = $q * $this->V[$i][$n] - $p * $z;
} }
// Complex pair // Complex pair
} else { } else {
$this->d[$n - 1] = $x + $p; $this->d[$n - 1] = $x + $p;
$this->d[$n] = $x + $p; $this->d[$n] = $x + $p;
@ -671,7 +671,7 @@ class EigenvalueDecomposition
} else { } else {
$this->H[$i][$n] = -$r / ($eps * $norm); $this->H[$i][$n] = -$r / ($eps * $norm);
} }
// Solve real equations // Solve real equations
} else { } else {
$x = $this->H[$i][$i + 1]; $x = $this->H[$i][$i + 1];
$y = $this->H[$i + 1][$i]; $y = $this->H[$i + 1][$i];
@ -693,7 +693,7 @@ class EigenvalueDecomposition
} }
} }
} }
// Complex vector // Complex vector
} elseif ($q < 0) { } elseif ($q < 0) {
$l = $n - 1; $l = $n - 1;
// Last vector component imaginary so matrix is triangular // Last vector component imaginary so matrix is triangular

View File

@ -67,21 +67,21 @@ class Matrix
$this->A = $args[0]; $this->A = $args[0];
break; break;
//Square matrix - n x n //Square matrix - n x n
case 'integer': case 'integer':
$this->m = $args[0]; $this->m = $args[0];
$this->n = $args[0]; $this->n = $args[0];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
break; break;
//Rectangular matrix - m x n //Rectangular matrix - m x n
case 'integer,integer': case 'integer,integer':
$this->m = $args[0]; $this->m = $args[0];
$this->n = $args[1]; $this->n = $args[1];
$this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0)); $this->A = array_fill(0, $this->m, array_fill(0, $this->n, 0));
break; break;
//Rectangular matrix - m x n initialized from packed array //Rectangular matrix - m x n initialized from packed array
case 'array,integer': case 'array,integer':
$this->m = $args[1]; $this->m = $args[1];
if ($this->m != 0) { if ($this->m != 0) {
@ -191,7 +191,7 @@ class Matrix
return $R; return $R;
break; break;
//A($i0...$iF; $j0...$jF) //A($i0...$iF; $j0...$jF)
case 'integer,integer,integer,integer': case 'integer,integer,integer,integer':
[$i0, $iF, $j0, $jF] = $args; [$i0, $iF, $j0, $jF] = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
@ -214,7 +214,7 @@ class Matrix
return $R; return $R;
break; break;
//$R = array of row indices; $C = array of column indices //$R = array of row indices; $C = array of column indices
case 'array,array': case 'array,array':
[$RL, $CL] = $args; [$RL, $CL] = $args;
if (count($RL) > 0) { if (count($RL) > 0) {
@ -237,7 +237,7 @@ class Matrix
return $R; return $R;
break; break;
//A($i0...$iF); $CL = array of column indices //A($i0...$iF); $CL = array of column indices
case 'integer,integer,array': case 'integer,integer,array':
[$i0, $iF, $CL] = $args; [$i0, $iF, $CL] = $args;
if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) { if (($iF > $i0) && ($this->m >= $iF) && ($i0 >= 0)) {
@ -260,7 +260,7 @@ class Matrix
return $R; return $R;
break; break;
//$RL = array of row indices //$RL = array of row indices
case 'array,integer,integer': case 'array,integer,integer':
[$RL, $j0, $jF] = $args; [$RL, $j0, $jF] = $args;
if (count($RL) > 0) { if (count($RL) > 0) {

View File

@ -315,7 +315,7 @@ class SingularValueDecomposition
} }
break; break;
// Split at negligible s(k). // Split at negligible s(k).
case 2: case 2:
$f = $e[$k - 1]; $f = $e[$k - 1];
$e[$k - 1] = 0.0; $e[$k - 1] = 0.0;
@ -336,7 +336,7 @@ class SingularValueDecomposition
} }
break; break;
// Perform one qr step. // Perform one qr step.
case 3: case 3:
// Calculate the shift. // Calculate the shift.
$scale = max(max(max(max(abs($this->s[$p - 1]), abs($this->s[$p - 2])), abs($e[$p - 2])), abs($this->s[$k])), abs($e[$k])); $scale = max(max(max(max(abs($this->s[$p - 1]), abs($this->s[$p - 2])), abs($e[$p - 2])), abs($this->s[$k])), abs($e[$k]));
@ -396,7 +396,7 @@ class SingularValueDecomposition
$iter = $iter + 1; $iter = $iter + 1;
break; break;
// Convergence. // Convergence.
case 4: case 4:
// Make the singular values positive. // Make the singular values positive.
if ($this->s[$k] <= 0.0) { if ($this->s[$k] <= 0.0) {

View File

@ -531,7 +531,7 @@ class Parser
{ {
return($this->convertFunction($token, $this->_func_args)); return($this->convertFunction($token, $this->_func_args));
}*/ }*/
// if it's an argument, ignore the token (the argument remains) // if it's an argument, ignore the token (the argument remains)
} elseif ($token == 'arg') { } elseif ($token == 'arg') {
return ''; return '';
} }

View File

@ -2836,7 +2836,7 @@ class Worksheet extends BIFFwriter
$operatorType = 0x01; $operatorType = 0x01;
break; break;
// not OPERATOR_NOTBETWEEN 0x02 // not OPERATOR_NOTBETWEEN 0x02
} }
} }