Skip to content

Commit 4521864

Browse files
committed
Document New Feature
1 parent 76ab794 commit 4521864

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

docs/topics/recipes.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,17 +631,33 @@ $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, you
653+
can mimic Excel's behavior with:
654+
```php
655+
$spreadsheet->getActiveSheet()
656+
->getStyle('E26')
657+
->getFont()
658+
->setHyperlinkTheme();
644659
```
660+
This will set underline (all formats) and text color (Xlsx only).
645661

646662
## Setting Printer Options for Excel files
647663

0 commit comments

Comments
 (0)