Skip to content

Commit 257c222

Browse files
Merge branch 'PHPOffice:master' into Table-for-Xlsx
2 parents d82c01e + 8885c4e commit 257c222

File tree

125 files changed

+4067
-1063
lines changed

Some content is hidden

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

125 files changed

+4067
-1063
lines changed

.php-cs-fixer.dist.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
'combine_consecutive_issets' => true,
2727
'combine_consecutive_unsets' => true,
2828
'combine_nested_dirname' => true,
29-
'comment_to_phpdoc' => true,
29+
'comment_to_phpdoc' => false, // interferes with annotations
3030
'compact_nullable_typehint' => true,
3131
'concat_space' => ['spacing' => 'one'],
3232
'constant_case' => true,
@@ -171,7 +171,7 @@
171171
'phpdoc_separation' => true,
172172
'phpdoc_single_line_var_spacing' => true,
173173
'phpdoc_summary' => true,
174-
'phpdoc_to_comment' => true,
174+
'phpdoc_to_comment' => false, // interferes with annotations
175175
'phpdoc_to_param_type' => false, // Because experimental, but interesting for one shot use
176176
'phpdoc_to_return_type' => false, // idem
177177
'phpdoc_trim' => true,

CHANGELOG.md

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

1010
### Added
1111

12-
- Implementation of the ISREF() information function.
12+
- Implementation of the FILTER(), SORT(), SORTBY() and UNIQUE() Lookup/Reference (array) functions
13+
- Implementation of the ISREF() Information function.
1314
- Added support for reading "formatted" numeric values from Csv files; although default behaviour of reading these values as strings is preserved.
1415

