Skip to content

Commit 2213139

Browse files
authored
Merge branch 'master' into issue4416
2 parents 664b9c7 + f52ae20 commit 2213139

File tree

70 files changed

+2074
-698
lines changed

Some content is hidden

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

70 files changed

+2074
-698
lines changed

CHANGELOG.md

+7
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

@@ -33,9 +36,13 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3336

3437
### Fixed
3538

39+
- 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)
3640
- 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)
3741
- Fix TREND_BEST_FIT_NO_POLY. [Issue #4400](https://github.com/PHPOffice/PhpSpreadsheet/issues/4400) [PR #4339](https://github.com/PHPOffice/PhpSpreadsheet/pull/4339)
3842
- 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)
43+
- Fix typo in Style exportArray quotePrefix. [Issue #4422](https://github.com/PHPOffice/PhpSpreadsheet/issues/4422) [PR #4424](https://github.com/PHPOffice/PhpSpreadsheet/pull/4424)
44+
- Tweak Spreadsheet clone. [PR #4419](https://github.com/PHPOffice/PhpSpreadsheet/pull/4419)
45+
- Better handling of Chart DisplayBlanksAs. [Issue #4411](https://github.com/PHPOffice/PhpSpreadsheet/issues/4411) [PR #4414](https://github.com/PHPOffice/PhpSpreadsheet/pull/4414)
3946

4047
## 2025-03-02 - 4.1.0
4148

docs/topics/conditional-formatting.md

+22-15
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

+41-3
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

docs/topics/tables.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Tables
2+
3+
## Introduction
4+
5+
To make managing and analyzing a group of related data easier, you can turn a range of cells into an Excel table (previously known as an Excel list).
6+
7+
## Support
8+
9+
Currently tables are supported in Xlsx reader and Html Writer
10+
11+
To enable table formatting for Html writer, use:
12+
13+
```php
14+
$writer = new HtmlWriter($spreadsheet);
15+
$writer->setConditionalFormatting(true);
16+
```

0 commit comments

Comments
 (0)