Added Hyperlink Support
Adaptation of a previous version PR https://github.com/box/spout/pull/352
This commit is contained in:
parent
6c4086cf97
commit
e087e2b03e
@ -213,7 +213,20 @@ EOD;
|
||||
$cellXML .= ' s="' . $styleId . '"';
|
||||
|
||||
if ($cell->isString()) {
|
||||
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue());
|
||||
$matches = array();
|
||||
if (preg_match('/=HYPERLINK\([\'"](.*)[\'"],\s*[\'"](.*)[\'"]\)/', $cell->getValue(), $matches)) {
|
||||
if ($this->stringHelper->getStringLength($cell->getValue()) > self::MAX_CHARACTERS_PER_CELL) {
|
||||
throw new InvalidArgumentException('Trying to add a value that exceeds the maximum number of characters allowed in a cell (32,767)');
|
||||
}
|
||||
// Special case to add HYPERLINK Formula
|
||||
$url = $this->stringsEscaper->escape($matches[1]);
|
||||
$text = $this->stringsEscaper->escape($matches[2]);
|
||||
$formula = sprintf('HYPERLINK("%s","%s")', $url, $text);
|
||||
$cellXML = sprintf(
|
||||
'<c r="%s%s" t="str"><f>%s</f><v>%s</v></c>',
|
||||
$columnIndex, $rowIndex, $formula, $text);
|
||||
}else
|
||||
$cellXML .= $this->getCellXMLFragmentForNonEmptyString($cell->getValue());
|
||||
} elseif ($cell->isBoolean()) {
|
||||
$cellXML .= ' t="b"><v>' . (int) ($cell->getValue()) . '</v></c>';
|
||||
} elseif ($cell->isNumeric()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user