Skip to content

Commit 473f827

Browse files
authored
Merge branch 'master' into brkupxlsr2
2 parents f498f43 + 87ddd21 commit 473f827

38 files changed

+570
-253
lines changed

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com)
66
and this project adheres to [Semantic Versioning](https://semver.org).
77

8-
## TBD - 3.0.0
8+
## 2024-09-29 - 3.0.0
99

1010
### Dynamic Arrays
1111

@@ -20,19 +20,30 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2020

2121
- Xlsx Reader default datatype when none is specified in Xml is changed from string to numeric, which is how Excel treats it. There is expected to be little impact because DefaultValueBinder and AdvancedValueBinder correct mis-identification as string, and StringValueBinder usually expects string. [PR #4139](https://github.com/PHPOffice/PhpSpreadsheet/pull/4139)
2222
- Currency and Accounting Wizards are changed to act like Excel, and a new CurrencyBase Wizard is added for for non-Excel formats. [Issue #4125](https://github.com/PHPOffice/PhpSpreadsheet/issues/4125) [Issue #4124](https://github.com/PHPOffice/PhpSpreadsheet/issues/4124) [PR #4127](https://github.com/PHPOffice/PhpSpreadsheet/pull/4127)
23+
- Images will not be added to spreadsheet if they cannot be validated as images.
2324

2425
### Deprecated
2526

2627
- Nothing yet.
2728

29+
### Removed
30+
31+
- The following items were deprecated in release 2 and are now removed.
32+
- Writer\Xls\Style\ColorMap (no longer needed).
33+
- Reader\Xml::trySimpleXMLLoadString (should not have been public, no public replacement).
34+
- Calculation\Calculation::_translateFormulaToLocale (use method name translateFormulaToLocale without leading underscore).
35+
- Calculation\Calculation::_translateFormulaToEnglish (use method name translateFormulaToEnglish without leading underscore).
36+
2837
### Moved
2938

3039
- Nothing yet.
3140

3241
### Fixed
3342

43+
- Several security patches.
3444
- Xls Reader Some Ranges Not Handled Properly. [Issue #1570](https://github.com/PHPOffice/PhpSpreadsheet/issues/1570) [PR #4140](https://github.com/PHPOffice/PhpSpreadsheet/pull/4140)
3545
- Better Handling of legacyDrawing Xml. [Issue #4105](https://github.com/PHPOffice/PhpSpreadsheet/issues/4105) [PR #4122](https://github.com/PHPOffice/PhpSpreadsheet/pull/4122)
46+
- Improve Xlsx Reader Speed. [Issue #3917](https://github.com/PHPOffice/PhpSpreadsheet/issues/3917) [PR #4153](https://github.com/PHPOffice/PhpSpreadsheet/pull/4153)
3647

3748
## 2024-08-07 - 2.2.2
3849

composer.lock

Lines changed: 37 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/Basic4/45_Quadratic_equation_solver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
?>
1616
<form action="45_Quadratic_equation_solver.php" method="POST">
17-
Enter the coefficients for the Ax<sup>2</sup> + Bx + C = 0
17+
Enter the coefficients for Ax<sup>2</sup> + Bx + C = 0
1818
<table border="0" cellpadding="0" cellspacing="0">
1919
<tr>
2020
<td>
@@ -47,7 +47,9 @@
4747
<?php
4848
/** If the user has submitted the form, then we need to execute a calculation * */
4949
if (isset($_POST['submit'])) {
50-
if ($_POST['A'] == 0) {
50+
if (!is_numeric($_POST['A']) || !is_numeric($_POST['B']) || !is_numeric($_POST['C'])) { // validate input
51+
$helper->log('Non-numeric input');
52+
} elseif ($_POST['A'] == 0) {
5153
$helper->log('The equation is not quadratic');
5254
} else {
5355
// Calculate and Display the results

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,16 +3318,6 @@ private static function translateFormula(array $from, array $to, string $formula
33183318

33193319
private static ?array $functionReplaceToLocale;
33203320

3321-
/**
3322-
* @deprecated 1.30.0 use translateFormulaToLocale() instead
3323-
*
3324-
* @codeCoverageIgnore
3325-
*/
3326-
public function _translateFormulaToLocale(string $formula): string
3327-
{
3328-
return $this->translateFormulaToLocale($formula);
3329-
}
3330-
33313321
public function translateFormulaToLocale(string $formula): string
33323322
{
33333323
$formula = preg_replace(self::CALCULATION_REGEXP_STRIP_XLFN_XLWS, '', $formula) ?? '';
@@ -3365,16 +3355,6 @@ public function translateFormulaToLocale(string $formula): string
33653355

33663356
private static ?array $functionReplaceToExcel;
33673357

3368-
/**
3369-
* @deprecated 1.30.0 use translateFormulaToEnglish() instead
3370-
*
3371-
* @codeCoverageIgnore
3372-
*/
3373-
public function _translateFormulaToEnglish(string $formula): string
3374-
{
3375-
return $this->translateFormulaToEnglish($formula);
3376-
}
3377-
33783358
public function translateFormulaToEnglish(string $formula): string
33793359
{
33803360
if (self::$functionReplaceFromLocale === null) {

src/PhpSpreadsheet/Calculation/Financial/Amortization.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class Amortization
1111
{
12-
private const ROUNDING_ADJUSTMENT = (PHP_VERSION_ID < 80400) ? 0 : 1e-14;
13-
1412
/**
1513
* AMORDEGRC.
1614
*
@@ -82,7 +80,7 @@ public static function AMORDEGRC(
8280
$amortiseCoeff = self::getAmortizationCoefficient($rate);
8381

8482
$rate *= $amortiseCoeff;
85-
$rate += self::ROUNDING_ADJUSTMENT;
83+
$rate = (float) (string) $rate; // ugly way to avoid rounding problem
8684
$fNRate = round($yearFrac * $rate * $cost, 0);
8785
$cost -= $fNRate;
8886
$fRest = $cost - $salvage;

src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ private static function vLookupSearch(mixed $lookupValue, array $lookupArray, $c
8888

8989
$rowNumber = null;
9090
foreach ($lookupArray as $rowKey => $rowData) {
91-
$bothNumeric = is_numeric($lookupValue) && is_numeric($rowData[$column]);
92-
$bothNotNumeric = !is_numeric($lookupValue) && !is_numeric($rowData[$column]);
91+
$bothNumeric = self::numeric($lookupValue) && self::numeric($rowData[$column]);
92+
$bothNotNumeric = !self::numeric($lookupValue) && !self::numeric($rowData[$column]);
9393
$cellDataLower = StringHelper::strToLower((string) $rowData[$column]);
9494

9595
// break if we have passed possible keys
@@ -114,4 +114,9 @@ private static function vLookupSearch(mixed $lookupValue, array $lookupArray, $c
114114

115115
return $rowNumber;
116116
}
117+
118+
private static function numeric(mixed $value): bool
119+
{
120+
return is_int($value) || is_float($value);
121+
}
117122
}

src/PhpSpreadsheet/Cell/Cell.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,21 @@ public function setValueExplicit(mixed $value, string $dataType = DataType::TYPE
318318
$this->updateInCollection();
319319
$cellCoordinate = $this->getCoordinate();
320320
self::updateIfCellIsTableHeader($this->getParent()?->getParent(), $this, $oldValue, $value);
321-
$this->getWorksheet()->applyStylesFromArray($cellCoordinate, ['quotePrefix' => $quotePrefix]);
321+
$worksheet = $this->getWorksheet();
322+
$spreadsheet = $worksheet->getParent();
323+
if (isset($spreadsheet)) {
324+
$originalSelected = $worksheet->getSelectedCells();
325+
$activeSheetIndex = $spreadsheet->getActiveSheetIndex();
326+
$style = $this->getStyle();
327+
$oldQuotePrefix = $style->getQuotePrefix();
328+
if ($oldQuotePrefix !== $quotePrefix) {
329+
$style->setQuotePrefix($quotePrefix);
330+
}
331+
$worksheet->setSelectedCells($originalSelected);
332+
if ($activeSheetIndex >= 0) {
333+
$spreadsheet->setActiveSheetIndex($activeSheetIndex);
334+
}
335+
}
322336

323337
return $this->getParent()?->get($cellCoordinate) ?? $this;
324338
}

0 commit comments

Comments
 (0)