Skip to content

Commit 39e5f12

Browse files
authored
Merge branch 'master' into Issue-2924_CellReference-for-Row/Column-Validation
2 parents e050b3b + 09406a6 commit 39e5f12

26 files changed

+874
-228
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ and this project adheres to [Semantic Versioning](https://semver.org).
5050
- Time interval formatting [Issue #2768](https://github.com/PHPOffice/PhpSpreadsheet/issues/2768) [PR #2772](https://github.com/PHPOffice/PhpSpreadsheet/pull/2772)
5151
- Copy from Xls(x) to Html/Pdf loses drawings [PR #2788](https://github.com/PHPOffice/PhpSpreadsheet/pull/2788)
5252
- Html Reader converting cell containing 0 to null string [Issue #2810](https://github.com/PHPOffice/PhpSpreadsheet/issues/2810) [PR #2813](https://github.com/PHPOffice/PhpSpreadsheet/pull/2813)
53-
- Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](https://github.com/PHPOffice/PhpSpreadsheet/issues/2762) [Issue #2299](https://github.com/PHPOffice/PhpSpreadsheet/issues/2299) [Issue #2700](https://github.com/PHPOffice/PhpSpreadsheet/issues/2700) [Issue #2817](https://github.com/PHPOffice/PhpSpreadsheet/issues/2817) [Issue #2763](https://github.com/PHPOffice/PhpSpreadsheet/issues/2763) [Issue #2219](https://github.com/PHPOffice/PhpSpreadsheet/issues/2219) [Issue #2863](https://github.com/PHPOffice/PhpSpreadsheet/issues/2863) [PR #2828](https://github.com/PHPOffice/PhpSpreadsheet/pull/2828) [PR #2841](https://github.com/PHPOffice/PhpSpreadsheet/pull/2841) [PR #2846](https://github.com/PHPOffice/PhpSpreadsheet/pull/2846) [PR #2852](https://github.com/PHPOffice/PhpSpreadsheet/pull/2852) [PR #2856](https://github.com/PHPOffice/PhpSpreadsheet/pull/2856) [PR #2865](https://github.com/PHPOffice/PhpSpreadsheet/pull/2865) [PR #2872](https://github.com/PHPOffice/PhpSpreadsheet/pull/2872) [PR #2879](https://github.com/PHPOffice/PhpSpreadsheet/pull/2879) [PR #2898](https://github.com/PHPOffice/PhpSpreadsheet/pull/2898) [PR #2906](https://github.com/PHPOffice/PhpSpreadsheet/pull/2906) [PR #2922](https://github.com/PHPOffice/PhpSpreadsheet/pull/2922)
53+
- Many fixes for Charts, especially, but not limited to, Scatter, Bubble, and Surface charts. [Issue #2762](https://github.com/PHPOffice/PhpSpreadsheet/issues/2762) [Issue #2299](https://github.com/PHPOffice/PhpSpreadsheet/issues/2299) [Issue #2700](https://github.com/PHPOffice/PhpSpreadsheet/issues/2700) [Issue #2817](https://github.com/PHPOffice/PhpSpreadsheet/issues/2817) [Issue #2763](https://github.com/PHPOffice/PhpSpreadsheet/issues/2763) [Issue #2219](https://github.com/PHPOffice/PhpSpreadsheet/issues/2219) [Issue #2863](https://github.com/PHPOffice/PhpSpreadsheet/issues/2863) [PR #2828](https://github.com/PHPOffice/PhpSpreadsheet/pull/2828) [PR #2841](https://github.com/PHPOffice/PhpSpreadsheet/pull/2841) [PR #2846](https://github.com/PHPOffice/PhpSpreadsheet/pull/2846) [PR #2852](https://github.com/PHPOffice/PhpSpreadsheet/pull/2852) [PR #2856](https://github.com/PHPOffice/PhpSpreadsheet/pull/2856) [PR #2865](https://github.com/PHPOffice/PhpSpreadsheet/pull/2865) [PR #2872](https://github.com/PHPOffice/PhpSpreadsheet/pull/2872) [PR #2879](https://github.com/PHPOffice/PhpSpreadsheet/pull/2879) [PR #2898](https://github.com/PHPOffice/PhpSpreadsheet/pull/2898) [PR #2906](https://github.com/PHPOffice/PhpSpreadsheet/pull/2906) [PR #2922](https://github.com/PHPOffice/PhpSpreadsheet/pull/2922) [PR #2923](https://github.com/PHPOffice/PhpSpreadsheet/pull/2923)
54+
- Adjust both coordinates for two-cell anchors when rows/columns are added/deleted. [Issue #2908](https://github.com/PHPOffice/PhpSpreadsheet/issues/2908) [PR #2909](https://github.com/PHPOffice/PhpSpreadsheet/pull/2909)
55+
- Keep calculated string results below 32K. [PR #2921](https://github.com/PHPOffice/PhpSpreadsheet/pull/2921)
56+
- Filter out illegal Unicode char values FFFE/FFFF. [Issue #2897](https://github.com/PHPOffice/PhpSpreadsheet/issues/2897) [PR #2910](https://github.com/PHPOffice/PhpSpreadsheet/pull/2910)
57+
- Better handling of REF errors and propagation of all errors in Calculation engine. [PR #2902](https://github.com/PHPOffice/PhpSpreadsheet/pull/2902)
5458
- Calculating Engine regexp for Column/Row references when there are multiple quoted worksheet references in the formula [Issue #2874](https://github.com/PHPOffice/PhpSpreadsheet/issues/2874) [PR #2899](https://github.com/PHPOffice/PhpSpreadsheet/pull/2899)
5559

5660
## 1.23.0 - 2022-04-24

phpstan-baseline.neon

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,86 +1110,6 @@ parameters:
11101110
count: 1
11111111
path: src/PhpSpreadsheet/Cell/Coordinate.php
11121112

1113-
-
1114-
message: "#^Call to an undefined method object\\:\\:render\\(\\)\\.$#"
1115-
count: 1
1116-
path: src/PhpSpreadsheet/Chart/Chart.php
1117-
1118-
-
1119-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$legend \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Legend\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Legend\\|null\\.$#"
1120-
count: 1
1121-
path: src/PhpSpreadsheet/Chart/Chart.php
1122-
1123-
-
1124-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$majorGridlines \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines\\|null\\.$#"
1125-
count: 1
1126-
path: src/PhpSpreadsheet/Chart/Chart.php
1127-
1128-
-
1129-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$minorGridlines \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\GridLines\\|null\\.$#"
1130-
count: 1
1131-
path: src/PhpSpreadsheet/Chart/Chart.php
1132-
1133-
-
1134-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$plotArea \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\PlotArea\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\PlotArea\\|null\\.$#"
1135-
count: 1
1136-
path: src/PhpSpreadsheet/Chart/Chart.php
1137-
1138-
-
1139-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$title \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\|null\\.$#"
1140-
count: 1
1141-
path: src/PhpSpreadsheet/Chart/Chart.php
1142-
1143-
-
1144-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$worksheet \\(PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null\\.$#"
1145-
count: 1
1146-
path: src/PhpSpreadsheet/Chart/Chart.php
1147-
1148-
-
1149-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$xAxis \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis\\|null\\.$#"
1150-
count: 1
1151-
path: src/PhpSpreadsheet/Chart/Chart.php
1152-
1153-
-
1154-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$xAxisLabel \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\|null\\.$#"
1155-
count: 1
1156-
path: src/PhpSpreadsheet/Chart/Chart.php
1157-
1158-
-
1159-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$yAxis \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Axis\\|null\\.$#"
1160-
count: 1
1161-
path: src/PhpSpreadsheet/Chart/Chart.php
1162-
1163-
-
1164-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\:\\:\\$yAxisLabel \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\|null\\.$#"
1165-
count: 1
1166-
path: src/PhpSpreadsheet/Chart/Chart.php
1167-
1168-
-
1169-
message: "#^Strict comparison using \\=\\=\\= between PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeriesValues and null will always evaluate to false\\.$#"
1170-
count: 2
1171-
path: src/PhpSpreadsheet/Chart/DataSeries.php
1172-
1173-
-
1174-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Legend\\:\\:\\$layout \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\|null\\.$#"
1175-
count: 1
1176-
path: src/PhpSpreadsheet/Chart/Legend.php
1177-
1178-
-
1179-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Legend\\:\\:\\$positionXLref has no type specified\\.$#"
1180-
count: 1
1181-
path: src/PhpSpreadsheet/Chart/Legend.php
1182-
1183-
-
1184-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\PlotArea\\:\\:\\$layout \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\|null\\.$#"
1185-
count: 1
1186-
path: src/PhpSpreadsheet/Chart/PlotArea.php
1187-
1188-
-
1189-
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Title\\:\\:\\$layout \\(PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\) does not accept PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Layout\\|null\\.$#"
1190-
count: 1
1191-
path: src/PhpSpreadsheet/Chart/Title.php
1192-
11931113
-
11941114
message: "#^Property PhpOffice\\\\PhpSpreadsheet\\\\Collection\\\\Memory\\:\\:\\$cache has no type specified\\.$#"
11951115
count: 1
@@ -3630,11 +3550,6 @@ parameters:
36303550
count: 1
36313551
path: src/PhpSpreadsheet/Writer/Html.php
36323552

3633-
-
3634-
message: "#^Ternary operator condition is always true\\.$#"
3635-
count: 1
3636-
path: src/PhpSpreadsheet/Writer/Html.php
3637-
36383553
-
36393554
message: "#^Negated boolean expression is always false\\.$#"
36403555
count: 1
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
<?php
2+
3+
use PhpOffice\PhpSpreadsheet\Chart\Chart;
4+
use PhpOffice\PhpSpreadsheet\Chart\ChartColor;
5+
use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
6+
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
7+
use PhpOffice\PhpSpreadsheet\Chart\GridLines;
8+
use PhpOffice\PhpSpreadsheet\Chart\Layout;
9+
use PhpOffice\PhpSpreadsheet\Chart\Legend as ChartLegend;
10+
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
11+
use PhpOffice\PhpSpreadsheet\Chart\Properties;
12+
use PhpOffice\PhpSpreadsheet\Chart\Title;
13+
use PhpOffice\PhpSpreadsheet\IOFactory;
14+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
15+
16+
require __DIR__ . '/../Header.php';
17+
18+
$spreadsheet = new Spreadsheet();
19+
$worksheet = $spreadsheet->getActiveSheet();
20+
$worksheet->fromArray(
21+
[
22+
['', 2010, 2011, 2012],
23+
['Q1', 12, 15, 21],
24+
['Q2', 56, 73, 86],
25+
['Q3', 52, 61, 69],
26+
['Q4', 30, 32, 0],
27+
]
28+
);
29+
30+
// Custom colors for dataSeries (gray, blue, red, orange)
31+
$colors = [
32+
'cccccc', '00abb8', 'b8292f', 'eb8500',
33+
];
34+
35+
// Set the Labels for each data series we want to plot
36+
// Datatype
37+
// Cell reference for data
38+
// Format Code
39+
// Number of datapoints in series
40+
// Data values
41+
// Data Marker
42+
$dataSeriesLabels1 = [
43+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
44+
];
45+
// Set the X-Axis Labels
46+
// Datatype
47+
// Cell reference for data
48+
// Format Code
49+
// Number of datapoints in series
50+
// Data values
51+
// Data Marker
52+
$xAxisTickValues1 = [
53+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
54+
];
55+
// Set the Data values for each data series we want to plot
56+
// Datatype
57+
// Cell reference for data
58+
// Format Code
59+
// Number of datapoints in series
60+
// Data values
61+
// Data Marker
62+
// Custom colors
63+
$dataSeriesValues1 = [
64+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4, [], null, $colors),
65+
];
66+
$labelLayout = new Layout();
67+
$labelLayout
68+
->setShowVal(true)
69+
->setLabelFontColor(new ChartColor('FFFF00'))
70+
->setLabelFillColor(new ChartColor('accent2', null, 'schemeClr'));
71+
$dataSeriesValues1[0]->setLabelLayout($labelLayout);
72+
73+
// Build the dataseries
74+
$series1 = new DataSeries(
75+
DataSeries::TYPE_BARCHART, // plotType
76+
null, // plotGrouping (Pie charts don't have any grouping)
77+
range(0, count($dataSeriesValues1) - 1), // plotOrder
78+
$dataSeriesLabels1, // plotLabel
79+
$xAxisTickValues1, // plotCategory
80+
$dataSeriesValues1 // plotValues
81+
);
82+
83+
// Set up a layout object for the Pie chart
84+
$layout1 = new Layout();
85+
$layout1->setShowVal(true);
86+
$layout1->setShowPercent(true);
87+
88+
// Set the series in the plot area
89+
$plotArea1 = new PlotArea($layout1, [$series1]);
90+
// Set the chart legend
91+
$legend1 = new ChartLegend(ChartLegend::POSITION_RIGHT, null, false);
92+
93+
$title1 = new Title('Test Bar Chart');
94+
95+
// Create the chart
96+
$chart1 = new Chart(
97+
'chart1', // name
98+
$title1, // title
99+
$legend1, // legend
100+
$plotArea1, // plotArea
101+
true, // plotVisibleOnly
102+
DataSeries::EMPTY_AS_GAP, // displayBlanksAs
103+
null, // xAxisLabel
104+
null // yAxisLabel - Pie charts don't have a Y-Axis
105+
);
106+
$majorGridlinesY = new GridLines();
107+
$majorGridlinesY->setLineColorProperties('FF0000');
108+
$minorGridlinesY = new GridLines();
109+
$minorGridlinesY->setLineStyleProperty('dash', Properties::LINE_STYLE_DASH_ROUND_DOT);
110+
$chart1
111+
->getChartAxisY()
112+
->setMajorGridlines($majorGridlinesY)
113+
->setMinorGridlines($minorGridlinesY);
114+
$majorGridlinesX = new GridLines();
115+
$majorGridlinesX->setLineColorProperties('FF00FF');
116+
$minorGridlinesX = new GridLines();
117+
$minorGridlinesX->activateObject();
118+
$chart1
119+
->getChartAxisX()
120+
->setMajorGridlines($majorGridlinesX)
121+
->setMinorGridlines($minorGridlinesX);
122+
123+
// Set the position where the chart should appear in the worksheet
124+
$chart1->setTopLeftPosition('A7');
125+
$chart1->setBottomRightPosition('H20');
126+
127+
// Add the chart to the worksheet
128+
$worksheet->addChart($chart1);
129+
130+
// Set the Labels for each data series we want to plot
131+
// Datatype
132+
// Cell reference for data
133+
// Format Code
134+
// Number of datapoints in series
135+
// Data values
136+
// Data Marker
137+
$dataSeriesLabels2 = [
138+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // 2011
139+
];
140+
// Set the X-Axis Labels
141+
// Datatype
142+
// Cell reference for data
143+
// Format Code
144+
// Number of datapoints in series
145+
// Data values
146+
// Data Marker
147+
$xAxisTickValues2 = [
148+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
149+
];
150+
// Set the Data values for each data series we want to plot
151+
// Datatype
152+
// Cell reference for data
153+
// Format Code
154+
// Number of datapoints in series
155+
// Data values
156+
// Data Marker
157+
// Custom colors
158+
$dataSeriesValues2 = [
159+
$dataSeriesValues2Element = new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', null, 4),
160+
];
161+
$dataSeriesValues2Element->setFillColor($colors);
162+
163+
// Build the dataseries
164+
$series2 = new DataSeries(
165+
DataSeries::TYPE_DONUTCHART, // plotType
166+
null, // plotGrouping (Donut charts don't have any grouping)
167+
range(0, count($dataSeriesValues2) - 1), // plotOrder
168+
$dataSeriesLabels2, // plotLabel
169+
$xAxisTickValues2, // plotCategory
170+
$dataSeriesValues2 // plotValues
171+
);
172+
173+
// Set up a layout object for the Pie chart
174+
$layout2 = new Layout();
175+
$layout2->setShowVal(true);
176+
$layout2->setShowCatName(true);
177+
$layout2->setLabelFillColor(new ChartColor('FFFF00'));
178+
179+
// Set the series in the plot area
180+
$plotArea2 = new PlotArea($layout2, [$series2]);
181+
182+
$title2 = new Title('Test Donut Chart');
183+
184+
// Create the chart
185+
$chart2 = new Chart(
186+
'chart2', // name
187+
$title2, // title
188+
null, // legend
189+
$plotArea2, // plotArea
190+
true, // plotVisibleOnly
191+
DataSeries::EMPTY_AS_GAP, // displayBlanksAs
192+
null, // xAxisLabel
193+
null // yAxisLabel - Like Pie charts, Donut charts don't have a Y-Axis
194+
);
195+
196+
// Set the position where the chart should appear in the worksheet
197+
$chart2->setTopLeftPosition('I7');
198+
$chart2->setBottomRightPosition('P20');
199+
200+
// Add the chart to the worksheet
201+
$worksheet->addChart($chart2);
202+
203+
// Save Excel 2007 file
204+
$filename = $helper->getFilename(__FILE__);
205+
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
206+
$writer->setIncludeCharts(true);
207+
$callStartTime = microtime(true);
208+
$writer->save($filename);
209+
$helper->logWrite($writer, $filename, $callStartTime);
38 Bytes
Binary file not shown.

src/PhpSpreadsheet/Chart/Axis.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ public function __construct()
1616
$this->fillColor = new ChartColor();
1717
}
1818

19+
/**
20+
* Chart Major Gridlines as.
21+
*
22+
* @var ?GridLines
23+
*/
24+
private $majorGridlines;
25+
26+
/**
27+
* Chart Minor Gridlines as.
28+
*
29+
* @var ?GridLines
30+
*/
31+
private $minorGridlines;
32+
1933
/**
2034
* Axis Number.
2135
*
@@ -235,4 +249,28 @@ public function getCrossBetween(): string
235249
{
236250
return $this->crossBetween;
237251
}
252+
253+
public function getMajorGridlines(): ?GridLines
254+
{
255+
return $this->majorGridlines;
256+
}
257+
258+
public function getMinorGridlines(): ?GridLines
259+
{
260+
return $this->minorGridlines;
261+
}
262+
263+
public function setMajorGridlines(?GridLines $gridlines): self
264+
{
265+
$this->majorGridlines = $gridlines;
266+
267+
return $this;
268+
}
269+
270+
public function setMinorGridlines(?GridLines $gridlines): self
271+
{
272+
$this->minorGridlines = $gridlines;
273+
274+
return $this;
275+
}
238276
}

0 commit comments

Comments
 (0)