From 352e6ea5cc297ddfcfe3cd1af6c3e170691ed4b3 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 1 Mar 2016 12:34:05 +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 --- Classes/PHPExcel/Calculation/LookupRef.php | 1 + Examples/02types.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Classes/PHPExcel/Calculation/LookupRef.php b/Classes/PHPExcel/Calculation/LookupRef.php index d860551..1fe7790 100644 --- a/Classes/PHPExcel/Calculation/LookupRef.php +++ b/Classes/PHPExcel/Calculation/LookupRef.php @@ -281,6 +281,7 @@ class PHPExcel_Calculation_LookupRef } $pCell->getHyperlink()->setUrl($linkURL); + $pCell->getHyperlink()->setTooltip($displayName); return $displayName; } diff --git a/Examples/02types.php b/Examples/02types.php index 6ac11c7..394a73d 100644 --- a/Examples/02types.php +++ b/Examples/02types.php @@ -136,6 +136,27 @@ $objPHPExcel->getActiveSheet()->getStyle("C14")->getAlignment()->setWrapText(tru $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true); +$objRichText3 = new PHPExcel_RichText(); +$objRichText3->createText("Hello "); + +$objUnderlined = $objRichText3->createTextRun("underlined"); +$objUnderlined->getFont()->setUnderline(true); +$objRichText3->createText(' World.'); + +$objPHPExcel->getActiveSheet() + ->getCell("C15") + ->setValue($objRichText3); + + +$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")'); + + // Rename worksheet echo date('H:i:s') , " Rename worksheet" , EOL; $objPHPExcel->getActiveSheet()->setTitle('Datatypes');