From da3a7963c3cdc3e9def36cdb25e735cd3950c261 Mon Sep 17 00:00:00 2001 From: vinicius-remote Date: Tue, 11 Jun 2024 14:52:51 -0300 Subject: [PATCH] feat: allow formatted date cells to be empty (#2) * feat: allow formatted date cells to be empty * add oracle test * remove dbg * Update test/oracle_test.exs --- lib/elixlsx/util.ex | 4 ++++ test/oracle_test.exs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/elixlsx/util.ex b/lib/elixlsx/util.ex index a2a73be..f9fa99c 100644 --- a/lib/elixlsx/util.ex +++ b/lib/elixlsx/util.ex @@ -231,6 +231,10 @@ defmodule Elixlsx.Util do {:formula, value} end + @spec to_excel_datetime(binary() | nil) :: binary() + def to_excel_datetime(""), do: "" + def to_excel_datetime(nil), do: "" + @doc ~S""" Replace_all(input, [{search, replace}]). diff --git a/test/oracle_test.exs b/test/oracle_test.exs index b521ac1..b25f8fb 100644 --- a/test/oracle_test.exs +++ b/test/oracle_test.exs @@ -44,4 +44,14 @@ defmodule OracleTest do assert check(bin) end + + test "empty date cells" do + s = Sheet.with_name("1") |> Sheet.set_cell("A4", "", yyyymmdd: true) + + wk = %Workbook{} |> Workbook.append_sheet(s) + + assert {:ok, {_, bin}} = Elixlsx.write_to_memory(wk, "") + + assert check(bin) + end end