Class: IronCalc::UserModel
- Inherits:
-
Object
- Object
- IronCalc::UserModel
- Includes:
- Batch, DefinedNames
- Defined in:
- lib/ironcalc/native_methods.rb
Overview
The recommended, higher-level IronCalc API. Auto-evaluates after every action
and records diffs for collaboration (#flush_send_queue /
#apply_external_diffs). Mirrors IronCalc's WebAssembly binding and is a
superset of the Python binding's UserModel. Styling is per-property via
#update_range_style.
Instance Method Summary collapse
-
#apply_external_diffs(diffs) ⇒ void
Applies a peer's diff blob (from #flush_send_queue) for collaboration.
- #can_redo ⇒ Boolean
- #can_undo ⇒ Boolean
- #delete_columns(sheet, column, column_count) ⇒ void
-
#delete_defined_name(name, scope) ⇒ void
Deletes a defined name.
- #delete_rows(sheet, row, row_count) ⇒ void
- #delete_sheet(sheet) ⇒ void
-
#evaluate ⇒ void
Forces a recalculation.
-
#flush_send_queue ⇒ String
Returns and clears the queued diffs to broadcast to collaborators.
-
#get_cell_content(sheet, row, column) ⇒ String
Returns the cell's content: formula or literal text.
-
#get_cell_style(sheet, row, column) ⇒ Hash
Returns the cell style as a Hash with Symbol keys, like Model#get_style_for_cell.
-
#get_cell_type(sheet, row, column) ⇒ Symbol
Returns the cell type as a Symbol (see Model#get_cell_type).
-
#get_column_width(sheet, column) ⇒ Float
Width in pixels.
-
#get_defined_name_list ⇒ Array<Hash>
Defined names as one Hash per name, with symbol keys
:name,:scope(0-based sheet index, or nil for workbook scope) and:formula. -
#get_formatted_cell_value(sheet, row, column) ⇒ String
The cell's value with its number format applied, as displayed — e.g.
- #get_frozen_columns_count(sheet) ⇒ Integer
- #get_frozen_rows_count(sheet) ⇒ Integer
-
#get_row_height(sheet, row) ⇒ Float
Height in pixels.
-
#get_sheet_dimensions(sheet) ⇒ Array(Integer, Integer, Integer, Integer)
Returns
[min_row, max_row, min_column, max_column]over non-empty cells. -
#get_worksheets_properties ⇒ Array<Hash>
Returns one Hash per sheet with symbol keys
:name,:state,:sheet_idand:color. - #insert_columns(sheet, column, column_count) ⇒ void
- #insert_rows(sheet, row, row_count) ⇒ void
- #is_column_hidden(sheet, column) ⇒ Boolean
- #is_row_hidden(sheet, row) ⇒ Boolean
-
#is_valid_defined_name(name, scope, formula) ⇒ Integer?
Checks whether #new_defined_name would succeed for these arguments, raising with the reason if not.
-
#new_defined_name(name, scope, formula) ⇒ void
Adds a defined name.
-
#new_sheet ⇒ void
Adds a new sheet with an auto-generated name.
-
#pause_evaluation ⇒ void
Suspends the automatic recalculation this API does after every action — useful when writing many cells at once.
-
#range_clear_all(range) ⇒ void
Clears the contents and style of every cell in a range.
-
#range_clear_contents(range) ⇒ void
Clears the contents (not the style) of every cell in a range.
-
#range_clear_formatting(range) ⇒ void
Clears the style of every cell in a range, keeping the contents.
-
#redo ⇒ void
Redoes the last undone change.
- #rename_sheet(sheet, new_name) ⇒ void
-
#resume_evaluation ⇒ void
Re-enables automatic recalculation.
-
#save_to_icalc(file) ⇒ void
Saves the workbook to the internal binary icalc format.
-
#save_to_xlsx(file) ⇒ void
Saves the workbook to an xlsx file.
-
#set_columns_hidden(sheet, column_start, column_end, hidden) ⇒ void
Hides or shows columns
column_starttocolumn_end, inclusive. -
#set_columns_width(sheet, column_start, column_end, width) ⇒ void
Sets the width of columns
column_starttocolumn_end, inclusive. - #set_frozen_columns_count(sheet, count) ⇒ void
- #set_frozen_rows_count(sheet, count) ⇒ void
-
#set_rows_height(sheet, row_start, row_end, height) ⇒ void
Sets the height of rows
row_starttorow_end, inclusive. -
#set_rows_hidden(sheet, row_start, row_end, hidden) ⇒ void
Hides or shows rows
row_starttorow_end, inclusive. -
#set_sheet_color(sheet, color) ⇒ void
Sets the sheet tab color.
-
#set_user_input(sheet, row, column, value) ⇒ void
Sets a cell's input, parsed as a user typing it would be:
"3.5"is a number,"Hello"a string,"=A1*2"a formula. -
#to_bytes ⇒ String
Serializes the workbook to icalc bytes.
-
#to_xlsx_bytes ⇒ String
Serializes the workbook to xlsx bytes (load with create_user_model_from_xlsx_bytes).
-
#undo ⇒ void
Undoes the last change.
-
#update_defined_name(name, scope, new_name, new_scope, new_formula) ⇒ void
Renames, re-scopes and/or repoints an existing defined name.
-
#update_range_style(range, style_path, value) ⇒ void
Sets a single style property on every cell of a range, e.g.
Methods included from DefinedNames
#defined_names, #valid_defined_name?
Methods included from Batch
Instance Method Details
#apply_external_diffs(diffs) ⇒ void
This method returns an undefined value.
Applies a peer's diff blob (from #flush_send_queue) for collaboration.
|
|
# File 'lib/ironcalc/native_methods.rb', line 667
|
#can_redo ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 695
|
#can_undo ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 692
|
#delete_columns(sheet, column, column_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 782
|
#delete_defined_name(name, scope) ⇒ void
This method returns an undefined value.
Deletes a defined name. Fails if no name matches in that scope.
|
|
# File 'lib/ironcalc/native_methods.rb', line 932
|
#delete_rows(sheet, row, row_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 775
|
#delete_sheet(sheet) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 889
|
#evaluate ⇒ void
This method returns an undefined value.
Forces a recalculation. Usually unnecessary — the user model auto-evaluates after each action; exposed for parity.
|
|
# File 'lib/ironcalc/native_methods.rb', line 677
|
#flush_send_queue ⇒ String
Returns and clears the queued diffs to broadcast to collaborators.
|
|
# File 'lib/ironcalc/native_methods.rb', line 673
|
#get_cell_content(sheet, row, column) ⇒ String
Returns the cell's content: formula or literal text.
|
|
# File 'lib/ironcalc/native_methods.rb', line 715
|
#get_cell_style(sheet, row, column) ⇒ Hash
Returns the cell style as a Hash with Symbol keys, like Model#get_style_for_cell.
|
|
# File 'lib/ironcalc/native_methods.rb', line 740
|
#get_cell_type(sheet, row, column) ⇒ Symbol
Returns the cell type as a Symbol (see Model#get_cell_type).
|
|
# File 'lib/ironcalc/native_methods.rb', line 723
|
#get_column_width(sheet, column) ⇒ Float
Returns width in pixels.
|
|
# File 'lib/ironcalc/native_methods.rb', line 789
|
#get_defined_name_list ⇒ Array<Hash>
Defined names as one Hash per name, with symbol keys :name, :scope
(0-based sheet index, or nil for workbook scope) and :formula.
Also available as DefinedNames#defined_names.
|
|
# File 'lib/ironcalc/native_methods.rb', line 906
|
#get_formatted_cell_value(sheet, row, column) ⇒ String
The cell's value with its number format applied, as displayed — e.g.
"$ 5.75".
|
|
# File 'lib/ironcalc/native_methods.rb', line 731
|
#get_frozen_columns_count(sheet) ⇒ Integer
|
|
# File 'lib/ironcalc/native_methods.rb', line 849
|
#get_frozen_rows_count(sheet) ⇒ Integer
|
|
# File 'lib/ironcalc/native_methods.rb', line 854
|
#get_row_height(sheet, row) ⇒ Float
Returns height in pixels.
|
|
# File 'lib/ironcalc/native_methods.rb', line 795
|
#get_sheet_dimensions(sheet) ⇒ Array(Integer, Integer, Integer, Integer)
Returns [min_row, max_row, min_column, max_column] over non-empty cells.
|
|
# File 'lib/ironcalc/native_methods.rb', line 900
|
#get_worksheets_properties ⇒ Array<Hash>
Returns one Hash per sheet with symbol keys :name, :state,
:sheet_id and :color.
|
|
# File 'lib/ironcalc/native_methods.rb', line 871
|
#insert_columns(sheet, column, column_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 768
|
#insert_rows(sheet, row, row_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 761
|
#is_column_hidden(sheet, column) ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 819
|
#is_row_hidden(sheet, row) ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 834
|
#is_valid_defined_name(name, scope, formula) ⇒ Integer?
Checks whether #new_defined_name would succeed for these arguments, raising with the reason if not. DefinedNames#valid_defined_name? answers the same question as a boolean.
|
|
# File 'lib/ironcalc/native_methods.rb', line 939
|
#new_defined_name(name, scope, formula) ⇒ void
This method returns an undefined value.
Adds a defined name. Fails if the name is not a valid identifier (+"A1"+ is not: it parses as a cell reference), if it is already taken in that scope, or if the formula does not parse.
|
|
# File 'lib/ironcalc/native_methods.rb', line 912
|
#new_sheet ⇒ void
This method returns an undefined value.
Adds a new sheet with an auto-generated name.
|
|
# File 'lib/ironcalc/native_methods.rb', line 884
|
#pause_evaluation ⇒ void
This method returns an undefined value.
Suspends the automatic recalculation this API does after every action —
useful when writing many cells at once. While paused, formula cells read
back as #ERROR! until evaluated.
|
|
# File 'lib/ironcalc/native_methods.rb', line 965
|
#range_clear_all(range) ⇒ void
This method returns an undefined value.
Clears the contents and style of every cell in a range. Undoable.
|
|
# File 'lib/ironcalc/native_methods.rb', line 951
|
#range_clear_contents(range) ⇒ void
This method returns an undefined value.
Clears the contents (not the style) of every cell in a range. Undoable.
|
|
# File 'lib/ironcalc/native_methods.rb', line 708
|
#range_clear_formatting(range) ⇒ void
This method returns an undefined value.
Clears the style of every cell in a range, keeping the contents. Undoable.
|
|
# File 'lib/ironcalc/native_methods.rb', line 958
|
#redo ⇒ void
This method returns an undefined value.
Redoes the last undone change.
|
|
# File 'lib/ironcalc/native_methods.rb', line 687
|
#rename_sheet(sheet, new_name) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 894
|
#resume_evaluation ⇒ void
This method returns an undefined value.
Re-enables automatic recalculation. Does not recalculate by itself; call
evaluate afterwards to bring the workbook up to date.
|
|
# File 'lib/ironcalc/native_methods.rb', line 971
|
#save_to_icalc(file) ⇒ void
This method returns an undefined value.
Saves the workbook to the internal binary icalc format.
|
|
# File 'lib/ironcalc/native_methods.rb', line 656
|
#save_to_xlsx(file) ⇒ void
This method returns an undefined value.
Saves the workbook to an xlsx file. Fails if the file already exists.
|
|
# File 'lib/ironcalc/native_methods.rb', line 644
|
#set_columns_hidden(sheet, column_start, column_end, hidden) ⇒ void
This method returns an undefined value.
Hides or shows columns column_start to column_end, inclusive. Undoable.
|
|
# File 'lib/ironcalc/native_methods.rb', line 825
|
#set_columns_width(sheet, column_start, column_end, width) ⇒ void
This method returns an undefined value.
Sets the width of columns column_start to column_end, inclusive.
|
|
# File 'lib/ironcalc/native_methods.rb', line 801
|
#set_frozen_columns_count(sheet, count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 859
|
#set_frozen_rows_count(sheet, count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 865
|
#set_rows_height(sheet, row_start, row_end, height) ⇒ void
This method returns an undefined value.
Sets the height of rows row_start to row_end, inclusive.
|
|
# File 'lib/ironcalc/native_methods.rb', line 810
|
#set_rows_hidden(sheet, row_start, row_end, hidden) ⇒ void
This method returns an undefined value.
Hides or shows rows row_start to row_end, inclusive. Undoable.
|
|
# File 'lib/ironcalc/native_methods.rb', line 840
|
#set_sheet_color(sheet, color) ⇒ void
This method returns an undefined value.
Sets the sheet tab color.
|
|
# File 'lib/ironcalc/native_methods.rb', line 876
|
#set_user_input(sheet, row, column, value) ⇒ void
This method returns an undefined value.
Sets a cell's input, parsed as a user typing it would be: "3.5" is a
number, "Hello" a string, "=A1*2" a formula. Triggers recalculation.
|
|
# File 'lib/ironcalc/native_methods.rb', line 698
|
#to_bytes ⇒ String
Serializes the workbook to icalc bytes. This is IronCalc's internal format, not xlsx; see #to_xlsx_bytes.
|
|
# File 'lib/ironcalc/native_methods.rb', line 662
|
#to_xlsx_bytes ⇒ String
Serializes the workbook to xlsx bytes (load with IronCalc.create_user_model_from_xlsx_bytes).
|
|
# File 'lib/ironcalc/native_methods.rb', line 650
|
#undo ⇒ void
This method returns an undefined value.
Undoes the last change.
|
|
# File 'lib/ironcalc/native_methods.rb', line 682
|
#update_defined_name(name, scope, new_name, new_scope, new_formula) ⇒ void
This method returns an undefined value.
Renames, re-scopes and/or repoints an existing defined name.
|
|
# File 'lib/ironcalc/native_methods.rb', line 922
|
#update_range_style(range, style_path, value) ⇒ void
This method returns an undefined value.
Sets a single style property on every cell of a range, e.g. bold for
B2:C10: update_range_style({sheet: 0, row: 2, column: 2, width: 2,
height: 9}, "font.b", "true"). This is the user model's styling
primitive: the engine's UserModel has no whole-style setter.
|
|
# File 'lib/ironcalc/native_methods.rb', line 749
|