Elixlsx.Util (elixlsx v0.6.0) View Source

Link to this section Summary

Functions

Returns the application version suitable for the <ApplicationVersion> tag.

Returns the column index associated with a given letter.

Returns the column letter(s) associated with a column index.

Returns a tuple {row, col} corresponding to the input.

See from_excel_coords/1

Returns the ISO String representation (in UTC) for a erlang datetime() or datetime1970() object.

Replace_all(input, [{search, replace}]).

Returns the Char/Number representation of a given row/column combination.

Convert an erlang :calendar object, or a unix timestamp to an excel timestamp.

Link to this section Types

Specs

datetime_t() :: :calendar.datetime()

Link to this section Functions

Returns the application version suitable for the <ApplicationVersion> tag.

Specs

decode_col([char()] | String.t()) :: non_neg_integer()

Returns the column index associated with a given letter.

Examples

iex> decode_col("AB")
28

iex> decode_col("A")
1

Specs

encode_col(non_neg_integer()) :: String.t()

Returns the column letter(s) associated with a column index.

Col idx starts at 1.

Examples

iex> encode_col(1)
"A"

iex> encode_col(28)
"AB"
Link to this function

encode_col(num, suffix \\ "")

View Source
Link to this function

from_excel_coords(input)

View Source

Specs

from_excel_coords(String.t()) :: {pos_integer(), pos_integer()}

Returns a tuple {row, col} corresponding to the input.

Row and col are 1-indexed, use from_excel_coords0 for zero-indexing.

Examples

iex> from_excel_coords("C2")
{2, 3}

iex> from_excel_coords0("C2")
{1, 2}
Link to this function

from_excel_coords0(input)

View Source

Specs

from_excel_coords0(String.t()) :: {non_neg_integer(), non_neg_integer()}

See from_excel_coords/1

Link to this function

iso_from_datetime(calendar)

View Source

Specs

iso_from_datetime(datetime_t()) :: String.t()

Returns the ISO String representation (in UTC) for a erlang datetime() or datetime1970() object.

Examples

iex> iso_from_datetime {{2000, 12, 30}, {23, 59, 59}}
"2000-12-30T23:59:59Z"
Link to this function

iso_timestamp(input \\ nil)

View Source

Specs

iso_timestamp(String.t() | integer() | nil) :: String.t()

Returns

  • the current current timestamp if input is nil,
  • the UNIX-Timestamp interpretation when given an integer,

both in ISO-Repr.

If input is a String, the string is returned:

iex> iso_timestamp 0
"1970-01-01T00:00:00Z"

iex> iso_timestamp 1447885907
"2015-11-18T22:31:47Z"

It doesn't validate string inputs though:

iex> iso_timestamp "goat"
"goat"
Link to this function

replace_all(input, list)

View Source

Specs

replace_all(String.t(), [{String.t(), String.t()}]) :: String.t()

Replace_all(input, [{search, replace}]).

Examples

iex> replace_all("Hello World", [{"e", "E"}, {"o", "oO"}])
"HElloO WoOrld"
Link to this function

to_excel_coords(row, col)

View Source

Specs

to_excel_coords(number(), number()) :: String.t()

Returns the Char/Number representation of a given row/column combination.

Indizes start with 1.

Examples

iex> to_excel_coords(1, 1)
"A1"

iex> to_excel_coords(10, 27)
"AA10"
Link to this function

to_excel_datetime(input)

View Source

Specs

to_excel_datetime(datetime_t()) :: {:excelts, number()}
to_excel_datetime(number()) :: {:excelts, number()}
to_excel_datetime({:excelts, number()}) :: {:excelts, number()}
to_excel_datetime({:formula, String.t()}) :: {:formula, String.t()}

Convert an erlang :calendar object, or a unix timestamp to an excel timestamp.

Timestampts that are already in excel format are passed through unmodified.