From fa98c373df234902df0367f3c3519d04d2de58cc Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 1 Mar 2016 12:33:50 +0000 Subject: [PATCH] Allow HYPERLINK() function to set the tooltip, and add extra examples of setting hyperlinks either through PHPExcel methods or using the HYPERLINK() function --- Examples/02types.php | 9 +++++++++ src/PhpSpreadsheet/Calculation/LookupRef.php | 1 + 2 files changed, 10 insertions(+) diff --git a/Examples/02types.php b/Examples/02types.php index ea075f8d..58c68670 100644 --- a/Examples/02types.php +++ b/Examples/02types.php @@ -162,6 +162,15 @@ $objPHPExcel->getActiveSheet() ->getAlignment()->setWrapText(true); +$objPHPExcel->getActiveSheet()->setCellValue('A17', 'Hyperlink'); + +$objPHPExcel->getActiveSheet()->setCellValue('C17', 'www.phpexcel.net'); +$objPHPExcel->getActiveSheet()->getCell('C17')->getHyperlink()->setUrl('http://www.phpexcel.net'); +$objPHPExcel->getActiveSheet()->getCell('C17')->getHyperlink()->setTooltip('Navigate to website'); + +$objPHPExcel->getActiveSheet()->setCellValue('C18', '=HYPERLINK("mailto:abc@def.com","abc@def.com")'); + + $objPHPExcel->getActiveSheet() ->getColumnDimension('B') ->setAutoSize(true); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index bd12eecc..22662835 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -274,6 +274,7 @@ class LookupRef } $pCell->getHyperlink()->setUrl($linkURL); + $pCell->getHyperlink()->setTooltip($displayName); return $displayName; }