1516
(i.e a value of "12,345.67" can be read as numeric `1235.67`, not simply as a string `"12,345.67"`, if the `castFormattedNumberToNumeric()` setting is enabled.
1617

1718
This functionality is locale-aware, using the server's locale settings to identify the thousands and decimal separators.
1819

1920
- Support for two cell anchor drawing of images. [#2532](https://github.com/PHPOffice/PhpSpreadsheet/pull/2532)
21+
- Limited support for Xls Reader to handle Conditional Formatting:
22+
23+
Ranges and Rules are read, but style is currently limited to font size, weight and color; and to fill style and color.
2024

2125
### Changed
2226

@@ -28,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2832
This is determined by the Calculation Engine locale setting.
2933

3034
(i.e. `"Vrai"` wil be converted to a boolean `true` if the Locale is set to `fr`.)
35+
- Allow `psr/simple-cache` 2.x
3136

3237
### Deprecated
3338

@@ -39,6 +44,11 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3944

4045
### Fixed
4146

47+
- Update Conditional Formatting ranges and rule conditions when inserting/deleting rows/columns [Issue #2678](https://github.com/PHPOffice/PhpSpreadsheet/issues/2678) [PR #2689](https://github.com/PHPOffice/PhpSpreadsheet/pull/2689)
48+
- Allow `INDIRECT()` to accept row/column ranges as well as cell ranges [PR #2687](https://github.com/PHPOffice/PhpSpreadsheet/pull/2687)
49+
- Fix bug when deleting cells with hyperlinks, where the hyperlink was then being "inherited" by whatever cell moved to that cell address.
50+
- Fix bug in Conditional Formatting in the Xls Writer that resulted in a broken file when there were multiple conditional ranges in a worksheet.
51+
- Fix Conditional Formatting in the Xls Writer to work with rules that contain string literals, cell references and formulae.
4252
- Fix for setting Active Sheet to the first loaded worksheet when bookViews element isn't defined [Issue #2666](https://github.com/PHPOffice/PhpSpreadsheet/issues/2666) [PR #2669](https://github.com/PHPOffice/PhpSpreadsheet/pull/2669)
4353
- Fixed behaviour of XLSX font style vertical align settings.
4454
- Resolved formula translations to handle separators (row and column) for array functions as well as for function argument separators; and cleanly handle nesting levels.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
"markbaker/matrix": "^3.0",
7676
"psr/http-client": "^1.0",
7777
"psr/http-factory": "^1.0",
78-
"psr/simple-cache": "^1.0"
78+
"psr/simple-cache": "^1.0 || ^2.0"
7979
},
8080
"require-dev": {
8181
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan-baseline.neon

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,16 +2300,6 @@ parameters:
23002300
count: 2
23012301
path: src/PhpSpreadsheet/Reader/Xls.php
23022302

2303-
-
2304-
message: "#^Parameter \\#1 \\$errorStyle of method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\DataValidation\\:\\:setErrorStyle\\(\\) expects string, int\\|string given\\.$#"
2305-
count: 1
2306-
path: src/PhpSpreadsheet/Reader/Xls.php
2307-
2308-
-
2309-
message: "#^Parameter \\#1 \\$operator of method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\DataValidation\\:\\:setOperator\\(\\) expects string, int\\|string given\\.$#"
2310-
count: 1
2311-
path: src/PhpSpreadsheet/Reader/Xls.php
2312-
23132303
-
23142304
message: "#^Parameter \\#1 \\$showSummaryBelow of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:setShowSummaryBelow\\(\\) expects bool, int given\\.$#"
23152305
count: 1
@@ -2320,11 +2310,6 @@ parameters:
23202310
count: 1
23212311
path: src/PhpSpreadsheet/Reader/Xls.php
23222312

2323-
-
2324-
message: "#^Parameter \\#1 \\$type of method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\DataValidation\\:\\:setType\\(\\) expects string, int\\|string given\\.$#"
2325-
count: 1
2326-
path: src/PhpSpreadsheet/Reader/Xls.php
2327-
23282313
-
23292314
message: "#^Parameter \\#2 \\$row of method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\IReadFilter\\:\\:readCell\\(\\) expects int, string given\\.$#"
23302315
count: 1
@@ -3165,31 +3150,11 @@ parameters:
31653150
count: 1
31663151
path: src/PhpSpreadsheet/ReferenceHelper.php
31673152

3168-
-
3169-
message: "#^Parameter \\#1 \\$index of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\RowDimension\\:\\:setRowIndex\\(\\) expects int, string given\\.$#"
3170-
count: 1
3171-
path: src/PhpSpreadsheet/ReferenceHelper.php
3172-
3173-
-
3174-
message: "#^Parameter \\#2 \\$callback of function uksort expects callable\\(\\(int\\|string\\), \\(int\\|string\\)\\)\\: int, array\\{'self', 'cellReverseSort'\\} given\\.$#"
3175-
count: 4
3176-
path: src/PhpSpreadsheet/ReferenceHelper.php
3177-
3178-
-
3179-
message: "#^Parameter \\#2 \\$callback of function uksort expects callable\\(\\(int\\|string\\), \\(int\\|string\\)\\)\\: int, array\\{'self', 'cellSort'\\} given\\.$#"
3180-
count: 4
3181-
path: src/PhpSpreadsheet/ReferenceHelper.php
3182-
31833153
-
31843154
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|null given\\.$#"
31853155
count: 1
31863156
path: src/PhpSpreadsheet/ReferenceHelper.php
31873157

3188-
-
3189-
message: "#^Static property PhpOffice\\\\PhpSpreadsheet\\\\ReferenceHelper\\:\\:\\$instance \\(PhpOffice\\\\PhpSpreadsheet\\\\ReferenceHelper\\) in isset\\(\\) is not nullable\\.$#"
3190-
count: 1
3191-
path: src/PhpSpreadsheet/ReferenceHelper.php
3192-
31933158
-
31943159
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\Run\\:\\:\\$font \\(PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null\\.$#"
31953160
count: 1
@@ -4240,26 +4205,6 @@ parameters:
42404205
count: 1
42414206
path: src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php
42424207

4243-
-
4244-
message: "#^Cannot call method getCell\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#"
4245-
count: 1
4246-
path: src/PhpSpreadsheet/Worksheet/BaseDrawing.php
4247-
4248-
-
4249-
message: "#^Cannot call method getDrawingCollection\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#"
4250-
count: 1
4251-
path: src/PhpSpreadsheet/Worksheet/BaseDrawing.php
4252-
4253-
-
4254-
message: "#^Cannot call method getHashCode\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#"
4255-
count: 1
4256-
path: src/PhpSpreadsheet/Worksheet/BaseDrawing.php
4257-
4258-
-
4259-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\BaseDrawing\\:\\:\\$shadow \\(PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Drawing\\\\Shadow\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Drawing\\\\Shadow\\|null\\.$#"
4260-
count: 1
4261-
path: src/PhpSpreadsheet/Worksheet/BaseDrawing.php
4262-
42634208
-
42644209
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\CellIterator\\:\\:adjustForExistingOnlyRange\\(\\) has no return type specified\\.$#"
42654210
count: 1
@@ -5270,36 +5215,6 @@ parameters:
52705215
count: 2
52715216
path: src/PhpSpreadsheet/Writer/Xlsx/DocProps.php
52725217

5273-
-
5274-
message: "#^Parameter \\#1 \\$coordinates of static method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\Coordinate\\:\\:indexesFromString\\(\\) expects string, string\\|null given\\.$#"
5275-
count: 1
5276-
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
5277-
5278-
-
5279-
message: "#^Parameter \\#1 \\$index of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:getChartByIndex\\(\\) expects string, int\\<0, max\\> given\\.$#"
5280-
count: 1
5281-
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
5282-
5283-
-
5284-
message: "#^Parameter \\#2 \\$chart of method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Drawing\\:\\:writeChart\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false given\\.$#"
5285-
count: 1
5286-
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
5287-
5288-
-
5289-
message: "#^Parameter \\#2 \\$content of method XMLWriter\\:\\:writeElement\\(\\) expects string\\|null, int given\\.$#"
5290-
count: 20
5291-
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
5292-
5293-
-
5294-
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int given\\.$#"
5295-
count: 10
5296-
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
5297-
5298-
-
5299-
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int\\<0, max\\> given\\.$#"
5300-
count: 1
5301-
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
5302-
53035218
-
53045219
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeUnparsedRelationship\\(\\) has parameter \\$relationship with no type specified\\.$#"
53055220
count: 1
@@ -5554,3 +5469,4 @@ parameters:
55545469
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Xlfn\\:\\:addXlfn\\(\\) should return string but returns string\\|null\\.$#"
55555470
count: 1
55565471
path: src/PhpSpreadsheet/Writer/Xlsx/Xlfn.php
5472+

samples/Basic/44_Worksheet_info.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
<?php
22

33
use PhpOffice\PhpSpreadsheet\IOFactory;
4-
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
4+
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as Reader;
5+
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as Writer;
56

67
require __DIR__ . '/../Header.php';
78

89
// Create temporary file that will be read
910
$sampleSpreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
1011
$filename = $helper->getTemporaryFilename();
11-
$writer = new Xlsx($sampleSpreadsheet);
12+
$writer = new Writer($sampleSpreadsheet);
1213
$writer->save($filename);
1314

1415
$inputFileType = IOFactory::identify($filename);
15-
$reader = IOFactory::createReader($inputFileType);
16+
$reader = new Reader();
1617
$sheetList = $reader->listWorksheetNames($filename);
1718
$sheetInfo = $reader->listWorksheetInfo($filename);
1819

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
// Create new Spreadsheet object
4+
use PhpOffice\PhpSpreadsheet\Helper\Dimension;
5+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
6+
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
7+
8+
require __DIR__ . '/../Header.php';
9+
10+
$helper->log('Create new Spreadsheet object');
11+
$spreadsheet = new Spreadsheet();
12+
$sheet = $spreadsheet->getActiveSheet();
13+
$sheet->getCell('A1')->setValue('twocell');
14+
$sheet->getCell('A2')->setValue('twocell');
15+
$sheet->getCell('A3')->setValue('onecell');
16+
$sheet->getCell('A6')->setValue('absolute');
17+
18+
// Add a drawing to the worksheet
19+
$helper->log('Add a drawing to the worksheet two-cell anchor not resized');
20+
$drawing = new Drawing();
21+
$drawing->setName('PhpSpreadsheet');
22+
$drawing->setDescription('PhpSpreadsheet');
23+
$drawing->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png');
24+
// anchor type will be two-cell because Coordinates2 is set
25+
//$drawing->setAnchorType(Drawing::ANCHORTYPE_TWOCELL);
26+
$drawing->setCoordinates('B1');
27+
$drawing->setCoordinates2('B1');
28+
$drawing->setOffsetX2($drawing->getImageWidth());
29+
$drawing->setOffsetY2($drawing->getImageHeight());
30+
$drawing->setWorksheet($spreadsheet->getActiveSheet());
31+
32+
// Add a drawing to the worksheet
33+
$helper->log('Add a drawing to the worksheet two-cell anchor resized');
34+
$drawing2 = new Drawing();
35+
$drawing2->setName('PhpSpreadsheet');
36+
$drawing2->setDescription('PhpSpreadsheet');
37+
$drawing2->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png');
38+
// anchor type will be two-cell because Coordinates2 is set
39+
//$drawing->setAnchorType(Drawing::ANCHORTYPE_TWOCELL);
40+
$drawing2->setCoordinates('C2');
41+
$drawing2->setCoordinates2('C2');
42+
$drawing2->setOffsetX2($drawing->getImageWidth());
43+
$drawing2->setOffsetY2($drawing->getImageHeight());
44+
$drawing2->setWorksheet($spreadsheet->getActiveSheet());
45+
46+
$spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth($drawing->getImageWidth(), Dimension::UOM_PIXELS);
47+
$spreadsheet->getActiveSheet()->getRowDimension(2)->setRowHeight($drawing->getImageHeight(), Dimension::UOM_PIXELS);
48+
49+
// Add a drawing to the worksheet one cell anchor
50+
$helper->log('Add a drawing to the worksheet one-cell anchor');
51+
$drawing3 = new Drawing();
52+
$drawing3->setName('PhpSpreadsheet');
53+
$drawing3->setDescription('PhpSpreadsheet');
54+
$drawing3->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png');
55+
// anchor type will be one-cell because Coordinates2 is not set
56+
//$drawing->setAnchorType(Drawing::ANCHORTYPE_ONECELL);
57+
$drawing3->setCoordinates('D3');
58+
$drawing3->setWorksheet($spreadsheet->getActiveSheet());
59+
60+
// Add a drawing to the worksheet
61+
$helper->log('Add a drawing to the worksheet two-cell anchor resized absolute');
62+
$drawing4 = new Drawing();
63+
$drawing4->setName('PhpSpreadsheet');
64+
$drawing4->setDescription('PhpSpreadsheet');
65+
$drawing4->setPath(__DIR__ . '/../images/PhpSpreadsheet_logo.png');
66+
// anchor type will be two-cell because Coordinates2 is set
67+
//$drawing->setAnchorType(Drawing::ANCHORTYPE_TWOCELL);
68+
$drawing4->setCoordinates('C6');
69+
$drawing4->setCoordinates2('C6');
70+
$drawing4->setOffsetX2($drawing->getImageWidth());
71+
$drawing4->setOffsetY2($drawing->getImageHeight());
72+
$drawing4->setWorksheet($spreadsheet->getActiveSheet());
73+
$drawing4->setEditAs(Drawing::EDIT_AS_ABSOLUTE);
74+
75+
//$spreadsheet->getActiveSheet()->getColumnDimension('C')->setWidth($drawing->getImageWidth(), Dimension::UOM_PIXELS);
76+
$spreadsheet->getActiveSheet()->getRowDimension(6)->setRowHeight($drawing->getImageHeight(), Dimension::UOM_PIXELS);
77+
78+
$helper->write($spreadsheet, __FILE__, ['Xlsx']);

samples/Chart/33_Chart_create_area.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use PhpOffice\PhpSpreadsheet\Chart\Chart;
44
use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
55
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
6-
use PhpOffice\PhpSpreadsheet\Chart\Legend;
6+
use PhpOffice\PhpSpreadsheet\Chart\Legend as ChartLegend;
77
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
88
use PhpOffice\PhpSpreadsheet\Chart\Title;
99
use PhpOffice\PhpSpreadsheet\IOFactory;
@@ -71,7 +71,7 @@
7171
// Set the series in the plot area
7272
$plotArea = new PlotArea(null, [$series]);
7373
// Set the chart legend
74-
$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false);
74+
$legend = new ChartLegend(ChartLegend::POSITION_TOPRIGHT, null, false);
7575

7676
$title = new Title('Test %age-Stacked Area Chart');
7777
$yAxisLabel = new Title('Value ($k)');

samples/Chart/33_Chart_create_bar_stacked.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use PhpOffice\PhpSpreadsheet\Chart\Chart;
44
use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
55
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
6-
use PhpOffice\PhpSpreadsheet\Chart\Legend;
6+
use PhpOffice\PhpSpreadsheet\Chart\Legend as ChartLegend;
77
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
88
use PhpOffice\PhpSpreadsheet\Chart\Title;
99
use PhpOffice\PhpSpreadsheet\IOFactory;
@@ -74,7 +74,7 @@
7474
// Set the series in the plot area
7575
$plotArea = new PlotArea(null, [$series]);
7676
// Set the chart legend
77-
$legend = new Legend(Legend::POSITION_RIGHT, null, false);
77+
$legend = new ChartLegend(ChartLegend::POSITION_RIGHT, null, false);
7878

7979
$title = new Title('Test Chart');
8080
$yAxisLabel = new Title('Value ($k)');

samples/Chart/33_Chart_create_column.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use PhpOffice\PhpSpreadsheet\Chart\Chart;
44
use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
55
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
6-
use PhpOffice\PhpSpreadsheet\Chart\Legend;
6+
use PhpOffice\PhpSpreadsheet\Chart\Legend as ChartLegend;
77
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
88
use PhpOffice\PhpSpreadsheet\Chart\Title;
99
use PhpOffice\PhpSpreadsheet\IOFactory;
@@ -74,7 +74,7 @@
7474
// Set the series in the plot area
7575
$plotArea = new PlotArea(null, [$series]);
7676
// Set the chart legend
77-
$legend = new Legend(Legend::POSITION_RIGHT, null, false);
77+
$legend = new ChartLegend(ChartLegend::POSITION_RIGHT, null, false);
7878

7979
$title = new Title('Test Column Chart');
8080
$yAxisLabel = new Title('Value ($k)');

0 commit comments

Comments
 (0)