Skip to content

Commit 5ce46da

Browse files
authored
Merge branch 'master' into issue4435
2 parents 70a590b + 1946564 commit 5ce46da

File tree

417 files changed

+2822
-2075
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

417 files changed

+2822
-2075
lines changed

CHANGELOG.md

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

1212
- Add ability to add custom functions to Calculation. [PR #4390](https://github.com/PHPOffice/PhpSpreadsheet/pull/4390)
1313
- Add FormulaRange to IgnoredErrors. [PR #4393](https://github.com/PHPOffice/PhpSpreadsheet/pull/4393)
14+
- TextGrid improvements. [PR #4418](https://github.com/PHPOffice/PhpSpreadsheet/pull/4418)
15+
- Permit read to class which extends Spreadsheet. [Discussion #4402](https://github.com/PHPOffice/PhpSpreadsheet/discussions/4402) [PR #4404](https://github.com/PHPOffice/PhpSpreadsheet/pull/4404)
16+
- Conditional and table formatting support for html writer [PR #4412](https://github.com/PHPOffice/PhpSpreadsheet/pull/4412)
1417

1518
### Removed
1619

@@ -22,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2225
- Start migration to Phpstan level 9. [PR #4396](https://github.com/PHPOffice/PhpSpreadsheet/pull/4396)
2326
- Calculation locale logic moved to separate class. [PR #4398](https://github.com/PHPOffice/PhpSpreadsheet/pull/4398)
2427
- TREND_POLYNOMIAL_* and TREND_BEST_FIT do not work, and are changed to throw Exceptions if attempted. (TREND_BEST_FIT_NO_POLY works.) An attempt to use an unknown trend type will now also throw an exception. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)
28+
- Month parameter of DATE function will now return VALUE if an ordinal string (e.g. '3rd') is used, but will accept bool or null. [PR #4420](https://github.com/PHPOffice/PhpSpreadsheet/pull/4420)
2529

2630
### Moved
2731

@@ -33,9 +37,14 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3337

3438
### Fixed
3539

40+
- Ignore fractional part of Drawing Shadow Alpha. [Issue #4415](https://github.com/PHPOffice/PhpSpreadsheet/issues/4415) [PR #4417](https://github.com/PHPOffice/PhpSpreadsheet/pull/4417)
3641
- BIN2DEC, OCT2DEC, and HEX2DEC return numbers rather than strings. [Issue #4383](https://github.com/PHPOffice/PhpSpreadsheet/issues/4383) [PR #4389](https://github.com/PHPOffice/PhpSpreadsheet/pull/4389)
3742
- Fix TREND_BEST_FIT_NO_POLY. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)
3843
- Ods Reader No DataType for Null Value. [Issue #4435](https://github.com/PHPOffice/PhpSpreadsheet/issues/4435) [PR #4436](https://github.com/PHPOffice/PhpSpreadsheet/pull/4436)
44+
- Column widths not preserved when using read filter. [Issue #4416](https://github.com/PHPOffice/PhpSpreadsheet/issues/4416) [PR #4423](https://github.com/PHPOffice/PhpSpreadsheet/pull/4423)
45+
- Fix typo in Style exportArray quotePrefix. [Issue #4422](https://github.com/PHPOffice/PhpSpreadsheet/issues/4422) [PR #4424](https://github.com/PHPOffice/PhpSpreadsheet/pull/4424)
46+
- Tweak Spreadsheet clone. [PR #4419](https://github.com/PHPOffice/PhpSpreadsheet/pull/4419)
47+
- Better handling of Chart DisplayBlanksAs. [Issue #4411](https://github.com/PHPOffice/PhpSpreadsheet/issues/4411) [PR #4414](https://github.com/PHPOffice/PhpSpreadsheet/pull/4414)
3948

4049
## 2025-03-02 - 4.1.0
4150

composer.lock

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

docs/topics/conditional-formatting.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,28 @@ Currently, the following Conditional Types are supported for the following Reade
143143

144144
MS Excel | Conditional Type | Readers | Writers
145145
---|---|---|---
146-
| Cell Value | Conditional::CONDITION_CELLIS | Xlsx | Xlsx, Xls
147-
Specific Text | Conditional::CONDITION_CONTAINSTEXT | Xlsx | Xlsx
148-
| Conditional::CONDITION_NOTCONTAINSTEXT | Xlsx | Xlsx
149-
| Conditional::CONDITION_BEGINSWITH | Xlsx | Xlsx
150-
| Conditional::CONDITION_ENDSWITH | Xlsx | Xlsx
151-
Dates Occurring | Conditional::CONDITION_TIMEPERIOD | Xlsx | Xlsx
152-
Blanks | Conditional::CONDITION_CONTAINSBLANKS | Xlsx | Xlsx
153-
No Blanks | Conditional::CONDITION_NOTCONTAINSBLANKS | Xlsx | Xlsx
154-
Errors | Conditional::CONDITION_CONTAINSERRORS | Xlsx | Xlsx
155-
No Errors | Conditional::CONDITION_NOTCONTAINSERRORS | Xlsx | Xlsx
156-
Duplicates/Unique | Conditional::CONDITION_DUPLICATES | Xlsx | Xlsx
157-
| Conditional::CONDITION_UNIQUE | Xlsx | Xlsx
158-
Use a formula | Conditional::CONDITION_EXPRESSION | Xlsx | Xlsx, Xls
159-
Data Bars | Conditional::CONDITION_DATABAR | Xlsx | Xlsx
146+
| Cell Value | Conditional::CONDITION_CELLIS | Xlsx | Xlsx, Xls, Html
147+
Specific Text | Conditional::CONDITION_CONTAINSTEXT | Xlsx | Xlsx, Html
148+
| Conditional::CONDITION_NOTCONTAINSTEXT | Xlsx | Xlsx, Html
149+
| Conditional::CONDITION_BEGINSWITH | Xlsx | Xlsx, Html
150+
| Conditional::CONDITION_ENDSWITH | Xlsx | Xlsx, Html
151+
Dates Occurring | Conditional::CONDITION_TIMEPERIOD | Xlsx | Xlsx, Html
152+
Blanks | Conditional::CONDITION_CONTAINSBLANKS | Xlsx | Xlsx, Html
153+
No Blanks | Conditional::CONDITION_NOTCONTAINSBLANKS | Xlsx | Xlsx, Html
154+
Errors | Conditional::CONDITION_CONTAINSERRORS | Xlsx | Xlsx, Html
155+
No Errors | Conditional::CONDITION_NOTCONTAINSERRORS | Xlsx | Xlsx, Html
156+
Duplicates/Unique | Conditional::CONDITION_DUPLICATES | Xlsx | Xlsx, Html
157+
| Conditional::CONDITION_UNIQUE | Xlsx | Xlsx, Html
158+
Use a formula | Conditional::CONDITION_EXPRESSION | Xlsx | Xlsx, Xls, Html
159+
Data Bars | Conditional::CONDITION_DATABAR | Xlsx | Xlsx, Html
160+
Colour Scales | Conditional::COLORSCALE | Xlsx | Html
161+
162+
To enable conditional formatting for Html writer, use:
163+
164+
```php
165+
$writer = new HtmlWriter($spreadsheet);
166+
$writer->setConditionalFormatting(true);
167+
```
160168

161169
The following Conditional Types are currently not supported by any Readers or Writers:
162170

@@ -165,7 +173,6 @@ MS Excel | Conditional Type
165173
Above/Below Average | ?
166174
Top/Bottom Items | ?
167175
Top/Bottom %age | ?
168-
Colour Scales |?
169176
Icon Sets | ?
170177

171178
Unsupported types will by ignored by the Readers, and cannot be created through PHPSpreadsheet.

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

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,44 @@ One benefit of flags is that you can pass several flags in a single method call.
11691169
Two or more flags can be passed together using PHP's `|` operator.
11701170

11711171
```php
1172-
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile("myExampleFile.xlsx");
1173-
$reader->load("spreadsheetWithCharts.xlsx", $reader::READ_DATA_ONLY | $reader::IGNORE_EMPTY_CELLS);
1174-
```
1172+
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReaderForFile('myExampleFile.xlsx');
1173+
$reader->load(
1174+
'spreadsheetWithCharts.xlsx',
1175+
$reader::READ_DATA_ONLY | $reader::IGNORE_EMPTY_CELLS
1176+
);
1177+
```
1178+
1179+
## Writing Data as a Plaintext Grid
1180+
1181+
Although not really a spreadsheet format, it can be useful to write data in grid format to a plaintext file.
1182+
Code like the following can be used:
1183+
```php
1184+
$array = $sheet->toArray(null, true, true, true);
1185+
$textGrid = new \PhpOffice\PhpSpreadsheet\Shared\TextGrid(
1186+
$array,
1187+
true, // true for cli, false for html
1188+
// Starting with release 4.2,
1189+
// the output format can be tweaked by uncommenting
1190+
// any of the following 3 optional parameters.
1191+
// rowDividers: true,
1192+
// rowHeaders: false,
1193+
// columnHeaders: false,
1194+
);
1195+
$result = $textGrid->render();
1196+
```
1197+
You can then echo `$result` to a terminal, or write it to a file with `file_put_contents`. The result will resemble:
1198+
```
1199+
+-----+------------------+---+----------+
1200+
| A | B | C | D |
1201+
+---+-----+------------------+---+----------+
1202+
| 1 | 6 | 1900-01-06 00:00 | | 0.572917 |
1203+
| 2 | 6 | TRUE | | 1<>2 |
1204+
| 3 | xyz | xyz | | |
1205+
+---+-----+------------------+---+----------+
1206+
```
1207+
Please note that this may produce sub-optimal results for situations such as:
1208+
1209+
- use of accents as combining characters rather than using pre-composed characters (may be handled by extending the class to override the `getString` or `strlen` methods)
1210+
- Fullwidth characters
1211+
- right-to-left characters (better display in a browser than a terminal on a non-RTL system)
1212+
- multi-line strings

0 commit comments

Comments
 (0)