Allow HYPERLINK() function to set the tooltip, and add extra examples of setting hyperlinks either through PHPExcel methods or using the HYPERLINK() function

This commit is contained in:
MarkBaker 2016-03-01 12:34:05 +00:00
parent 6a3dd85f6f
commit 352e6ea5cc
2 changed files with 22 additions and 0 deletions

View File

@ -281,6 +281,7 @@ class PHPExcel_Calculation_LookupRef
} }
$pCell->getHyperlink()->setUrl($linkURL); $pCell->getHyperlink()->setUrl($linkURL);
$pCell->getHyperlink()->setTooltip($displayName);
return $displayName; return $displayName;
} }

View File

@ -136,6 +136,27 @@ $objPHPExcel->getActiveSheet()->getStyle("C14")->getAlignment()->setWrapText(tru
$objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true); $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension('C')->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 // Rename worksheet
echo date('H:i:s') , " Rename worksheet" , EOL; echo date('H:i:s') , " Rename worksheet" , EOL;
$objPHPExcel->getActiveSheet()->setTitle('Datatypes'); $objPHPExcel->getActiveSheet()->setTitle('Datatypes');