diff --git a/lib/elixlsx/sheet.ex b/lib/elixlsx/sheet.ex index e7d0878..b3cff43 100644 --- a/lib/elixlsx/sheet.ex +++ b/lib/elixlsx/sheet.ex @@ -77,6 +77,7 @@ defmodule Elixlsx.Sheet do case content do nil -> "" + {:formula, val} -> String.Chars.to_string(val) _ -> to_string(content) end end) diff --git a/test/elixlsx_test.exs b/test/elixlsx_test.exs index 871593d..983e314 100644 --- a/test/elixlsx_test.exs +++ b/test/elixlsx_test.exs @@ -126,4 +126,26 @@ defmodule ElixlsxTest do end end) end + + test "test csv can export function value" do + csv = Sheet.with_name("A name") + |> Sheet.set_at( + 0, + 0, + {:formula, "foo"} + ) + |> Sheet.set_at( + 0, + 1, + {:formula, "=HYPERLINK(\"https://www.google.com\", \"Go To Google\")"} + ) + |> Sheet.set_at( + 0, + 2, + {:formula, "bar"} + ) + |> Sheet.to_csv_string() + + assert csv == "foo,=HYPERLINK(\"https://www.google.com\", \"Go To Google\"),bar" + end end