GSS.Spreadsheet (elixir_google_spreadsheets v0.4.0)
Model of Google Spreadsheet for external interaction.
Summary
Types
State of currently active Google spreadsheet
Functions
Add Conditional Formula using a boolean rule (as opposed to a gradient rule).
Add Number Format.
Append row in a spreadsheet after an index.
Batch update to append multiple rows.
Returns a specification to start this module under a supervisor.
Clear Basic Filter.
Clear row in a spreadsheet by index.
Batched clear, which deletes more then one record. Pass either an array of ranges, or start and end row indexes.
Granular read by a custom range from a spreadsheet.
Freeze Row or Column Header.
Get sheet id associated with list_name in state.
Combine the sheet_id into the grid_range, and drop any values from the range that are nil.
Get spreadsheet internal id.
Get spreadsheet properties.
Read row in a spreadsheet by index.
Batched read, which returns more than one record. Pass either an array of ranges (or rows), or start and end row indexes.
Get total amount of rows in a spreadsheet.
Set Basic Filter.
Get spreadsheet sheets from properties.
Update Border.
Update Column Width.
Update Column Wrap.
Override row in a spreadsheet by index.
Batch update to write multiple rows.
Types
@type spreadsheet_data() :: [String.t()]
@type spreadsheet_response() :: {:json, map()} | {:error, Exception.t()} | no_return()
@type state() :: map()
State of currently active Google spreadsheet:
%{
spreadsheet_id => "16Wgt0fuoYDgEAtGtYKF4jdjAhZez0q77UhkKdeKI6B4",
list_name => nil,
sheet_id => nil
}
Functions
@spec add_conditional_format( pid(), grid_range(), %{formula: String.t(), color_map: map()}, Keyword.t() ) :: {:ok, list()} | {:error, Exception.t()}
Add Conditional Formula using a boolean rule (as opposed to a gradient rule).
Required keys in params
:
formula
: A value the condition is based on. The value is parsed as if the user typed into a cell. Formulas are supported (and must begin with an = or a '+').color_map
: Represents a color in the RGBA color space. Keys arered
,green
,blue
, andalpha
, and each value is in the interval [0, 1].
@spec add_number_format( pid(), grid_range(), %{type: String.t(), pattern: String.t()}, Keyword.t() ) :: {:ok, list()} | {:error, Exception.t()}
Add Number Format.
Required keys in params
:
type
: The number format of the cell (e.g.,DATE
orTIME
).pattern
: Pattern string used for formatting (e.g.,yyyy-mm-dd
).
@spec append_row(pid(), integer(), spreadsheet_data(), Keyword.t()) :: :ok
Append row in a spreadsheet after an index.
@spec append_rows(pid(), integer(), [spreadsheet_data()], Keyword.t()) :: :ok | {:error, Exception.t()}
Batch update to append multiple rows.
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec clear_basic_filter(pid(), Keyword.t()) :: {:ok, map()} | {:error, Exception.t()}
Clear Basic Filter.
Clear row in a spreadsheet by index.
@spec clear_rows(pid(), [String.t()]) :: :ok | {:error, Exception.t()}
Batched clear, which deletes more then one record. Pass either an array of ranges, or start and end row indexes.
@spec clear_rows(pid(), [String.t()], Keyword.t()) :: :ok | {:error, Exception.t()}
@spec clear_rows(pid(), integer(), integer()) :: :ok | {:error, Exception.t()}
@spec clear_rows(pid(), integer(), integer(), Keyword.t()) :: :ok | {:error, Exception.t()}
@spec fetch(pid(), String.t()) :: {:ok, spreadsheet_data()} | {:error, Exception.t()}
Granular read by a custom range from a spreadsheet.
@spec freeze_header(pid(), %{dim: :row | :col, n_freeze: integer()}, Keyword.t()) :: {:ok, list()} | {:error, Exception.t()}
Freeze Row or Column Header.
Required keys in params
:
dim
: Either:row
or:col
to set the dimension to freeze.n_freeze
: Set the number of rows or columns to freeze.
Get sheet id associated with list_name in state.
@spec grid_range(integer(), grid_range()) :: map()
Combine the sheet_id into the grid_range, and drop any values from the range that are nil.
Get spreadsheet internal id.
Get spreadsheet properties.
@spec read_row(pid(), integer(), Keyword.t()) :: {:ok, spreadsheet_data()} | {:error, Exception.t()}
Read row in a spreadsheet by index.
@spec read_rows(pid(), [String.t()] | [integer()]) :: {:ok, [spreadsheet_data() | nil]} | {:error, Exception.t()}
Batched read, which returns more than one record. Pass either an array of ranges (or rows), or start and end row indexes.
By default it returns nils
for an empty rows,
use pad_empty: true
and column_to: integer
options to fill records
with an empty string values.
@spec read_rows(pid(), [String.t()] | [integer()], Keyword.t()) :: {:ok, [spreadsheet_data()]} | {:error, Exception.t()}
@spec read_rows(pid(), integer(), integer()) :: {:ok, [spreadsheet_data()]} | {:error, atom()}
@spec rows(pid(), Keyword.t()) :: {:ok, integer()} | {:error, Exception.t()}
Get total amount of rows in a spreadsheet.
@spec set_basic_filter(pid(), grid_range(), map(), Keyword.t()) :: {:ok, list()} | {:error, Exception.t()}
Set Basic Filter.
Two options for params
:
- To not filter out any rows, pass an empty map.
- To filter out rows based on a column value, add these
keys:
col_idx
,condition_type
,user_entered_value
.
@spec set_font(pid(), grid_range(), %{font_family: String.t()}, Keyword.t()) :: {:ok, list()} | {:error, Exception.t()}
Set Font.
Required key in params
: font_family
.
Get spreadsheet sheets from properties.
@spec update_border(pid(), grid_range(), map(), Keyword.t()) :: {:ok, list()} | {:error, Exception.t()}
Update Border.
Map params
can only have keys in [:top, :bottom, :left, :right]
. If a key is omitted,
then the border remains as-is on that side. Subkeys: style
, red
, green
, blue
, alpha
.
@spec update_col_width( pid(), %{col_idx: integer(), col_width: integer()}, Keyword.t() ) :: {:ok, list()} | {:error, Exception.t()}
Update Column Width.
Required keys in params
:
col_idx
: Index of column.col_width
: Column width in pixels.
@spec update_col_wrap(pid(), grid_range(), %{wrap_strategy: String.t()}, Keyword.t()) :: {:ok, list()} | {:error, Exception.t()}
Update Column Wrap.
Required keys in params
:
wrap_strategy
: How to wrap text in a cell. Options: [overflow_cell
,clip
,wrap
].
@spec write_row(pid(), integer(), spreadsheet_data(), Keyword.t()) :: :ok
Override row in a spreadsheet by index.
@spec write_rows(pid(), [String.t()], [spreadsheet_data()], Keyword.t()) :: {:ok, list()} | {:error, Exception.t()}
Batch update to write multiple rows.
Range schema should define the same amount of rows as amound of records in data and same amount of columns as entries in data record.