Skip to content

Commit d0a0080

Browse files
authored
Merge branch 'master' into parseutf8
2 parents ac34f58 + 06f0b4c commit d0a0080

23 files changed

+72
-175
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org).
1111

1212
- Data Validations will be stored by worksheet, not cell. Index can be one or more cells or cell ranges. [Issue #797](https://github.com/PHPOffice/PhpSpreadsheet/issues/797) [Issue #4091](https://github.com/PHPOffice/PhpSpreadsheet/issues/4091) [Issue #4206](https://github.com/PHPOffice/PhpSpreadsheet/issues/4206) [PR #4240](https://github.com/PHPOffice/PhpSpreadsheet/pull/4240)
1313
- Conditional Formatting adds Priority property and handles overlapping ranges better. [Issue #4312](https://github.com/PHPOffice/PhpSpreadsheet/issues/4312) [Issue #4318](https://github.com/PHPOffice/PhpSpreadsheet/issues/4318) [PR #4314](https://github.com/PHPOffice/PhpSpreadsheet/pull/4314)
14+
- Csv Reader will no longer auto-detect Mac line endings by default. Prior behavior can be explicitly enabled via `setTestAutoDetect(true)`, and it will not be possible at all with Php9+. [Issue #4092](https://github.com/PHPOffice/PhpSpreadsheet/issues/4092) [PR #4340](https://github.com/PHPOffice/PhpSpreadsheet/pull/4340)
15+
- Html Writer will now use "better boolean" logic. Booleans will now be output by default as TRUE/FALSE rather than 1/null-string. Prior behavior can be explicitly enabled via `setBetterBoolean(false)`. [PR #4340](https://github.com/PHPOffice/PhpSpreadsheet/pull/4340)
16+
- Xlsx Writer will now use false as the default for `forceFullCalc`. This affects writes with `preCalculateFormulas` set to false. Prior behavior can be explicitly enabled via `setForceFullCalc(null)`.[PR #4340](https://github.com/PHPOffice/PhpSpreadsheet/pull/4340)
1417
- Deletion of items deprecated in Release 3. See "removed" below.
1518

1619
### Added
@@ -19,7 +22,14 @@ and this project adheres to [Semantic Versioning](https://semver.org).
1922

2023
### Removed
2124

22-
- Nothing yet.
25+
- Worksheet::getStyles - no replacement. [PR #4330](https://github.com/PHPOffice/PhpSpreadsheet/pull/4330)
26+
- The following items were deprecated in release 3 and are now removed.
27+
- Drawing::setIsUrl - no replacement.
28+
- Settings::setLibXmlLoaderOptions() and Settings::getLibXmlLoaderOptions() - no replacement.
29+
- Worksheet::getHashCode - no replacement.
30+
- IReader::SKIP_EMPTY_CELLS - use its alias IGNORE_EMPTY_CELLS instead.
31+
- Worksheet::getProtectedCells - use getProtectedCellRanges instead.
32+
- Writer/Html::isMpdf property - use instanceof Mpdf instead.
2333

2434
### Changed
2535

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ This makes it easier to see exactly what is being tested when reviewing the PR.
4242
3. Push the tag with `git push --tags`, GitHub Actions will create a GitHub release automatically, and the release details will automatically be sent to packagist.
4343
4. By default, Github removes markdown headings in the Release Notes. You can either edit to restore these, or, probably preferably, change the default comment character on your system - `git config core.commentChar ";"`.
4444

45-
> **Note:** Tagged releases are made from the `master` branch. Only in an emergency should a tagged release be made from the `release` branch. (i.e. cherry-picked hot-fixes.) However, there are 3 branches which have been updated to apply security patches, and those may be tagged if future security updates are needed.
45+
> **Note:** Tagged releases are made from the `master` branch. Only in an emergency should a tagged release be made from the `release` branch. (i.e. cherry-picked hot-fixes.) However, there are 4 branches which have been updated to apply security patches, and those may be tagged if future security updates are needed.
4646
- release1291
4747
- release210
4848
- release222
49-
49+
- release390

docs/topics/reading-and-writing-to-file.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ even if pre-calculated is set to false
173173
```php
174174
$writer->setForceFullCalc(false);
175175
```
176-
In a future release, the property's default may change to `false` and that statement may no longer be required.
176+
Starting with Release 4.0.0, the property's default is changed to `false` and that statement is no longer be required. The property can be set to `null` if the old behavior is needed.
177177

178178
#### Office 2003 compatibility pack
179179

@@ -594,6 +594,9 @@ You can suppress testing for Mac line endings as follows:
594594
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Csv();
595595
$reader->setTestAutoDetect(false);
596596
```
597+
Starting with Release 4.0.0, the property defaults to `false`,
598+
so the statement above is no longer needed. The old behavior
599+
can be enabled by setting the property to `true`.
597600

598601
### \PhpOffice\PhpSpreadsheet\Writer\Csv
599602

src/PhpSpreadsheet/Reader/Csv.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class Csv extends BaseReader
8484
*/
8585
private static $constructorCallback;
8686

87-
/** Will be changed to false in next major release */
88-
public const DEFAULT_TEST_AUTODETECT = true;
87+
/** Changed from true to false in release 4.0.0 */
88+
public const DEFAULT_TEST_AUTODETECT = false;
8989

9090
/**
9191
* Attempt autodetect line endings (deprecated after PHP8.1)?

src/PhpSpreadsheet/Reader/IReader.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ interface IReader
1818
*/
1919
public const READ_DATA_ONLY = 2;
2020

21-
/**
22-
* @deprecated 3.4.0 use IGNORE_EMPTY_CELLS instead.
23-
*/
24-
public const SKIP_EMPTY_CELLS = self::IGNORE_EMPTY_CELLS;
25-
2621
/**
2722
* Flag used to ignore empty cells when reading.
2823
*

src/PhpSpreadsheet/ReferenceHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,14 @@ protected function adjustMergeCells(Worksheet $worksheet): void
321321
*/
322322
protected function adjustProtectedCells(Worksheet $worksheet, int $numberOfColumns, int $numberOfRows): void
323323
{
324-
$aProtectedCells = $worksheet->getProtectedCells();
324+
$aProtectedCells = $worksheet->getProtectedCellRanges();
325325
($numberOfColumns > 0 || $numberOfRows > 0)
326326
? uksort($aProtectedCells, [self::class, 'cellReverseSort'])
327327
: uksort($aProtectedCells, [self::class, 'cellSort']);
328-
foreach ($aProtectedCells as $cellAddress => $value) {
328+
foreach ($aProtectedCells as $cellAddress => $protectedRange) {
329329
$newReference = $this->updateCellReference($cellAddress);
330330
if ($cellAddress !== $newReference) {
331-
$worksheet->protectCells($newReference, $value, true);
331+
$worksheet->protectCells($newReference, $protectedRange->getPassword(), true);
332332
$worksheet->unprotectCells($cellAddress);
333333
}
334334
}

src/PhpSpreadsheet/Settings.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ class Settings
2020
*/
2121
private static ?string $chartRenderer = null;
2222

23-
/**
24-
* Default options for libxml loader.
25-
*/
26-
private static ?int $libXmlLoaderOptions = null;
27-
2823
/**
2924
* The cache implementation to be used for cell collection.
3025
*/
@@ -90,36 +85,6 @@ public static function htmlEntityFlags(): int
9085
return ENT_COMPAT;
9186
}
9287

93-
/**
94-
* Set default options for libxml loader.
95-
*
96-
* @param ?int $options Default options for libxml loader
97-
*
98-
* @deprecated 3.5.0 no longer needed
99-
*/
100-
public static function setLibXmlLoaderOptions(?int $options): int
101-
{
102-
if ($options === null) {
103-
$options = defined('LIBXML_DTDLOAD') ? (LIBXML_DTDLOAD | LIBXML_DTDATTR) : 0;
104-
}
105-
self::$libXmlLoaderOptions = $options;
106-
107-
return $options;
108-
}
109-
110-
/**
111-
* Get default options for libxml loader.
112-
* Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly.
113-
*
114-
* @return int Default options for libxml loader
115-
*
116-
* @deprecated 3.5.0 no longer needed
117-
*/
118-
public static function getLibXmlLoaderOptions(): int
119-
{
120-
return self::$libXmlLoaderOptions ?? (defined('LIBXML_DTDLOAD') ? (LIBXML_DTDLOAD | LIBXML_DTDATTR) : 0);
121-
}
122-
12388
/**
12489
* Sets the implementation of cache that should be used for cell collection.
12590
*/

src/PhpSpreadsheet/Worksheet/Drawing.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,6 @@ public function getIsURL(): bool
192192
return $this->isUrl;
193193
}
194194

195-
/**
196-
* Set isURL.
197-
*
198-
* @return $this
199-
*
200-
* @deprecated 3.7.0 not needed, property is set by setPath
201-
*/
202-
public function setIsURL(bool $isUrl): self
203-
{
204-
$this->isUrl = $isUrl;
205-
206-
return $this;
207-
}
208-
209195
/**
210196
* Get hash code.
211197
*

src/PhpSpreadsheet/Worksheet/Worksheet.php

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Worksheet
6363
/**
6464
* Invalid characters in sheet title.
6565
*/
66-
private static array $invalidCharacters = ['*', ':', '/', '\\', '?', '[', ']'];
66+
private const INVALID_CHARACTERS = ['*', ':', '/', '\\', '?', '[', ']'];
6767

6868
/**
6969
* Parent spreadsheet.
@@ -157,13 +157,6 @@ class Worksheet
157157
*/
158158
private Protection $protection;
159159

160-
/**
161-
* Collection of styles.
162-
*
163-
* @var Style[]
164-
*/
165-
private array $styles = [];
166-
167160
/**
168161
* Conditional styles. Indexed by cell coordinate, e.g. 'A1'.
169162
*/
@@ -400,7 +393,7 @@ public function getCellCollection(): Cells
400393
*/
401394
public static function getInvalidCharacters(): array
402395
{
403-
return self::$invalidCharacters;
396+
return self::INVALID_CHARACTERS;
404397
}
405398

406399
/**
@@ -418,7 +411,7 @@ private static function checkSheetCodeName(string $sheetCodeName): string
418411
}
419412
// Some of the printable ASCII characters are invalid: * : / \ ? [ ] and first and last characters cannot be a "'"
420413
if (
421-
(str_replace(self::$invalidCharacters, '', $sheetCodeName) !== $sheetCodeName)
414+
(str_replace(self::INVALID_CHARACTERS, '', $sheetCodeName) !== $sheetCodeName)
422415
|| (Shared\StringHelper::substring($sheetCodeName, -1, 1) == '\'')
423416
|| (Shared\StringHelper::substring($sheetCodeName, 0, 1) == '\'')
424417
) {
@@ -443,7 +436,7 @@ private static function checkSheetCodeName(string $sheetCodeName): string
443436
private static function checkSheetTitle(string $sheetTitle): string
444437
{
445438
// Some of the printable ASCII characters are invalid: * : / \ ? [ ]
446-
if (str_replace(self::$invalidCharacters, '', $sheetTitle) !== $sheetTitle) {
439+
if (str_replace(self::INVALID_CHARACTERS, '', $sheetTitle) !== $sheetTitle) {
447440
throw new Exception('Invalid character found in sheet title');
448441
}
449442

@@ -1393,16 +1386,6 @@ public function getColumnStyle(string $column): ?Style
13931386
);
13941387
}
13951388

1396-
/**
1397-
* Get styles.
1398-
*
1399-
* @return Style[]
1400-
*/
1401-
public function getStyles(): array
1402-
{
1403-
return $this->styles;
1404-
}
1405-
14061389
/**
14071390
* Get style for cell.
14081391
*
@@ -1957,24 +1940,6 @@ public function unprotectCells(AddressRange|CellAddress|int|string|array $range)
19571940
return $this;
19581941
}
19591942

1960-
/**
1961-
* Get password for protected cells.
1962-
*
1963-
* @return string[]
1964-
*
1965-
* @deprecated 2.0.1 use getProtectedCellRanges instead
1966-
* @see Worksheet::getProtectedCellRanges()
1967-
*/
1968-
public function getProtectedCells(): array
1969-
{
1970-
$array = [];
1971-
foreach ($this->protectedCells as $key => $protectedRange) {
1972-
$array[$key] = $protectedRange->getPassword();
1973-
}
1974-
1975-
return $array;
1976-
}
1977-
19781943
/**
19791944
* Get protected cells.
19801945
*
@@ -3198,14 +3163,6 @@ public function garbageCollect(): static
31983163
return $this;
31993164
}
32003165

3201-
/**
3202-
* @deprecated 3.5.0 use getHashInt instead.
3203-
*/
3204-
public function getHashCode(): string
3205-
{
3206-
return (string) $this->hash;
3207-
}
3208-
32093166
public function getHashInt(): int
32103167
{
32113168
return $this->hash;

src/PhpSpreadsheet/Writer/Html.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,6 @@ class Html extends BaseWriter
118118
*/
119119
protected bool $isPdf = false;
120120

121-
/**
122-
* Is the current writer creating mPDF?
123-
*
124-
* @deprecated 2.0.1 use instanceof Mpdf instead
125-
*/
126-
protected bool $isMPdf = false;
127-
128121
/**
129122
* Generate the Navigation block.
130123
*/
@@ -143,7 +136,7 @@ class Html extends BaseWriter
143136
/** @var Chart[] */
144137
private $sheetCharts;
145138

146-
private bool $betterBoolean = false;
139+
private bool $betterBoolean = true;
147140

148141
private string $getTrue = 'TRUE';
149142

@@ -1494,7 +1487,7 @@ private function generateRowWriteCell(
14941487
$dataType = $worksheet->getCell($coordinate)->getDataType();
14951488
if ($dataType === DataType::TYPE_BOOL) {
14961489
$html .= ' data-type="' . DataType::TYPE_BOOL . '"';
1497-
} elseif ($dataType === DataType::TYPE_FORMULA && is_bool($worksheet->getCell($coordinate)->getCalculatedValue())) {
1490+
} elseif ($dataType === DataType::TYPE_FORMULA && $this->preCalculateFormulas && is_bool($worksheet->getCell($coordinate)->getCalculatedValue())) {
14981491
$html .= ' data-type="' . DataType::TYPE_BOOL . '"';
14991492
} elseif (is_numeric($cellData) && $worksheet->getCell($coordinate)->getDataType() === DataType::TYPE_STRING) {
15001493
$html .= ' data-type="' . DataType::TYPE_STRING . '"';

0 commit comments

Comments
 (0)