Skip to content

Commit 1700100

Browse files
authored
Merge branch 'master' into issue4476
2 parents dbca68c + 3bb10ff commit 1700100

Some content is hidden

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

65 files changed

+1326
-165
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3434
- Print Area and Row Break. [Issue #1275](https://github.com/PHPOffice/PhpSpreadsheet/issues/1275) [PR #4450](https://github.com/PHPOffice/PhpSpreadsheet/pull/4450)
3535
- Copy Styles after insertNewColumnBefore. [Issue #1425](https://github.com/PHPOffice/PhpSpreadsheet/issues/1425) [PR #4468](https://github.com/PHPOffice/PhpSpreadsheet/pull/4468)
3636
- Xls Writer Treat Hyperlink Starting with # as Internal. [Issue #56](https://github.com/PHPOffice/PhpSpreadsheet/issues/56) [PR #4453](https://github.com/PHPOffice/PhpSpreadsheet/pull/4453)
37-
- ODS Handling of Ceiling and Floor. [Issue #407](https://github.com/PHPOffice/PhpSpreadsheet/issues/407) [PR #4466](https://github.com/PHPOffice/PhpSpreadsheet/pull/4466)
3837
- More Precision for Float to String Casts. [Issue #3899](https://github.com/PHPOffice/PhpSpreadsheet/issues/3899) [PR #4479](https://github.com/PHPOffice/PhpSpreadsheet/pull/4479)
38+
- Hyperlink Styles. [Issue #1632](https://github.com/PHPOffice/PhpSpreadsheet/issues/1632) [PR #4478](https://github.com/PHPOffice/PhpSpreadsheet/pull/4478)
39+
- ODS Handling of Ceiling and Floor. [Issue #477](https://github.com/PHPOffice/PhpSpreadsheet/issues/407) [PR #4466](https://github.com/PHPOffice/PhpSpreadsheet/pull/4466)
40+
- Xlsx Reader Do Not Process Printer Settings for Dataonly. [Issue #4477](https://github.com/PHPOffice/PhpSpreadsheet/issues/4477) [PR #4480](https://github.com/PHPOffice/PhpSpreadsheet/pull/4480)
3941

4042
## 2025-04-16 - 4.2.0
4143

bin/generate-document.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,20 @@
1111

1212
file_put_contents(
1313
__DIR__ . '/../docs/references/function-list-by-category.md',
14-
DocumentGenerator::generateFunctionListByCategory($phpSpreadsheetFunctions)
14+
DocumentGenerator::generateFunctionListByCategory(
15+
$phpSpreadsheetFunctions
16+
)
1517
);
1618
file_put_contents(
1719
__DIR__ . '/../docs/references/function-list-by-name.md',
18-
DocumentGenerator::generateFunctionListByName($phpSpreadsheetFunctions)
20+
DocumentGenerator::generateFunctionListByName(
21+
$phpSpreadsheetFunctions
22+
)
23+
);
24+
file_put_contents(
25+
__DIR__ . '/../docs/references/function-list-by-name-compact.md',
26+
DocumentGenerator::generateFunctionListByName(
27+
$phpSpreadsheetFunctions,
28+
true
29+
)
1930
);

docs/references/function-list-by-name-compact.md

Lines changed: 663 additions & 0 deletions
Large diffs are not rendered by default.

docs/references/function-list-by-name.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Function list by name
22

3+
A more compact list can be found [here](./function-list-by-name-compact.md)
4+
5+
36
## A
47

58
Excel Function | Category | PhpSpreadsheet Function

docs/topics/recipes.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ finding a specific document in a file repository or a document
2020
management system. For example Microsoft Sharepoint uses document
2121
metadata to search for a specific document in its document lists.
2222

23-
<details>
23+
<details markdown>
2424
<summary>Click here for details of Spreadsheet Document Properties</summary>
2525

2626
These are accessed in MS Excel from the "Info" option on the "File" menu:
@@ -67,7 +67,7 @@ $spreadsheet->getProperties()
6767

6868
You can choose which properties to set or ignore.
6969

70-
<details>
70+
<details markdown>
7171
<summary>Click here for details of Property Getters/Setters</summary>
7272

7373
PhpSpreadsheet provides specific getters/setters for a number of pre-defined properties.
@@ -90,7 +90,7 @@ PhpSpreadsheet provides specific getters/setters for a number of pre-defined pro
9090
9191
</details>
9292

93-
<details>
93+
<details markdown>
9494
<summary>Click here for details of Custom Properties</summary>
9595

9696
Additionally, PhpSpreadsheet supports the creation and reading of custom properties for those file formats that accept custom properties.
@@ -143,7 +143,7 @@ $spreadsheet->getProperties()
143143

144144
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).
145145

146-
<details>
146+
<details markdown>
147147
<summary>Click here for details about Worksheets</summary>
148148

149149
When you create a new Spreadsheet in MS Excel, it creates the Spreadsheet with a single Worksheet ("Sheet1")
@@ -278,7 +278,7 @@ define your own values as long as they are a valid MS Excel format.
278278
PhpSpreadsheet also provides a number of Wizards to help you create
279279
Date, Time and DateTime format masks.
280280

281-
<details>
281+
<details markdown>
282282
<summary>Click here for an example of the Date/Time Wizards</summary>
283283

284284
```php
@@ -631,17 +631,35 @@ $spreadsheet->getActiveSheet()->getCell('A1')
631631
You can make a cell a clickable URL by setting its hyperlink property:
632632

633633
```php
634-
$spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
635-
$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('https://www.example.com');
634+
$spreadsheet->getActiveSheet()->setCellValue('E26', 'www.example.com');
635+
$spreadsheet->getActiveSheet()->getCell('E26')
636+
->getHyperlink()
637+
->setUrl('https://www.example.com');
636638
```
637639

638640
If you want to make a hyperlink to another worksheet/cell, use the
639641
following code:
640642

641643
```php
642-
$spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
643-
$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl("sheet://'Sheetname'!A1");
644+
$spreadsheet->getActiveSheet()
645+
->setCellValue('E27', 'go to another sheet');
646+
$spreadsheet->getActiveSheet()->getCell('E27')
647+
->getHyperlink()
648+
->setUrl("sheet://'Sheetname'!A1");
649+
```
650+
651+
Excel automatically supplies a special style when a hyperlink is
652+
entered into a cell. PhpSpreadsheet cannot do so. However,
653+
starting with release 4.3,
654+
you can mimic Excel's behavior with:
655+
```php
656+
$spreadsheet->getActiveSheet()
657+
->getStyle('E26')
658+
->getFont()
659+
->setHyperlinkTheme();
644660
```
661+
This will set underline (all formats) and text color (always
662+
for Xlsx, and usually for other formats).
645663

646664
## Setting Printer Options for Excel files
647665

@@ -824,7 +842,9 @@ $drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooterDrawing();
824842
$drawing->setName('PhpSpreadsheet logo');
825843
$drawing->setPath('./images/PhpSpreadsheet_logo.png');
826844
$drawing->setHeight(36);
827-
$spreadsheet->getActiveSheet()->getHeaderFooter()->addImage($drawing, \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter::IMAGE_HEADER_LEFT);
845+
$spreadsheet->getActiveSheet()
846+
->getHeaderFooter()
847+
->addImage($drawing, \PhpOffice\PhpSpreadsheet\Worksheet\HeaderFooter::IMAGE_HEADER_LEFT);
828848
```
829849

830850
### Setting printing breaks on a row or column
@@ -2018,7 +2038,11 @@ $richText->createText('This invoice is ');
20182038
$payable = $richText->createTextRun('payable within thirty days after the end of the month');
20192039
$payable->getFont()->setBold(true);
20202040
$payable->getFont()->setItalic(true);
2021-
$payable->getFont()->setColor( new \PhpOffice\PhpSpreadsheet\Style\Color( \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN ) );
2041+
$payable->getFont()->setColor(
2042+
new \PhpOffice\PhpSpreadsheet\Style\Color(
2043+
\PhpOffice\PhpSpreadsheet\Style\Color::COLOR_DARKGREEN
2044+
)
2045+
);
20222046
$richText->createText(', unless specified otherwise on the invoice.');
20232047
$spreadsheet->getActiveSheet()->getCell('A18')->setValue($richText);
20242048
```

docs/topics/settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ then the `setLocale()` method will return an error, and American English
4242
More details of the features available once a locale has been set,
4343
including a list of the languages and locales currently supported, can
4444
be found in [Locale Settings for
45-
Formulae](./recipes.md#locale-settings-for-formulae).
45+
Formulas](./recipes.md#locale-settings-for-formulas).
4646

4747
## HTTP client
4848

infra/DocumentGenerator.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,30 @@ private static function getPhpSpreadsheetFunctionText(mixed $functionCall): stri
9191
/**
9292
* @param array<string, array{category: string, functionCall: string|string[], argumentCount: string, passCellReference?: bool, passByReference?: bool[], custom?: bool}> $phpSpreadsheetFunctions
9393
*/
94-
public static function generateFunctionListByName(array $phpSpreadsheetFunctions): string
94+
public static function generateFunctionListByName(array $phpSpreadsheetFunctions, bool $compact = false): string
9595
{
9696
$categoryConstants = array_flip(self::getCategories());
97-
$result = "# Function list by name\n";
97+
if ($compact) {
98+
$result = "# Function list by name compact\n";
99+
$result .= "\n";
100+
$result .= 'Category should be prefixed by `CATEGORY_` to match the values in \PhpOffice\PhpSpreadsheet\Calculation\Category';
101+
$result .= "\n\n";
102+
$result .= 'Function should be prefixed by `PhpOffice\PhpSpreadsheet\Calculation\`';
103+
$result .= "\n\n";
104+
$result .= 'A less compact list can be found [here](./function-list-by-name.md)';
105+
$result .= "\n\n";
106+
} else {
107+
$result = "# Function list by name\n";
108+
$result .= "\n";
109+
$result .= 'A more compact list can be found [here](./function-list-by-name-compact.md)';
110+
$result .= "\n\n";
111+
}
98112
$lastAlphabet = null;
113+
$lengths = $compact ? [25, 22, 37] : [25, 31, 37];
99114
foreach ($phpSpreadsheetFunctions as $excelFunction => $functionInfo) {
100115
if (in_array($excelFunction, self::EXCLUDED_FUNCTIONS, true)) {
101116
continue;
102117
}
103-
$lengths = [25, 31, 37];
104118
if ($lastAlphabet !== $excelFunction[0]) {
105119
$lastAlphabet = $excelFunction[0];
106120
$result .= "\n";
@@ -111,6 +125,14 @@ public static function generateFunctionListByName(array $phpSpreadsheetFunctions
111125
}
112126
$category = $categoryConstants[$functionInfo['category']];
113127
$phpFunction = self::getPhpSpreadsheetFunctionText($functionInfo['functionCall']);
128+
if ($compact) {
129+
$category = str_replace('CATEGORY_', '', $category);
130+
$phpFunction = str_replace(
131+
'\PhpOffice\PhpSpreadsheet\Calculation\\',
132+
'',
133+
$phpFunction
134+
);
135+
}
114136
$result .= self::tableRow($lengths, [$excelFunction, $category, $phpFunction]) . "\n";
115137
}
116138

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ extra_css:
77
- extra/extra.css
88
extra_javascript:
99
- extra/extrajs.js
10+
markdown_extensions:
11+
- md_in_html

samples/Basic/02_Types.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@
142142
->getHyperlink()
143143
->setUrl('https://github.com/PHPOffice/PhpSpreadsheet')
144144
->setTooltip('Navigate to PhpSpreadsheet website');
145+
$spreadsheet->getActiveSheet()->getStyle('C17')->getFont()->setHyperlinkTheme();
145146

146147
$spreadsheet->getActiveSheet()
147148
->setCellValue('C18', '=HYPERLINK("mailto:abc@def.com","abc@def.com")');
149+
$spreadsheet->getActiveSheet()->getStyle('C18')->getFont()->setHyperlinkTheme();
148150

149151
$spreadsheet->getActiveSheet()
150152
->setCellValue('A20', 'String')

samples/templates/sampleSpreadsheet.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,18 @@
248248

249249
// Add a hyperlink to the sheet
250250
$helper->log('Add a hyperlink to an external website');
251-
$spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
251+
$spreadsheet->getActiveSheet()->setCellValue('E26', 'www.example.com');
252252
$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('https://www.example.com');
253253
$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setTooltip('Navigate to website');
254254
$spreadsheet->getActiveSheet()->getStyle('E26')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
255+
$spreadsheet->getActiveSheet()->getStyle('E26')->getFont()->setHyperlinkTheme();
255256

256257
$helper->log('Add a hyperlink to another cell on a different worksheet within the workbook');
257258
$spreadsheet->getActiveSheet()->setCellValue('E27', 'Terms and conditions');
258259
$spreadsheet->getActiveSheet()->getCell('E27')->getHyperlink()->setUrl("sheet://'Terms and conditions'!A1");
259260
$spreadsheet->getActiveSheet()->getCell('E27')->getHyperlink()->setTooltip('Review terms and conditions');
260261
$spreadsheet->getActiveSheet()->getStyle('E27')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_RIGHT);
262+
$spreadsheet->getActiveSheet()->getStyle('E27')->getFont()->setHyperlinkTheme();
261263

262264
// Add a drawing to the worksheet
263265
$helper->log('Add a drawing to the worksheet');

0 commit comments

Comments
 (0)