diff --git a/src/Spout/Writer/XLSX/Internal/Worksheet.php b/src/Spout/Writer/XLSX/Internal/Worksheet.php index 5896c05..4628bb3 100644 --- a/src/Spout/Writer/XLSX/Internal/Worksheet.php +++ b/src/Spout/Writer/XLSX/Internal/Worksheet.php @@ -200,11 +200,22 @@ EOD; $cellXML .= ' s="' . $styleId . '"'; if (CellHelper::isNonEmptyString($cellValue)) { - if ($this->shouldUseInlineStrings) { - $cellXML .= ' t="inlineStr">' . $this->stringsEscaper->escape($cellValue) . ''; + $matches = array(); + if (preg_match('/=HYPERLINK\("(.*)","(.*)"\)/', $cellValue, $matches)) { + // 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( + '%s%s', + $columnIndex, $rowIndex, $formula, $text); } else { - $sharedStringId = $this->sharedStringsHelper->writeString($cellValue); - $cellXML .= ' t="s">' . $sharedStringId . ''; + if ($this->shouldUseInlineStrings) { + $cellXML .= ' t="inlineStr">' . $this->stringsEscaper->escape($cellValue) . ''; + } else { + $sharedStringId = $this->sharedStringsHelper->writeString($cellValue); + $cellXML .= ' t="s">' . $sharedStringId . ''; + } } } else if (CellHelper::isBoolean($cellValue)) { $cellXML .= ' t="b">' . intval($cellValue) . '';