Skip to content

Commit

Permalink
feat: allow formatted date cells to be empty (#2)
Browse files Browse the repository at this point in the history
* feat: allow formatted date cells to be empty

* add oracle test

* remove dbg

* Update test/oracle_test.exs
  • Loading branch information
vinicius-remote authored Jun 11, 2024
1 parent 4d06bde commit da3a796
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/elixlsx/util.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}]).
Expand Down
10 changes: 10 additions & 0 deletions test/oracle_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit da3a796

Please sign in to comment.