Class: IronCalc::UserModel
- Inherits:
-
Object
- Object
- IronCalc::UserModel
- Defined in:
- lib/ironcalc/native_methods.rb,
lib/ironcalc/model.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 (the Hash convenience #set_cell_style is layered on top).
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
-
#clear_cell_contents(sheet, row, column) ⇒ void
Clears a cell’s contents (not its style).
- #delete_columns(sheet, column, column_count) ⇒ void
- #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 string keys, like Model#get_cell_style.
-
#get_cell_style_json(sheet, row, column) ⇒ String
private
JSON backing for ‘get_cell_style`.
-
#get_cell_type(sheet, row, column) ⇒ Symbol
Returns the cell type as a Symbol (see #get_cell_type).
-
#get_column_width(sheet, column) ⇒ Float
Width in pixels.
-
#get_formatted_cell_value(sheet, row, column) ⇒ String
Returns the cell’s value formatted as displayed.
- #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
-
#new_sheet ⇒ void
Adds a new sheet with an auto-generated name.
-
#redo ⇒ void
Redoes the last undone change.
- #rename_sheet(sheet, new_name) ⇒ void
-
#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_cell_style(sheet, row, column, style) ⇒ void
Sets the cell style from a Hash (or JSON string).
- #set_column_width(sheet, column, width) ⇒ void
- #set_frozen_columns_count(sheet, count) ⇒ void
- #set_frozen_rows_count(sheet, count) ⇒ void
- #set_row_height(sheet, row, height) ⇒ void
- #set_sheet_color(sheet, color) ⇒ void
-
#set_user_input(sheet, row, column, value) ⇒ void
Sets a cell’s raw input (literal or formula).
-
#to_bytes ⇒ String
Serializes the workbook to icalc bytes.
-
#undo ⇒ void
Undoes the last change.
-
#update_range_style(sheet, row, column, style_path, value) ⇒ void
Sets a single style property on a cell, e.g.
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 303
|
#can_redo ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 331
|
#can_undo ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 328
|
#clear_cell_contents(sheet, row, column) ⇒ void
This method returns an undefined value.
Clears a cell’s contents (not its style).
|
|
# File 'lib/ironcalc/native_methods.rb', line 343
|
#delete_columns(sheet, column, column_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 413
|
#delete_rows(sheet, row, row_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 406
|
#delete_sheet(sheet) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 484
|
#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 313
|
#flush_send_queue ⇒ String
Returns and clears the queued diffs to broadcast to collaborators.
|
|
# File 'lib/ironcalc/native_methods.rb', line 309
|
#get_cell_content(sheet, row, column) ⇒ String
Returns the cell’s content: formula or literal text.
|
|
# File 'lib/ironcalc/native_methods.rb', line 351
|
#get_cell_style(sheet, row, column) ⇒ Hash
Returns the cell style as a Hash with string keys, like Model#get_cell_style.
43 44 45 |
# File 'lib/ironcalc/model.rb', line 43 def get_cell_style(sheet, row, column) JSON.parse(get_cell_style_json(sheet, row, column)) end |
#get_cell_style_json(sheet, row, column) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
JSON backing for ‘get_cell_style`. Prefer the Hash-returning wrapper.
|
|
# File 'lib/ironcalc/native_methods.rb', line 375
|
#get_cell_type(sheet, row, column) ⇒ Symbol
Returns the cell type as a Symbol (see IronCalc#get_cell_type).
|
|
# File 'lib/ironcalc/native_methods.rb', line 359
|
#get_column_width(sheet, column) ⇒ Float
Returns width in pixels.
|
|
# File 'lib/ironcalc/native_methods.rb', line 420
|
#get_formatted_cell_value(sheet, row, column) ⇒ String
Returns the cell’s value formatted as displayed.
|
|
# File 'lib/ironcalc/native_methods.rb', line 367
|
#get_frozen_columns_count(sheet) ⇒ Integer
|
|
# File 'lib/ironcalc/native_methods.rb', line 446
|
#get_frozen_rows_count(sheet) ⇒ Integer
|
|
# File 'lib/ironcalc/native_methods.rb', line 451
|
#get_row_height(sheet, row) ⇒ Float
Returns height in pixels.
|
|
# File 'lib/ironcalc/native_methods.rb', line 426
|
#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 495
|
#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 468
|
#insert_columns(sheet, column, column_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 399
|
#insert_rows(sheet, row, row_count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 392
|
#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 479
|
#redo ⇒ void
This method returns an undefined value.
Redoes the last undone change.
|
|
# File 'lib/ironcalc/native_methods.rb', line 323
|
#rename_sheet(sheet, new_name) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 489
|
#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 293
|
#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 287
|
#set_cell_style(sheet, row, column, style) ⇒ void
This method returns an undefined value.
Sets the cell style from a Hash (or JSON string). The user model has no whole-style setter; styling is per-property via the engine’s #update_range_style (mirroring the WASM binding). This convenience flattens the Hash and applies each leaf with #update_range_style.
58 59 60 61 62 63 |
# File 'lib/ironcalc/model.rb', line 58 def set_cell_style(sheet, row, column, style) desired = style.is_a?(String) ? JSON.parse(style) : style flatten_style(desired).each do |path, value| update_range_style(sheet, row, column, path, value.to_s) end end |
#set_column_width(sheet, column, width) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 432
|
#set_frozen_columns_count(sheet, count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 456
|
#set_frozen_rows_count(sheet, count) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 462
|
#set_row_height(sheet, row, height) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 439
|
#set_sheet_color(sheet, color) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 473
|
#set_user_input(sheet, row, column, value) ⇒ void
This method returns an undefined value.
Sets a cell’s raw input (literal or formula). Triggers recalculation.
|
|
# File 'lib/ironcalc/native_methods.rb', line 334
|
#to_bytes ⇒ String
Serializes the workbook to icalc bytes.
|
|
# File 'lib/ironcalc/native_methods.rb', line 299
|
#undo ⇒ void
This method returns an undefined value.
Undoes the last change.
|
|
# File 'lib/ironcalc/native_methods.rb', line 318
|
#update_range_style(sheet, row, column, style_path, value) ⇒ void
This method returns an undefined value.
Sets a single style property on a cell, e.g. update_range_style(0, 1, 1, “font.b”, “true”). This is the user model’s styling primitive (mirrors the WASM binding); ‘set_cell_style` wraps it for whole-Hash convenience.
|
|
# File 'lib/ironcalc/native_methods.rb', line 380
|