Skip to content

Commit 9b3c3f4

Browse files
author
MarkBaker
committed
Merge branch 'master' into Xls-Reader-Conditional-Formatting
2 parents cb5a451 + 178f748 commit 9b3c3f4

38 files changed

+1225
-612
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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3939

4040
### Fixed
4141

42+
- 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)
43+
- Allow `INDIRECT()` to accept row/column ranges as well as cell ranges [PR #2687](https://github.com/PHPOffice/PhpSpreadsheet/pull/2687)
44+
- Fix bug when deleting cells with hyperlinks, where the hyperlink was then being "inherited" by whatever cell moved to that cell address.
4245
- Fix bug in Conditional Formatting in the Xls Writer that resulted in a broken file when there were multiple conditional ranges in a worksheet.
4346
- Fix Conditional Formatting in the Xls Writer to work with rules that contain string literals, cell references and formulae.
4447
- 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)

phpstan-baseline.neon

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,31 +3165,11 @@ parameters:
31653165
count: 1
31663166
path: src/PhpSpreadsheet/ReferenceHelper.php
31673167

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-
31833168
-
31843169
message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, string\\|null given\\.$#"
31853170
count: 1
31863171
path: src/PhpSpreadsheet/ReferenceHelper.php
31873172

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-
31933173
-
31943174
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\Run\\:\\:\\$font \\(PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\Font\\|null\\.$#"
31953175
count: 1
@@ -4240,26 +4220,6 @@ parameters:
42404220
count: 1
42414221
path: src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php
42424222

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-
42634223
-
42644224
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\CellIterator\\:\\:adjustForExistingOnlyRange\\(\\) has no return type specified\\.$#"
42654225
count: 1
@@ -5270,36 +5230,6 @@ parameters:
52705230
count: 2
52715231
path: src/PhpSpreadsheet/Writer/Xlsx/DocProps.php
52725232

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-
53035233
-
53045234
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Rels\\:\\:writeUnparsedRelationship\\(\\) has parameter \\$relationship with no type specified\\.$#"
53055235
count: 1
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)');

samples/Chart/33_Chart_create_column_2.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;
@@ -82,7 +82,7 @@
8282
// Set the series in the plot area
8383
$plotArea = new PlotArea(null, [$series]);
8484
// Set the chart legend
85-
$legend = new Legend(Legend::POSITION_BOTTOM, null, false);
85+
$legend = new ChartLegend(ChartLegend::POSITION_BOTTOM, null, false);
8686

8787
$title = new Title('Test Grouped Column Chart');
8888
$xAxisLabel = new Title('Financial Period');

samples/Chart/33_Chart_create_composite.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;
@@ -128,7 +128,7 @@
128128
// Set the series in the plot area
129129
$plotArea = new PlotArea(null, [$series1, $series2, $series3]);
130130
// Set the chart legend
131-
$legend = new Legend(Legend::POSITION_RIGHT, null, false);
131+
$legend = new ChartLegend(ChartLegend::POSITION_RIGHT, null, false);
132132

133133
$title = new Title('Average Weather Chart for Crete');
134134

samples/Chart/33_Chart_create_line.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;
@@ -72,7 +72,7 @@
7272
// Set the series in the plot area
7373
$plotArea = new PlotArea(null, [$series]);
7474
// Set the chart legend
75-
$legend = new Legend(Legend::POSITION_TOPRIGHT, null, false);
75+
$legend = new ChartLegend(ChartLegend::POSITION_TOPRIGHT, null, false);
7676

7777
$title = new Title('Test Stacked Line Chart');
7878
$yAxisLabel = new Title('Value ($k)');

0 commit comments

Comments
 (0)