Skip to content

Commit 345c0eb

Browse files
authored
Merge branch 'master' into TextFunctions-New
2 parents 88bfa98 + c0809b0 commit 345c0eb

Some content is hidden

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

43 files changed

+1439
-185
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ If this is an issue with reading a specific spreadsheet file, then it may be app
3434
- [ ] Writer
3535
- [ ] Styles
3636
- [ ] Data Validations
37-
- [ ] Formula Calulations
37+
- [ ] Formula Calculations
3838
- [ ] Charts
3939
- [ ] AutoFilter
4040
- [ ] Form Elements

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,35 @@ and this project adheres to [Semantic Versioning](https://semver.org).
2525

2626
### Fixed
2727

28+
- Fully flatten an array [Issue #2955](https://github.com/PHPOffice/PhpSpreadsheet/issues/2955) [PR #2956](https://github.com/PHPOffice/PhpSpreadsheet/pull/2956)
29+
30+
## 1.24.1 - 2022-07-18
31+
32+
### Added
33+
34+
- Add Chart Axis Option textRotation [Issue #2705](https://github.com/PHPOffice/PhpSpreadsheet/issues/2705) [PR #2940](https://github.com/PHPOffice/PhpSpreadsheet/pull/2940)
35+
36+
### Changed
37+
38+
- Nothing
39+
40+
### Deprecated
41+
2842
- Nothing
2943

44+
### Removed
45+
46+
- Nothing
47+
48+
### Fixed
49+
50+
- Fix Encoding issue with Html reader (PHP 8.2 deprecation for mb_convert_encoding) [Issue #2942](https://github.com/PHPOffice/PhpSpreadsheet/issues/2942) [PR #2943](https://github.com/PHPOffice/PhpSpreadsheet/pull/2943)
51+
- Additional Chart fixes
52+
- Pie chart with part separated unwantedly [Issue #2506](https://github.com/PHPOffice/PhpSpreadsheet/issues/2506) [PR #2928](https://github.com/PHPOffice/PhpSpreadsheet/pull/2928)
53+
- Chart styling is lost on simple load / save process [Issue #1797](https://github.com/PHPOffice/PhpSpreadsheet/issues/1797) [Issue #2077](https://github.com/PHPOffice/PhpSpreadsheet/issues/2077) [PR #2930](https://github.com/PHPOffice/PhpSpreadsheet/pull/2930)
54+
- Can't create contour chart (surface 2d) [Issue #2931](https://github.com/PHPOffice/PhpSpreadsheet/issues/2931) [PR #2933](https://github.com/PHPOffice/PhpSpreadsheet/pull/2933)
55+
- VLOOKUP Breaks When Array Contains Null Cells [Issue #2934](https://github.com/PHPOffice/PhpSpreadsheet/issues/2934) [PR #2939](https://github.com/PHPOffice/PhpSpreadsheet/pull/2939)
56+
3057
## 1.24.0 - 2022-07-09
3158

3259
Note that this will be the last 1.x branch release before the 2.x release. We will maintain both branches in parallel for a time; but users are requested to update to version 2.0 once that is fully available.

phpstan-baseline.neon

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,11 +2860,6 @@ parameters:
28602860
count: 1
28612861
path: src/PhpSpreadsheet/Spreadsheet.php
28622862

2863-
-
2864-
message: "#^Comparison operation \"\\<\\=\" between int\\<min, \\-1\\> and 1000 is always true\\.$#"
2865-
count: 1
2866-
path: src/PhpSpreadsheet/Spreadsheet.php
2867-
28682863
-
28692864
message: "#^Parameter \\#1 \\$worksheet of method PhpOffice\\\\PhpSpreadsheet\\\\Spreadsheet\\:\\:getIndex\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet, PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\|null given\\.$#"
28702865
count: 1
@@ -2875,21 +2870,11 @@ parameters:
28752870
count: 1
28762871
path: src/PhpSpreadsheet/Spreadsheet.php
28772872

2878-
-
2879-
message: "#^Result of \\|\\| is always true\\.$#"
2880-
count: 1
2881-
path: src/PhpSpreadsheet/Spreadsheet.php
2882-
28832873
-
28842874
message: "#^Strict comparison using \\=\\=\\= between PhpOffice\\\\PhpSpreadsheet\\\\Spreadsheet and null will always evaluate to false\\.$#"
28852875
count: 1
28862876
path: src/PhpSpreadsheet/Spreadsheet.php
28872877

2888-
-
2889-
message: "#^Strict comparison using \\=\\=\\= between string and null will always evaluate to false\\.$#"
2890-
count: 1
2891-
path: src/PhpSpreadsheet/Spreadsheet.php
2892-
28932878
-
28942879
message: "#^Unreachable statement \\- code above always terminates\\.$#"
28952880
count: 1

samples/Chart/33_Chart_create_scatter2.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
$xAxis = new Axis();
125125
//$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE );
126126
$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true);
127+
$xAxis->setAxisOption('textRotation', '45');
127128

128129
$yAxis = new Axis();
129130
$yAxis->setLineStyleProperties(
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<?php
2+
3+
use PhpOffice\PhpSpreadsheet\Chart\Axis;
4+
use PhpOffice\PhpSpreadsheet\Chart\Chart;
5+
use PhpOffice\PhpSpreadsheet\Chart\ChartColor;
6+
use PhpOffice\PhpSpreadsheet\Chart\DataSeries;
7+
use PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues;
8+
use PhpOffice\PhpSpreadsheet\Chart\Legend as ChartLegend;
9+
use PhpOffice\PhpSpreadsheet\Chart\PlotArea;
10+
use PhpOffice\PhpSpreadsheet\Chart\Properties;
11+
use PhpOffice\PhpSpreadsheet\Chart\Title;
12+
use PhpOffice\PhpSpreadsheet\IOFactory;
13+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
14+
15+
require __DIR__ . '/../Header.php';
16+
17+
$spreadsheet = new Spreadsheet();
18+
$worksheet = $spreadsheet->getActiveSheet();
19+
// changed data to simulate a trend chart - Xaxis are dates; Yaxis are 3 meausurements from each date
20+
$worksheet->fromArray(
21+
[
22+
['', 'metric1', 'metric2', 'metric3'],
23+
['=DATEVALUE("2021-01-01")', 12.1, 15.1, 21.1],
24+
['=DATEVALUE("2021-01-04")', 56.2, 73.2, 86.2],
25+
['=DATEVALUE("2021-01-07")', 52.2, 61.2, 69.2],
26+
['=DATEVALUE("2021-01-10")', 30.2, 32.2, 0.2],
27+
]
28+
);
29+
$worksheet->getStyle('A2:A5')->getNumberFormat()->setFormatCode(Properties::FORMAT_CODE_DATE_ISO8601);
30+
$worksheet->getColumnDimension('A')->setAutoSize(true);
31+
$worksheet->setSelectedCells('A1');
32+
33+
// Set the Labels for each data series we want to plot
34+
// Datatype
35+
// Cell reference for data
36+
// Format Code
37+
// Number of datapoints in series
38+
// Data values
39+
// Data Marker
40+
$dataSeriesLabels = [
41+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$B$1', null, 1), // was 2010
42+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$C$1', null, 1), // was 2011
43+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$D$1', null, 1), // was 2012
44+
];
45+
// Set the X-Axis Labels
46+
// changed from STRING to NUMBER
47+
// added 2 additional x-axis values associated with each of the 3 metrics
48+
// added FORMATE_CODE_NUMBER
49+
$xAxisTickValues = [
50+
//new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_STRING, 'Worksheet!$A$2:$A$5', null, 4), // Q1 to Q4
51+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$A$2:$A$5', Properties::FORMAT_CODE_DATE, 4),
52+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$A$2:$A$5', Properties::FORMAT_CODE_DATE, 4),
53+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$A$2:$A$5', Properties::FORMAT_CODE_DATE, 4),
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+
// added FORMAT_CODE_NUMBER
63+
$dataSeriesValues = [
64+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$B$2:$B$5', Properties::FORMAT_CODE_NUMBER, 4),
65+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$C$2:$C$5', Properties::FORMAT_CODE_NUMBER, 4),
66+
new DataSeriesValues(DataSeriesValues::DATASERIES_TYPE_NUMBER, 'Worksheet!$D$2:$D$5', Properties::FORMAT_CODE_NUMBER, 4),
67+
];
68+
69+
// series 1
70+
// marker details
71+
$dataSeriesValues[0]
72+
->setPointMarker('diamond')
73+
->setPointSize(5)
74+
->getMarkerFillColor()
75+
->setColorProperties('0070C0', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
76+
$dataSeriesValues[0]
77+
->getMarkerBorderColor()
78+
->setColorProperties('002060', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
79+
80+
// line details - smooth line, connected
81+
$dataSeriesValues[0]
82+
->setScatterLines(true)
83+
->setSmoothLine(true)
84+
->setLineColorProperties('accent1', 40, ChartColor::EXCEL_COLOR_TYPE_SCHEME); // value, alpha, type
85+
$dataSeriesValues[0]->setLineStyleProperties(
86+
2.5, // width in points
87+
Properties::LINE_STYLE_COMPOUND_TRIPLE, // compound
88+
Properties::LINE_STYLE_DASH_SQUARE_DOT, // dash
89+
Properties::LINE_STYLE_CAP_SQUARE, // cap
90+
Properties::LINE_STYLE_JOIN_MITER, // join
91+
Properties::LINE_STYLE_ARROW_TYPE_OPEN, // head type
92+
Properties::LINE_STYLE_ARROW_SIZE_4, // head size preset index
93+
Properties::LINE_STYLE_ARROW_TYPE_ARROW, // end type
94+
Properties::LINE_STYLE_ARROW_SIZE_6 // end size preset index
95+
);
96+
97+
// series 2 - straight line - no special effects, connected, straight line
98+
$dataSeriesValues[1] // square fill
99+
->setPointMarker('square')
100+
->setPointSize(6)
101+
->getMarkerBorderColor()
102+
->setColorProperties('accent6', 3, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
103+
$dataSeriesValues[1] // square border
104+
->getMarkerFillColor()
105+
->setColorProperties('0FFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
106+
$dataSeriesValues[1]
107+
->setScatterLines(true)
108+
->setSmoothLine(false)
109+
->setLineColorProperties('FF0000', 80, ChartColor::EXCEL_COLOR_TYPE_RGB);
110+
$dataSeriesValues[1]->setLineWidth(2.0);
111+
112+
// series 3 - markers, no line
113+
$dataSeriesValues[2] // triangle fill
114+
//->setPointMarker('triangle') // let Excel choose shape
115+
->setPointSize(7)
116+
->getMarkerFillColor()
117+
->setColorProperties('FFFF00', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
118+
$dataSeriesValues[2] // triangle border
119+
->getMarkerBorderColor()
120+
->setColorProperties('accent4', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME);
121+
$dataSeriesValues[2]->setScatterLines(false); // points not connected
122+
123+
// Added so that Xaxis shows dates instead of Excel-equivalent-year1900-numbers
124+
$xAxis = new Axis();
125+
//$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE );
126+
$xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601, true);
127+
$xAxis->setAxisOption('textRotation', '45');
128+
$xAxis->setAxisOption('hidden', '1');
129+
130+
$yAxis = new Axis();
131+
$yAxis->setLineStyleProperties(
132+
2.5, // width in points
133+
Properties::LINE_STYLE_COMPOUND_SIMPLE,
134+
Properties::LINE_STYLE_DASH_DASH_DOT,
135+
Properties::LINE_STYLE_CAP_FLAT,
136+
Properties::LINE_STYLE_JOIN_BEVEL
137+
);
138+
$yAxis->setLineColorProperties('ffc000', null, ChartColor::EXCEL_COLOR_TYPE_RGB);
139+
$yAxis->setAxisOption('hidden', '1');
140+
141+
// Build the dataseries
142+
$series = new DataSeries(
143+
DataSeries::TYPE_SCATTERCHART, // plotType
144+
null, // plotGrouping (Scatter charts don't have any grouping)
145+
range(0, count($dataSeriesValues) - 1), // plotOrder
146+
$dataSeriesLabels, // plotLabel
147+
$xAxisTickValues, // plotCategory
148+
$dataSeriesValues, // plotValues
149+
null, // plotDirection
150+
false, // smooth line
151+
DataSeries::STYLE_SMOOTHMARKER // plotStyle
152+
);
153+
154+
// Set the series in the plot area
155+
$plotArea = new PlotArea(null, [$series]);
156+
$plotArea->setNoFill(true);
157+
// Set the chart legend
158+
$legend = new ChartLegend(ChartLegend::POSITION_TOPRIGHT, null, false);
159+
160+
$title = new Title('Test Scatter Trend Chart');
161+
//$yAxisLabel = new Title('Value ($k)');
162+
163+
// Create the chart
164+
$chart = new Chart(
165+
'chart1', // name
166+
$title, // title
167+
$legend, // legend
168+
$plotArea, // plotArea
169+
true, // plotVisibleOnly
170+
DataSeries::EMPTY_AS_GAP, // displayBlanksAs
171+
null, // xAxisLabel
172+
null, //$yAxisLabel, // yAxisLabel
173+
// added xAxis for correct date display
174+
$xAxis, // xAxis
175+
$yAxis, // yAxis
176+
);
177+
$chart->setNoFill(true);
178+
179+
// Set the position where the chart should appear in the worksheet
180+
$chart->setTopLeftPosition('A7');
181+
$chart->setBottomRightPosition('P20');
182+
// Add the chart to the worksheet
183+
$worksheet->addChart($chart);
184+
185+
// Save Excel 2007 file
186+
$filename = $helper->getFilename(__FILE__);
187+
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
188+
$writer->setIncludeCharts(true);
189+
$callStartTime = microtime(true);
190+
$writer->save($filename);
191+
$spreadsheet->disconnectWorksheets();
192+
$helper->logWrite($writer, $filename, $callStartTime);

0 commit comments

Comments
 (0)