Elixlsx.Sheet (elixlsx v0.6.0) View Source

Describes a single sheet with a given name. The name can be up to 31 characters long.

The rows property is a list, each corresponding to a row (from the top), of lists, each corresponding to a column (from the left), of contents.

Content may be:

  • a String.t (unicode),
  • a number, or
  • a list [String|number, property_list...]

The property list describes formatting options for that cell. See Font.from_props/1 for a list of options.

Link to this section Summary

Functions

Group given column range. (i.e. increase outline level by one)

Group given row range. (i.e. increase outline level by one)

Removes any pane freezing that has been set.

Set a cell at a given row/column index.

Set a cell indexed by excel coordinates.

Set the column width for a given column.

Set the pane freeze at the given row and column.

Set the row height for a given row.

Returns a "CSV" representation of the Sheet.

Create a sheet with a sheet name.

Link to this section Types

Specs

rowcol_group() :: Range.t() | {Range.t(), opts :: keyword()}

Specs

t() :: %Elixlsx.Sheet{
  col_widths: %{required(pos_integer()) => number()},
  data_validations: [{String.t(), String.t(), [String.t()] | String.t()}],
  group_cols: [rowcol_group()],
  group_rows: [rowcol_group()],
  merge_cells: [{String.t(), String.t()}],
  name: String.t(),
  pane_freeze: {number(), number()} | nil,
  row_heights: %{required(pos_integer()) => number()},
  rows: [[any()]],
  show_grid_lines: boolean()
}

Link to this section Functions

Link to this function

add_data_validations(sheet, start_cell, end_cell, values)

View Source

Specs

add_data_validations(t(), String.t(), String.t(), [String.t()]) :: t()
Link to this function

group_cols(sheet, first_col, last_col, opts \\ [])

View Source

Group given column range. (i.e. increase outline level by one)

Column is indexed by name ("A", ...)

Options

  • collapsed: if true, collapse this group.
Link to this function

group_rows(sheet, first_row_idx, last_row_idx, opts \\ [])

View Source

Group given row range. (i.e. increase outline level by one)

Row is indexed starting from 1.

Options

  • collapsed: if true, collapse this group.
Link to this function

remove_pane_freeze(sheet)

View Source

Specs

remove_pane_freeze(t()) :: t()

Removes any pane freezing that has been set.

Link to this function

set_at(sheet, rowidx, colidx, content, opts \\ [])

View Source

Specs

set_at(t(), non_neg_integer(), non_neg_integer(), any(), Keyword.t()) :: t()

Set a cell at a given row/column index.

Indizes start at 0.

Examples

iex> %Elixlsx.Sheet{} |>
...> Elixlsx.Sheet.set_at(0, 2, "Hello World",
...>                bold: true, underline: true) |>
...> Elixlsx.Sheet.to_csv_string
",,Hello World"
Link to this function

set_cell(sheet, index, content, opts \\ [])

View Source

Specs

set_cell(t(), String.t(), any(), Keyword.t()) :: t()

Set a cell indexed by excel coordinates.

Examples

iex> %Elixlsx.Sheet{} |>
...> Elixlsx.Sheet.set_cell("C1", "Hello World",
...>                bold: true, underline: true) |>
...> Elixlsx.Sheet.to_csv_string
",,Hello World"
Link to this function

set_col_width(sheet, column, width)

View Source

Specs

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

Set the column width for a given column.

Column is indexed by name ("A", ...)

Link to this function

set_pane_freeze(sheet, row_idx, col_idx)

View Source

Specs

set_pane_freeze(t(), number(), number()) :: t()

Set the pane freeze at the given row and column.

Row and column are indexed starting from 1. Special value 0 means no freezing, e.g. {1, 0} will freeze first row and no columns.

Link to this function

set_row_height(sheet, row_idx, height)

View Source

Specs

set_row_height(t(), number(), number()) :: t()

Set the row height for a given row.

Row is indexed starting from 1

Returns a "CSV" representation of the Sheet.

This is mainly used for doctests and does not generate valid CSV (yet).

Specs

with_name(String.t()) :: t()

Create a sheet with a sheet name.

The name can be up to 31 characters long.