PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.6
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.6
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Reader / Xlsx / Hyperlinks.php

Hyperlinks.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.11.6, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php

59 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Reader\Xlsx;
4
5 use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
6 use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
7
8 class Hyperlinks
9 {
10 private $worksheet;
11
12 private $hyperlinks = [];
13
14 public function __construct(Worksheet $workSheet)
15 {
16 $this->worksheet = $workSheet;
17 }
18
19 public function readHyperlinks(\SimpleXMLElement $relsWorksheet)
20 {
21 foreach ($relsWorksheet->Relationship as $element) {
22 if ($element['Type'] == 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink') {
23 $this->hyperlinks[(string) $element['Id']] = (string) $element['Target'];
24 }
25 }
26 }
27
28 public function setHyperlinks(\SimpleXMLElement $worksheetXml)
29 {
30 foreach ($worksheetXml->hyperlink as $hyperlink) {
31 $this->setHyperlink($hyperlink, $this->worksheet);
32 }
33 }
34
35 private function setHyperlink(\SimpleXMLElement $hyperlink, Worksheet $worksheet)
36 {
37 // Link url
38 $linkRel = $hyperlink->attributes('http://schemas.openxmlformats.org/officeDocument/2006/relationships');
39
40 foreach (Coordinate::extractAllCellReferencesInRange($hyperlink['ref']) as $cellReference) {
41 $cell = $worksheet->getCell($cellReference);
42 if (isset($linkRel['id'])) {
43 $hyperlinkUrl = $this->hyperlinks[(string) $linkRel['id']];
44 if (isset($hyperlink['location'])) {
45 $hyperlinkUrl .= '#' . (string) $hyperlink['location'];
46 }
47 $cell->getHyperlink()->setUrl($hyperlinkUrl);
48 } elseif (isset($hyperlink['location'])) {
49 $cell->getHyperlink()->setUrl('sheet://' . (string) $hyperlink['location']);
50 }
51
52 // Tooltip
53 if (isset($hyperlink['tooltip'])) {
54 $cell->getHyperlink()->setTooltip((string) $hyperlink['tooltip']);
55 }
56 }
57 }
58 }
59