From 0f78a6b1268baf8099942e262bd5338c5e58c711 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:08:23 -0500 Subject: [PATCH 1/2] HYPERLINK without a friendly name returns the link as text Excel: HYPERLINK(1) is the text "1" (ISTEXT is TRUE); with a friendly name the result keeps that value's type. --- crates/functions/src/info.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/functions/src/info.rs b/crates/functions/src/info.rs index 7aa2c2660..3cec219e4 100644 --- a/crates/functions/src/info.rs +++ b/crates/functions/src/info.rs @@ -311,11 +311,8 @@ fn hyperlink(a: &[Arg], _c: &mut dyn Ctx) -> R { let v = a.get(1).map(scalar).unwrap_or(Value::Empty); return Ok(empty_to_zero(v)); } - let link = a.first().map(scalar).unwrap_or(Value::Empty); - if let Value::Error(e) = link { - return Err(e); - } - Ok(link) + // Excel returns the link as text, so HYPERLINK(1) is "1" and ISTEXT is TRUE. + Ok(Value::Text(text(a, 0)?.into())) } fn encodeurl(a: &[Arg], _c: &mut dyn Ctx) -> R { @@ -608,6 +605,12 @@ mod tests { is_text(ev("HYPERLINK", vec![t("http://x.com")]), "http://x.com"); is_text(ev("HYPERLINK", vec![t("http://x.com"), t("Click")]), "Click"); close(ev("HYPERLINK", vec![t("http://x.com"), n(5.0)]), 5.0); + // Excel 16: without a friendly name the result is the link as text. + is_text(ev("HYPERLINK", vec![n(1.0)]), "1"); + is_text(ev("HYPERLINK", vec![n(1.5)]), "1.5"); + is_text(ev("HYPERLINK", vec![Value::Bool(true)]), "TRUE"); + is_text(ev("HYPERLINK", vec![Value::Empty]), ""); + is_err(ev("HYPERLINK", vec![Value::Error(CellError::Div0)]), CellError::Div0); is_text(ev("ENCODEURL", vec![t("a b&c/é")]), "a%20b%26c%2F%C3%A9"); is_err(ev("WEBSERVICE", vec![t("http://x")]), CellError::Value); is_err(ev("FILTERXML", vec![t(""), t("//a")]), CellError::Value); From 87342cb30892c598d969c78334c5f6d70ecbe7b9 Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Tue, 27 Oct 2026 21:08:35 -0500 Subject: [PATCH 2/2] HYPERLINK tests: use the Arg helpers --- crates/functions/src/info.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/functions/src/info.rs b/crates/functions/src/info.rs index 3cec219e4..309f0323e 100644 --- a/crates/functions/src/info.rs +++ b/crates/functions/src/info.rs @@ -608,9 +608,9 @@ mod tests { // Excel 16: without a friendly name the result is the link as text. is_text(ev("HYPERLINK", vec![n(1.0)]), "1"); is_text(ev("HYPERLINK", vec![n(1.5)]), "1.5"); - is_text(ev("HYPERLINK", vec![Value::Bool(true)]), "TRUE"); - is_text(ev("HYPERLINK", vec![Value::Empty]), ""); - is_err(ev("HYPERLINK", vec![Value::Error(CellError::Div0)]), CellError::Div0); + is_text(ev("HYPERLINK", vec![b(true)]), "TRUE"); + is_text(ev("HYPERLINK", vec![rf(Value::Empty)]), ""); + is_err(ev("HYPERLINK", vec![e(CellError::Div0)]), CellError::Div0); is_text(ev("ENCODEURL", vec![t("a b&c/é")]), "a%20b%26c%2F%C3%A9"); is_err(ev("WEBSERVICE", vec![t("http://x")]), CellError::Value); is_err(ev("FILTERXML", vec![t(""), t("//a")]), CellError::Value);