diff --git a/example.exs b/example.exs index 809866a..25494e2 100755 --- a/example.exs +++ b/example.exs @@ -2,11 +2,9 @@ require Elixlsx -alias Elixlsx.Sheet -alias Elixlsx.Workbook +alias Elixlsx.{Sheet, Workbook} -sheet1 = - Sheet.with_name("First") +sheet1 = Sheet.with_name("First") # Set cell B2 to the string "Hi". :) |> Sheet.set_cell("B2", "Hi") # Optionally, set font properties: @@ -21,17 +19,19 @@ sheet1 = |> Sheet.set_cell("A3", 1_448_882_362, datetime: true) # datetime: true outputs date and time, yyyymmdd limits the output to just the date |> 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) # make some room in the first column, otherwise the date will only show up as ### |> Sheet.set_col_width("A", 18.0) # Cell borders - |> Sheet.set_cell("A5", "Double border", border: [bottom: [style: :double, color: "#cc3311"]]) + |> Sheet.set_cell("A6", "Double border", border: [bottom: [style: :double, color: "#cc3311"]]) # Formatting with empty content - |> Sheet.set_cell("A5", :empty, + |> Sheet.set_cell("A7", :empty, bg_color: "#ffff00", border: [bottom: [style: :double, color: "#cc3311"]] ) # Boolean value - |> Sheet.set_cell("A6", true) + |> Sheet.set_cell("A7", true) # Formula |> Sheet.set_cell("E1", 1.2, num_format: "0.00") |> Sheet.set_cell("E2", 2, num_format: "0.00") diff --git a/lib/elixlsx/style/num_fmt.ex b/lib/elixlsx/style/num_fmt.ex index 727eff5..74ae642 100644 --- a/lib/elixlsx/style/num_fmt.ex +++ b/lib/elixlsx/style/num_fmt.ex @@ -13,6 +13,9 @@ defmodule Elixlsx.Style.NumFmt do props[:yyyymmdd] -> date_yyyy_mm_dd() + props[:yyyymm] -> + date_yyyy_mm() + props[:datetime] -> date_datetime() @@ -39,6 +42,13 @@ defmodule Elixlsx.Style.NumFmt do %NumFmt{format: "yyyy-mm-dd"} end + @doc ~S""" + Returns a semi-ISP date format only month and year (YYYY-MM) + """ + def date_yyyy_mm do + %NumFmt{format: "yyyy-mm"} + end + @doc ~S""" Returns a standard semi-iso datetime format. """ diff --git a/mix.exs b/mix.exs index fade930..1ec6181 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Elixlsx.Mixfile do use Mix.Project @source_url "https://github.com/xou/elixlsx" - @version "0.5.1" + @version "0.5.2" def project do [