Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow empty datetime cells #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions example.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ sheet1 = Sheet.with_name("First")
|> Sheet.set_cell("A4", 1_448_882_362, yyyymmdd: true)
# datetime: true ouputs date and time, yyyymmdd limits the output to just the date
|> Sheet.set_cell("A5", 1_448_882_362, yyyymm: true)
# Date formatting can also be applied without setting the cell content
|> Sheet.set_cell("A6", "", datetime: true)
# make some room in the first column, otherwise the date will only show up as ###
|> Sheet.set_col_width("A", 18.0)
# Cell borders
Expand Down
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(nil), do: ""
def to_excel_datetime(""), do: ""

@doc ~S"""
Replace_all(input, [{search, replace}]).

Expand Down