提交的内容
This commit is contained in:
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AddressHelper.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AddressHelper.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AddressRange.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AddressRange.php
vendored
Executable file → Normal file
7
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php
vendored
Executable file → Normal file
7
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php
vendored
Executable file → Normal file
@ -51,8 +51,9 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
||||
return $this->setImproperFraction($matches, $cell);
|
||||
}
|
||||
|
||||
$decimalSeparator = preg_quote(StringHelper::getDecimalSeparator());
|
||||
$thousandsSeparator = preg_quote(StringHelper::getThousandsSeparator());
|
||||
$decimalSeparatorNoPreg = StringHelper::getDecimalSeparator();
|
||||
$decimalSeparator = preg_quote($decimalSeparatorNoPreg, '/');
|
||||
$thousandsSeparator = preg_quote(StringHelper::getThousandsSeparator(), '/');
|
||||
|
||||
// Check for percentage
|
||||
if (preg_match('/^\-?\d*' . $decimalSeparator . '?\d*\s?\%$/', preg_replace('/(\d)' . $thousandsSeparator . '(\d)/u', '$1$2', $value))) {
|
||||
@ -64,7 +65,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
||||
// Convert value to number
|
||||
$sign = ($matches['PrefixedSign'] ?? $matches['PrefixedSign2'] ?? $matches['PostfixedSign']) ?? null;
|
||||
$currencyCode = $matches['PrefixedCurrency'] ?? $matches['PostfixedCurrency'];
|
||||
$value = (float) ($sign . trim(str_replace([$decimalSeparator, $currencyCode, ' ', '-'], ['.', '', '', ''], preg_replace('/(\d)' . $thousandsSeparator . '(\d)/u', '$1$2', $value)))); // @phpstan-ignore-line
|
||||
$value = (float) ($sign . trim(str_replace([$decimalSeparatorNoPreg, $currencyCode, ' ', '-'], ['.', '', '', ''], preg_replace('/(\d)' . $thousandsSeparator . '(\d)/u', '$1$2', $value)))); // @phpstan-ignore-line
|
||||
|
||||
return $this->setCurrency($value, $cell, $currencyCode); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
13
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php
vendored
Executable file → Normal file
13
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Cell.php
vendored
Executable file → Normal file
@ -71,6 +71,9 @@ class Cell
|
||||
*/
|
||||
private $formulaAttributes;
|
||||
|
||||
/** @var IgnoredErrors */
|
||||
private $ignoredErrors;
|
||||
|
||||
/**
|
||||
* Update the cell into the cell collection.
|
||||
*
|
||||
@ -119,6 +122,7 @@ class Cell
|
||||
} elseif (self::getValueBinder()->bindValue($this, $value) === false) {
|
||||
throw new Exception('Value could not be bound to cell.');
|
||||
}
|
||||
$this->ignoredErrors = new IgnoredErrors();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -391,7 +395,9 @@ class Cell
|
||||
}
|
||||
|
||||
throw new \PhpOffice\PhpSpreadsheet\Calculation\Exception(
|
||||
$this->getWorksheet()->getTitle() . '!' . $this->getCoordinate() . ' -> ' . $ex->getMessage()
|
||||
$this->getWorksheet()->getTitle() . '!' . $this->getCoordinate() . ' -> ' . $ex->getMessage(),
|
||||
$ex->getCode(),
|
||||
$ex
|
||||
);
|
||||
}
|
||||
|
||||
@ -794,4 +800,9 @@ class Cell
|
||||
{
|
||||
return (string) $this->getValue();
|
||||
}
|
||||
|
||||
public function getIgnoredErrors(): IgnoredErrors
|
||||
{
|
||||
return $this->ignoredErrors;
|
||||
}
|
||||
}
|
||||
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/CellAddress.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/CellAddress.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/CellRange.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/CellRange.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/ColumnRange.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/ColumnRange.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Coordinate.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataType.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataType.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidation.php
vendored
Executable file → Normal file
54
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidator.php
vendored
Executable file → Normal file
54
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DataValidator.php
vendored
Executable file → Normal file
@ -20,7 +20,7 @@ class DataValidator
|
||||
*/
|
||||
public function isValid(Cell $cell)
|
||||
{
|
||||
if (!$cell->hasDataValidation()) {
|
||||
if (!$cell->hasDataValidation() || $cell->getDataValidation()->getType() === DataValidation::TYPE_NONE) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -31,13 +31,55 @@ class DataValidator
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: write check on all cases
|
||||
switch ($dataValidation->getType()) {
|
||||
case DataValidation::TYPE_LIST:
|
||||
return $this->isValueInList($cell);
|
||||
$returnValue = false;
|
||||
$type = $dataValidation->getType();
|
||||
if ($type === DataValidation::TYPE_LIST) {
|
||||
$returnValue = $this->isValueInList($cell);
|
||||
} elseif ($type === DataValidation::TYPE_WHOLE) {
|
||||
if (!is_numeric($cellValue) || fmod((float) $cellValue, 1) != 0) {
|
||||
$returnValue = false;
|
||||
} else {
|
||||
$returnValue = $this->numericOperator($dataValidation, (int) $cellValue);
|
||||
}
|
||||
} elseif ($type === DataValidation::TYPE_DECIMAL || $type === DataValidation::TYPE_DATE || $type === DataValidation::TYPE_TIME) {
|
||||
if (!is_numeric($cellValue)) {
|
||||
$returnValue = false;
|
||||
} else {
|
||||
$returnValue = $this->numericOperator($dataValidation, (float) $cellValue);
|
||||
}
|
||||
} elseif ($type === DataValidation::TYPE_TEXTLENGTH) {
|
||||
$returnValue = $this->numericOperator($dataValidation, mb_strlen((string) $cellValue));
|
||||
}
|
||||
|
||||
return false;
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/** @param float|int $cellValue */
|
||||
private function numericOperator(DataValidation $dataValidation, $cellValue): bool
|
||||
{
|
||||
$operator = $dataValidation->getOperator();
|
||||
$formula1 = $dataValidation->getFormula1();
|
||||
$formula2 = $dataValidation->getFormula2();
|
||||
$returnValue = false;
|
||||
if ($operator === DataValidation::OPERATOR_BETWEEN) {
|
||||
$returnValue = $cellValue >= $formula1 && $cellValue <= $formula2;
|
||||
} elseif ($operator === DataValidation::OPERATOR_NOTBETWEEN) {
|
||||
$returnValue = $cellValue < $formula1 || $cellValue > $formula2;
|
||||
} elseif ($operator === DataValidation::OPERATOR_EQUAL) {
|
||||
$returnValue = $cellValue == $formula1;
|
||||
} elseif ($operator === DataValidation::OPERATOR_NOTEQUAL) {
|
||||
$returnValue = $cellValue != $formula1;
|
||||
} elseif ($operator === DataValidation::OPERATOR_LESSTHAN) {
|
||||
$returnValue = $cellValue < $formula1;
|
||||
} elseif ($operator === DataValidation::OPERATOR_LESSTHANOREQUAL) {
|
||||
$returnValue = $cellValue <= $formula1;
|
||||
} elseif ($operator === DataValidation::OPERATOR_GREATERTHAN) {
|
||||
$returnValue = $cellValue > $formula1;
|
||||
} elseif ($operator === DataValidation::OPERATOR_GREATERTHANOREQUAL) {
|
||||
$returnValue = $cellValue >= $formula1;
|
||||
}
|
||||
|
||||
return $returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/DefaultValueBinder.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Hyperlink.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/Hyperlink.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IValueBinder.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IValueBinder.php
vendored
Executable file → Normal file
66
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IgnoredErrors.php
vendored
Normal file
66
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/IgnoredErrors.php
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Cell;
|
||||
|
||||
class IgnoredErrors
|
||||
{
|
||||
/** @var bool */
|
||||
private $numberStoredAsText = false;
|
||||
|
||||
/** @var bool */
|
||||
private $formula = false;
|
||||
|
||||
/** @var bool */
|
||||
private $twoDigitTextYear = false;
|
||||
|
||||
/** @var bool */
|
||||
private $evalError = false;
|
||||
|
||||
public function setNumberStoredAsText(bool $value): self
|
||||
{
|
||||
$this->numberStoredAsText = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNumberStoredAsText(): bool
|
||||
{
|
||||
return $this->numberStoredAsText;
|
||||
}
|
||||
|
||||
public function setFormula(bool $value): self
|
||||
{
|
||||
$this->formula = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFormula(): bool
|
||||
{
|
||||
return $this->formula;
|
||||
}
|
||||
|
||||
public function setTwoDigitTextYear(bool $value): self
|
||||
{
|
||||
$this->twoDigitTextYear = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTwoDigitTextYear(): bool
|
||||
{
|
||||
return $this->twoDigitTextYear;
|
||||
}
|
||||
|
||||
public function setEvalError(bool $value): self
|
||||
{
|
||||
$this->evalError = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEvalError(): bool
|
||||
{
|
||||
return $this->evalError;
|
||||
}
|
||||
}
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/RowRange.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/RowRange.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Cell/StringValueBinder.php
vendored
Executable file → Normal file
Reference in New Issue
Block a user