How a cell looks: a plain map with atom keys, so styles compose with
Map.merge/2 and read well when inspected.
%{bold: true, background: "#FFF2CC", number_format: "0.00%"}| Key | Value |
|---|---|
:bold, :italic, :underline, :strikethrough | boolean() |
:font_size | points, a positive integer |
:font_family | "Roboto" |
:color | text colour, "#RRGGBB" |
:background | fill colour, "#RRGGBB" |
:horizontal | :left, :center or :right |
:vertical | :top, :middle or :bottom |
:wrap | :overflow, :clip or :wrap |
:number_format | a Sheets pattern, "#,##0.00", "yyyy-mm-dd" |
:col_width | pixels, a positive integer |
:row_height | pixels, a positive integer |
:col_width and :row_height describe the column and row the cell sits in
rather than the cell; writers lift them out. Validation happens where a style
is about to be written, not when you build it.
Summary
Functions
A "#RRGGBB" colour as {red, green, blue} in 0..255.
Every key a style may have.
{red, green, blue} in 0..255 as "#RRGGBB".
Whether the term is a valid style.
Checks every key and value.
Types
Functions
@spec hex_to_rgb(color()) :: {0..255, 0..255, 0..255}
A "#RRGGBB" colour as {red, green, blue} in 0..255.
iex> Sheetshow.Style.hex_to_rgb("#FF8800")
{255, 136, 0}
@spec keys() :: [atom()]
Every key a style may have.
@spec rgb_to_hex({0..255, 0..255, 0..255}) :: color()
{red, green, blue} in 0..255 as "#RRGGBB".
iex> Sheetshow.Style.rgb_to_hex({255, 136, 0})
"#FF8800"
Whether the term is a valid style.
@spec validate(term()) :: :ok | {:error, Sheetshow.Error.t()}
Checks every key and value.
iex> Sheetshow.Style.validate(%{bold: true, horizontal: :center})
:ok
iex> {:error, %Sheetshow.Error{reason: :invalid_style, details: %{key: :bolt}}} =
...> Sheetshow.Style.validate(%{bolt: true})
iex> {:error, %Sheetshow.Error{details: %{key: :font_size, value: 0}}} =
...> Sheetshow.Style.validate(%{font_size: 0})