Merge pull request #3025 from PHPOffice/Minor-Tweaks

Minor changes, mainly cosmetic
This commit is contained in:
Mark Baker 2022-08-24 16:30:40 +02:00 committed by GitHub
commit f039a24bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 = [
['ID', 'First Name', 'Last Name', 'Salary'],
[72, 'Emily', 'Smith', 64901, null, 'ID', 53, 66, 56],
[66, 'James', 'Anderson', 70855, null, 'Salary'],
[72, 'Emily', 'Smith', 64901],
[66, 'James', 'Anderson', 70855],
[14, 'Mia', 'Clark', 188657],
[30, 'John', 'Lewis', 97566],
[53, 'Jessica', 'Walker', 58339],
@ -25,11 +25,24 @@ $data = [
$worksheet->fromArray($data, null, 'B2');
$worksheet->getCell('H4')->setValue('=VLOOKUP(H3, B3:E9, 4, FALSE)');
$worksheet->getCell('I4')->setValue('=VLOOKUP(I3, B3:E9, 4, FALSE)');
$worksheet->getCell('J4')->setValue('=VLOOKUP(J3, B3:E9, 4, FALSE)');
$lookupFields = [
['ID', 53, 66, 56],
['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) {
$cell = $worksheet->getCell("{$column}4");
$helper->log("{$column}4: {$cell->getValue()} => {$cell->getCalculatedValue()}");
for ($row = 4; $row <= 5; ++$row) {
$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);
$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->setAxisNumberProperties(Properties::FORMAT_CODE_DATE );
$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);
$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->setAxisNumberProperties(Properties::FORMAT_CODE_DATE );
$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true);

View File

@ -121,7 +121,7 @@ $dataSeriesValues[2] // triangle border
->getMarkerBorderColor()
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
$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->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true);

View File

@ -4756,9 +4756,8 @@ class Calculation
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 === '%')) {
// 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) {
return $this->raiseFormulaError('Internal error - Operand value missing from stack');
}
@ -4865,9 +4864,8 @@ class Calculation
if (isset($storeKey)) {
$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)) {
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
if ($pCellParent) {
$cell->attach($pCellParent);
}
@ -4977,8 +4975,8 @@ class Calculation
if (isset($storeKey)) {
$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)) {
// if the token is a named range or formula, evaluate it and push the result onto the stack
$definedName = $matches[6];
if ($cell === null || $pCellWorksheet === null) {
return $this->raiseFormulaError("undefined name '$token'");

View File

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

View File

@ -17,7 +17,7 @@ class Random
*/
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,
function ($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 (($value ** (($degrees / 2) - 1) * exp(-$value / 2))) /
return ($value ** (($degrees / 2) - 1) * exp(-$value / 2)) /
((2 ** ($degrees / 2)) * Gamma::gammaValue($degrees / 2));
}

View File

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

View File

@ -6999,7 +6999,7 @@ class Xls extends BaseReader
}
break;
// Unknown cases // don't know how to deal with
// Unknown cases // don't know how to deal with
default:
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));
break;
//Ribbon
// Ribbon
case Namespaces::EXTENSIBILITY:
$customUI = $relTarget;
if ($customUI) {
@ -530,7 +530,7 @@ class Xlsx extends BaseReader
}
break;
// a vbaProject ? (: some macros)
// a vbaProject ? (: some macros)
case Namespaces::VBA:
$macros = $ele['Target'];
@ -1695,8 +1695,8 @@ class Xlsx extends BaseReader
break;
// unparsed
case 'application/vnd.ms-excel.controlproperties+xml':
// unparsed
$unparsedLoadedData['override_content_types'][(string) $contentType['PartName']] = (string) $contentType['ContentType'];
break;
@ -1722,7 +1722,6 @@ class Xlsx extends BaseReader
$value->createText(StringHelper::controlCharacterOOXML2PHP((string) $is->t));
} else {
if (is_object($is->r)) {
/** @var SimpleXMLElement $run */
foreach ($is->r as $run) {
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] = $q * $this->V[$i][$n] - $p * $z;
}
// Complex pair
// Complex pair
} else {
$this->d[$n - 1] = $x + $p;
$this->d[$n] = $x + $p;
@ -671,7 +671,7 @@ class EigenvalueDecomposition
} else {
$this->H[$i][$n] = -$r / ($eps * $norm);
}
// Solve real equations
// Solve real equations
} else {
$x = $this->H[$i][$i + 1];
$y = $this->H[$i + 1][$i];
@ -693,7 +693,7 @@ class EigenvalueDecomposition
}
}
}
// Complex vector
// Complex vector
} elseif ($q < 0) {
$l = $n - 1;
// Last vector component imaginary so matrix is triangular

View File

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

View File

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

View File

@ -531,7 +531,7 @@ class Parser
{
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') {
return '';
}

View File

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