elixlsx v0.0.2 Elixlsx.Util

Summary

Functions

returns the column index associated with a given letter

returns the column letter(s) associated with a column index. Col idx starts at 1

returns a tuple {row, col} corresponding to the input. row and col are 1-indexed, use from_excel_coords0 for zero-indexing

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. Indizes start with 1

Timestampts that are already in excel format are passed through unmodified

Types

datetime_t :: :calendar.datetime

Functions

decode_col(s)

Specs

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

returns the column index associated with a given letter.

Example

iex> decode_col("AB")
28

iex> decode_col("A")
1
encode_col(num)

Specs

encode_col(non_neg_integer) :: String.t

returns the column letter(s) associated with a column index. Col idx starts at 1.

Example

iex> encode_col(1)
"A"

iex> encode_col(28)
"AB"
from_excel_coords(input)

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.

Example:

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

iex> from_excel_coords0("C2")
{1, 2}
from_excel_coords0(input)

Specs

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

See from_excel_coords/1

iso_from_datetime(calendar)

Specs

iso_from_datetime(datetime_t) :: String.t

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

Example

iex> iso_from_datetime {{2000, 12, 30}, {23, 59, 59}}
"2000-12-30T23:59:59Z"
iso_timestamp(input \\ nil)

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"
replace_all(input, list)

Specs

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

replace_all(input, [{search, replace}])

Example

iex> replace_all("Hello World", [{"e", "E"}, {"o", "oO"}])
"HElloO WoOrld"
to_excel_coords(row, col)

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"
to_excel_datetime(input)

Specs

to_excel_datetime(number) :: number
to_excel_datetime(datetime_t) :: number

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