You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
26
26
### Fixed
27
27
28
28
- Updates Cell formula absolute ranges/references, and Defined Name absolute ranges/references when inserting/deleting rows/columns [Issue #3368](https://github.com/PHPOffice/PhpSpreadsheet/issues/3368)[PR #3402](https://github.com/PHPOffice/PhpSpreadsheet/pull/3402)
29
+
- EOMONTH() and EDATE() Functions should round date value before evaluation [Issue #3436](https://github.com/PHPOffice/PhpSpreadsheet/issues/3436)[PR #3437](https://github.com/PHPOffice/PhpSpreadsheet/pull/3437)
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+28-7
Original file line number
Diff line number
Diff line change
@@ -2,19 +2,40 @@
2
2
3
3
If you would like to contribute, here are some notes and guidelines:
4
4
5
-
- All new development happens on feature/fix branches, and are then merged to the `master` branch once stable; so the `master` branch is always the most up-to-date, working code
6
-
- Tagged releases are made from the `master` branch
7
-
- If you are going to be submitting a pull request, please fork from `master`, and submit your pull request back as a fix/feature branch referencing the GitHub issue number
8
-
- Code style might be automatically fixed by `composer fix`
9
-
- All code changes must be validated by `composer check`
5
+
- All new development should be on feature/fix branches, which are then merged to the `master` branch once stable and approved; so the `master` branch is always the most up-to-date, working code
6
+
- If you are going to submit a pull request, please fork from `master`, and submit your pull request back as a fix/feature branch referencing the GitHub issue number
7
+
- The code must work with all PHP versions that we support (currently PHP 7.4 to PHP 8.2).
8
+
- You can call `composer versions` to test version compatibility.
9
+
- Code style should be maintained.
10
+
-`composer style` will identify any issues with Coding Style`.
11
+
-`composer fix` will fix most issues with Coding Style.
12
+
- All code changes must be validated by `composer check`.
13
+
- Please include Unit Tests to verify that a bug exists, and that this PR fixes it.
14
+
- Please include Unit Tests to show that a new Feature works as expected.
15
+
- Please don't "bundle" several changes into a single PR; submit a PR for each discrete change/fix.
16
+
10
17
-[Helpful article about forking](https://help.github.com/articles/fork-a-repo/"Forking a GitHub repository")
11
18
-[Helpful article about pull requests](https://help.github.com/articles/using-pull-requests/"Pull Requests")
12
19
20
+
## Unit Tests
21
+
22
+
When writing Unit Tests, please
23
+
- Always try to write Unit Tests for both the happy and unhappy paths.
24
+
- Put all assertions in the Test itself, not in an abstract class that the Test extends (even if this means code duplication between tests).
25
+
- Include any necessary `setup()` and `tearDown()` in the Test itself.
26
+
- If you change any global settings (such as system locale, or Compatibility Mode for Excel Function tests), make sure that you reset to the default in the `tearDown()`.
27
+
28
+
This makes it easier to see exactly what is being tested when reviewing the PR. I want to be able to see it in the PR, not have to hunt in other classes to see what the test is doing.
29
+
13
30
## How to release
14
31
15
32
1. Complete CHANGELOG.md and commit
16
33
2. Create an annotated tag
17
34
1.`git tag -a 1.2.3`
18
35
2. Tag subject must be the version number, eg: `1.2.3`
19
-
3. Tag body must be a copy-paste of the changelog entries
20
-
3. Push tag with `git push --tags`, GitHub Actions will create a GitHub release automatically
36
+
3. Tag body must be a copy-paste of the changelog entries.
37
+
3. Push the tag with `git push --tags`, GitHub Actions will create a GitHub release automatically, and the release details will automatically be sent to packagist.
38
+
4. Github seems to remove markdown headings in the Release Notes, so you should edit to restore these.
39
+
40
+
> **Note:** Tagged releases are made from the `master` branch. Only in an emergency should a tagged release be made from the `release` branch. (i.e. cherry-picked hot-fixes.)
Copy file name to clipboardExpand all lines: docs/index.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ for details.
33
33
LTS: Support for PHP versions will only be maintained for a period of six months beyond the
34
34
[end of life of that PHP version](https://www.php.net/eol.php).
35
35
36
-
Currently the required PHP minimum version is PHP 7.4. The last PHP release was 7.4.32 on 29th September 2022, and security support ends on 28th November 2022, so PhpSpreadsheet will support PHP 7.4 until 28th May 2023.
36
+
Currently the required PHP minimum version is PHP 7.4: the last release was 7.4.32 on 29th September 2022, and security support ends on 28th November 2022, so PhpSpreadsheet will support PHP 7.4 until 28th May 2023.
37
37
PHP 8.0 is officially [End of Life](https://www.php.net/supported-versions.php) on 26th November 2023, and PhpSpreadsheet will continue to support PHP 8.0 for six months after that date.
38
38
39
39
See the `composer.json` for other requirements.
@@ -86,8 +86,8 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
Copy file name to clipboardExpand all lines: docs/topics/recipes.md
+174-11
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ For example, [setting a worksheet's page orientation and size
10
10
orientation to A4. Other paper formats, like US Letter, are not covered
11
11
in this document, but in the PhpSpreadsheet [API documentation](https://phpoffice.github.io/PhpSpreadsheet).
12
12
13
+
My apologies if this documentation seems very basic to some of you; but I spend so much time having to provide help lessons in PHP 101 and Excel 101 that I feel I need to provide this level of very simple detail.
14
+
13
15
## Setting a spreadsheet's metadata
14
16
15
17
PhpSpreadsheet allows an easy way to set a spreadsheet's metadata, using
@@ -18,12 +20,42 @@ finding a specific document in a file repository or a document
18
20
management system. For example Microsoft Sharepoint uses document
19
21
metadata to search for a specific document in its document lists.
20
22
21
-
Setting spreadsheet metadata is done as follows:
23
+
<details>
24
+
<summary>Click here for details of Spreadsheet Document Properties</summary>
25
+
26
+
These are accessed in MS Excel from the "Info" option on the "File" menu:
Properties on the "General", "Statistics" and "Contents" tabs are informational, and cannot be user-defined in Excel itself.
39
+
Properties on the "Summary" tab are all string values.
40
+
41
+
The "Custom" tab allows you to define your own properties. More information from the Microsoft Documentation can be found [here](https://support.microsoft.com/en-us/office/view-or-change-the-properties-for-an-office-file-21d604c2-481e-4379-8e54-1dd4622c6b75).
You can select a property name from the dropdown, or type a new name of your choice; select a Type; enter a value; and then click on "Add".
45
+
The new property will then be created and displayed in the list at the bottom of the form.
46
+
47
+
While "Text", "Number" (can be an integer or a floating point value) and "Yes or No" types are straightforward to add a value, "Date" types are more difficult, and Microsoft provide very little help.
48
+
However, you need to enter the date in the format that matches your locale, so an American would enter "7/4/2023 for the 4th of July; but in the UK I would enter "4/7/2023" for the same date.
49
+
Although typically recognised as a date elsewhere in MS Excel, the almost universally recognised `2022-12-31` date format is not recognised as valid here.
50
+
51
+
</details>
52
+
53
+
Setting spreadsheet metadata in PhpSpreadsheet is done as follows:
Will let you set (or modify) a custom property. If you don't provide a datatype, then PhpSpreadsheet will attempt to identify the datatype from the value that you set.
> **Warning:** If the datatype for a date is not explicitly used, then it will be treated as a string.
139
+
140
+
> **Note:** Although MS Excel doesn't recognise `2022-12-31` as valid date format when entering Custom Date Properties, PhpSpreadsheet will accept it.
141
+
36
142
## Setting a spreadsheet's active sheet
37
143
38
-
The following line of code sets the active sheet index to the first
39
-
sheet:
144
+
A Spreadsheet consists of (very rarely) none, one or more Worksheets. If you have 1 or more Worksheets, then one (and only one) of those Worksheets can be "Active" (viewed or updated) at a time, but there will always be an "Active" Worksheet (unless you explicitly delete all of the Worksheets in the Spreadsheet).
145
+
146
+
<details>
147
+
<summary>Click here for details about Worksheets</summary>
148
+
149
+
When you create a new Spreadsheet in MS Excel, it creates the Spreadsheet with a single Worksheet ("Sheet1")
And you can then write values to Cells in `$activeWorksheet` (`Sheet1`).
165
+
166
+
To create a new Worksheet in MS Excel, you click on the "+" button in the Worksheet Tab Bar. MS Excel will then create a new Worksheet ("Sheet2") in the Spreadsheet, and make that the current "Active" Worksheet.
You can also set the active sheet by its name/title
170
+
Excel always shows the "Active" Worksheet in the Grid, and you can see which Worksheet is "Active" because it is highlighted in the Worksheet Tab Bar at the bottom of the Worksheet Grid.
And you can then write values to Cells in `$activeWorksheet` (`Sheet2`).
179
+
180
+
</details>
181
+
182
+
To switch between Worksheets in MS Excel, you click on the Tab for the Worksheet that you want to be "Active" in the Worksheet Tab Bar. Excel will then set that as the "Active" Worksheet.
50
183
51
-
will change the currently active sheet to the worksheet called
Where you set the "Active" Worksheet by its position in the Worksheet Tab Bar, with 0 as the first Worksheet, 1 as the second, etc.
199
+
200
+
And you can then write values to Cells in `$activeWorksheet` (`Sheet1`) again.
201
+
202
+
203
+
You don't have to assign the return value from calls to `createSheet()` and `setActiveSheetIndex()` to a variable, but it means that you can call Worksheet methods directly against `$activeWorksheet`, rather than having to call `$spreadsheet->getActiveSheet()` all the time.
204
+
And, unlike MS Excel where you can only update Cells in the "Active" Worksheet; PhpSpreadsheet allows you to update Cells in any Worksheet:
205
+
```php
206
+
// Create a Spreadsheet, with Worksheet Sheet1, which is the Active Worksheet
207
+
$spreadsheet = new Spreadsheet();
208
+
// Assign the Active Worksheet (Sheet1) to $worksheet1
209
+
$worksheet1 = $spreadsheet->getActiveSheet();
210
+
// Create a new Worksheet (Sheet2) and make that the Active Worksheet
211
+
$worksheet2 = $spreadsheet->createSheet();
212
+
213
+
$worksheet1->setCellValue('A1', 'I am a cell on Sheet1');
214
+
$worksheet2->setCellValue('A1', 'I am a cell on Sheet2');
215
+
```
53
216
54
217
## Write a date or time into a cell
55
218
@@ -1580,8 +1743,8 @@ Adding rich text to a cell can be done using
1580
1743
`\PhpOffice\PhpSpreadsheet\RichText\RichText` instances. Here''s an example, which
1581
1744
creates the following rich text string:
1582
1745
1583
-
> This invoice is ***payable within thirty days after the end of the
1584
-
> month*** unless specified otherwise on the invoice.
1746
+
> This invoice is <fontcolor="darkgreen">***payable within thirty days after the end of the
1747
+
> month***</font> unless specified otherwise on the invoice.
1585
1748
1586
1749
```php
1587
1750
$richText = new \PhpOffice\PhpSpreadsheet\RichText\RichText();
0 commit comments