From 243e4760fe22aa9c524a5d4bb2ddcc2def8493aa Mon Sep 17 00:00:00 2001 From: daveherman71 Date: Wed, 18 Oct 2023 11:02:50 +0200 Subject: [PATCH] Add support for cell hyperlinks via _excel-link attribute --- lib/HtmlPhpExcel/HtmlPhpExcel.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/HtmlPhpExcel/HtmlPhpExcel.php b/lib/HtmlPhpExcel/HtmlPhpExcel.php index 285f500..e797a9c 100644 --- a/lib/HtmlPhpExcel/HtmlPhpExcel.php +++ b/lib/HtmlPhpExcel/HtmlPhpExcel.php @@ -227,6 +227,12 @@ private function createExcel(): void $excelWorksheet->getComment($excelCellIndex)->getText()->createText($cellComment); } + // Set Url + $cellLink = $cell->getAttribute('_excel-link'); + if ($cellLink = filter_var($cellLink, FILTER_SANITIZE_URL)) { + $excelWorksheet->getCell($excelCellIndex)->getHyperlink()->setUrl($cellLink); + } + // Merge cells $colspan = $cell->getAttribute('colspan'); $rowspan = $cell->getAttribute('rowspan');