Class: IronCalc::Model
- Inherits:
-
Object
- Object
- IronCalc::Model
- Includes:
- DefinedNames
- Defined in:
- lib/ironcalc/native_methods.rb
Overview
Instance Method Summary collapse
-
#add_sheet(name) ⇒ void
Adds a new sheet with the given name.
-
#copy_cell_style(source_cell, destination_cell) ⇒ void
Copies one cell's style (and nothing else) onto another cell, in any sheet.
-
#delete_column_style(sheet, column) ⇒ void
Removes a column's default style.
-
#delete_columns(sheet, column, column_count) ⇒ void
Deletes
column_countcolumns starting atcolumn. -
#delete_defined_name(name, scope) ⇒ void
Deletes a defined name.
-
#delete_row_style(sheet, row) ⇒ void
Removes a row's default style.
-
#delete_rows(sheet, row, row_count) ⇒ void
Deletes
row_countrows starting atrow. - #delete_sheet(sheet) ⇒ void
-
#evaluate ⇒ void
Recalculates the whole workbook.
-
#get_all_cells ⇒ Array<Hash>
Every cell the workbook holds a record for, as
{ index:, row:, column: }hashes (+index+ is the 0-based sheet index), ordered by sheet, then row, then column. -
#get_cell_formula(sheet, row, column) ⇒ String?
The cell's formula including the leading
=, or nil if it is not a formula cell. -
#get_cell_type(sheet, row, column) ⇒ Symbol
Returns the cell type as a Symbol:
:number,:text,:logical_value,:error_value,:arrayor:compound_data. -
#get_cell_value_by_index(sheet, row, column) ⇒ nil, ...
The cell's value as a Ruby object — nil, String, Float or true/false — unformatted.
-
#get_cell_value_by_ref(cell_ref) ⇒ nil, ...
Like
get_cell_value_by_index, addressed by an A1-style reference that includes the sheet, e.g. -
#get_column_style(sheet, column) ⇒ Hash?
The default style for a whole column, as a Hash, or nil if the column carries no style of its own.
-
#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_localized_cell_content(sheet, row, column) ⇒ String
Returns the cell's content in the model's locale: the formula (e.g. "=A1+1") or literal text.
-
#get_row_height(sheet, row) ⇒ Float
Height in pixels.
-
#get_row_style(sheet, row) ⇒ Hash?
The default style for a whole row, as a Hash, or nil if the sheet holds no record for that row.
-
#get_sheet_dimensions(sheet) ⇒ Array(Integer, Integer, Integer, Integer)
Returns
[min_row, max_row, min_column, max_column]over non-empty cells (an empty sheet returns[1, 1, 1, 1]). -
#get_style_for_cell(sheet, row, column) ⇒ Hash
Returns the cell style as a Hash with Symbol keys, e.g.
-
#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
Inserts
column_countcolumns beforecolumn. -
#insert_rows(sheet, row, row_count) ⇒ void
Inserts
row_countrows beforerow. -
#insert_sheet(sheet_name, sheet_index, sheet_id) ⇒ void
Adds a sheet at
sheet_indexrather than appending it. - #is_column_hidden(sheet, column) ⇒ Boolean
-
#is_empty_cell(sheet, row, column) ⇒ Boolean
Whether the cell holds no content.
- #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.
-
#range_clear_all(area) ⇒ void
Clears the contents and style of every cell in a range, removing the cells entirely.
-
#range_clear_contents(range) ⇒ void
Clears the contents (not the style) of every cell in a range.
-
#rename_sheet(old_name, new_name) ⇒ void
Renames the sheet called
old_name. - #rename_sheet_by_index(sheet_index, 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.
- #set_column_hidden(sheet, column, hidden) ⇒ void
-
#set_column_style(sheet, column, style) ⇒ void
Sets the default style for a whole column.
- #set_column_width(sheet, column, width) ⇒ void
- #set_frozen_columns(sheet, frozen_columns) ⇒ void
- #set_frozen_rows(sheet, frozen_rows) ⇒ void
- #set_row_height(sheet, row, height) ⇒ void
- #set_row_hidden(sheet, row, hidden) ⇒ void
-
#set_row_style(sheet, row, style) ⇒ void
Sets the default style for a whole row.
-
#set_sheet_color(sheet, color) ⇒ void
Sets the sheet tab color.
-
#set_sheet_state(sheet, state) ⇒ void
Sets a sheet's visibility.
-
#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 (load with load_from_bytes).
-
#to_xlsx_bytes ⇒ String
Serializes the workbook to xlsx bytes (load with load_from_xlsx_bytes).
-
#update_cell_with_bool(sheet, row, column, value) ⇒ void
Sets a boolean without input parsing.
-
#update_cell_with_formula(sheet, row, column, formula) ⇒ void
Stores a formula directly.
-
#update_cell_with_number(sheet, row, column, value) ⇒ void
Sets a number without input parsing.
-
#update_cell_with_text(sheet, row, column, value) ⇒ void
Stores
valueas text without parsing it, so"007"stays"007"and +"=1+1"+ stays a string. -
#update_defined_name(name, scope, new_name, new_scope, new_formula) ⇒ void
Renames, re-scopes and/or repoints an existing defined name.
Methods included from DefinedNames
#defined_names, #valid_defined_name?
Instance Method Details
#add_sheet(name) ⇒ void
This method returns an undefined value.
Adds a new sheet with the given name.
|
|
# File 'lib/ironcalc/native_methods.rb', line 463
|
#copy_cell_style(source_cell, destination_cell) ⇒ void
This method returns an undefined value.
Copies one cell's style (and nothing else) onto another cell, in any sheet.
|
|
# File 'lib/ironcalc/native_methods.rb', line 323
|
#delete_column_style(sheet, column) ⇒ void
This method returns an undefined value.
Removes a column's default style.
|
|
# File 'lib/ironcalc/native_methods.rb', line 330
|
#delete_columns(sheet, column, column_count) ⇒ void
This method returns an undefined value.
Deletes column_count columns starting at column.
|
|
# File 'lib/ironcalc/native_methods.rb', line 368
|
#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 525
|
#delete_row_style(sheet, row) ⇒ void
This method returns an undefined value.
Removes a row's default style.
|
|
# File 'lib/ironcalc/native_methods.rb', line 337
|
#delete_rows(sheet, row, row_count) ⇒ void
This method returns an undefined value.
Deletes row_count rows starting at row.
|
|
# File 'lib/ironcalc/native_methods.rb', line 360
|
#delete_sheet(sheet) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 473
|
#evaluate ⇒ void
This method returns an undefined value.
Recalculates the whole workbook. Call after #set_user_input.
|
|
# File 'lib/ironcalc/native_methods.rb', line 220
|
#get_all_cells ⇒ Array<Hash>
Every cell the workbook holds a record for, as { index:, row:, column: }
hashes (+index+ is the 0-based sheet index), ordered by sheet, then row,
then column. A cell emptied with range_clear_contents keeps its record
and is still listed; combine with is_empty_cell if you only want cells
that have a value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 606
|
#get_cell_formula(sheet, row, column) ⇒ String?
The cell's formula including the leading =, or nil if it is not a
formula cell.
|
|
# File 'lib/ironcalc/native_methods.rb', line 595
|
#get_cell_type(sheet, row, column) ⇒ Symbol
Returns the cell type as a Symbol: :number, :text, :logical_value,
:error_value, :array or :compound_data.
|
|
# File 'lib/ironcalc/native_methods.rb', line 250
|
#get_cell_value_by_index(sheet, row, column) ⇒ nil, ...
The cell's value as a Ruby object — nil, String, Float or true/false —
unformatted. Compare get_formatted_cell_value, which always returns a
String, and get_localized_cell_content, which returns what the user typed.
The engine has no error variant here, so an error cell comes back as the
String "#DIV/0!" and is indistinguishable from that literal text. Use
get_cell_type, which reports :error_value, to tell them apart.
|
|
# File 'lib/ironcalc/native_methods.rb', line 577
|
#get_cell_value_by_ref(cell_ref) ⇒ nil, ...
Like get_cell_value_by_index, addressed by an A1-style reference that
includes the sheet, e.g. "Sheet1!C4".
|
|
# File 'lib/ironcalc/native_methods.rb', line 588
|
#get_column_style(sheet, column) ⇒ Hash?
The default style for a whole column, as a Hash, or nil if the column carries no style of its own.
|
|
# File 'lib/ironcalc/native_methods.rb', line 288
|
#get_column_width(sheet, column) ⇒ Float
Returns width in pixels.
|
|
# File 'lib/ironcalc/native_methods.rb', line 376
|
#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 498
|
#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 259
|
#get_frozen_columns_count(sheet) ⇒ Integer
|
|
# File 'lib/ironcalc/native_methods.rb', line 428
|
#get_frozen_rows_count(sheet) ⇒ Integer
|
|
# File 'lib/ironcalc/native_methods.rb', line 433
|
#get_localized_cell_content(sheet, row, column) ⇒ String
Returns the cell's content in the model's locale: the formula (e.g. "=A1+1") or literal text.
|
|
# File 'lib/ironcalc/native_methods.rb', line 241
|
#get_row_height(sheet, row) ⇒ Float
Returns height in pixels.
|
|
# File 'lib/ironcalc/native_methods.rb', line 382
|
#get_row_style(sheet, row) ⇒ Hash?
The default style for a whole row, as a Hash, or nil if the sheet holds no record for that row. A row whose style was deleted reads back as the default style rather than nil; the column equivalent returns nil.
|
|
# File 'lib/ironcalc/native_methods.rb', line 296
|
#get_sheet_dimensions(sheet) ⇒ Array(Integer, Integer, Integer, Integer)
Returns [min_row, max_row, min_column, max_column] over non-empty cells
(an empty sheet returns [1, 1, 1, 1]).
|
|
# File 'lib/ironcalc/native_methods.rb', line 491
|
#get_style_for_cell(sheet, row, column) ⇒ Hash
Returns the cell style as a Hash with Symbol keys, e.g.
{num_fmt: "general", font: {b: false, ...}, ...}.
|
|
# File 'lib/ironcalc/native_methods.rb', line 268
|
#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 450
|
#insert_columns(sheet, column, column_count) ⇒ void
This method returns an undefined value.
Inserts column_count columns before column.
|
|
# File 'lib/ironcalc/native_methods.rb', line 352
|
#insert_rows(sheet, row, row_count) ⇒ void
This method returns an undefined value.
Inserts row_count rows before row.
|
|
# File 'lib/ironcalc/native_methods.rb', line 344
|
#insert_sheet(sheet_name, sheet_index, sheet_id) ⇒ void
This method returns an undefined value.
Adds a sheet at sheet_index rather than appending it.
|
|
# File 'lib/ironcalc/native_methods.rb', line 614
|
#is_column_hidden(sheet, column) ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 402
|
#is_empty_cell(sheet, row, column) ⇒ Boolean
Whether the cell holds no content.
|
|
# File 'lib/ironcalc/native_methods.rb', line 601
|
#is_row_hidden(sheet, row) ⇒ Boolean
|
|
# File 'lib/ironcalc/native_methods.rb', line 415
|
#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 532
|
#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 505
|
#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 469
|
#range_clear_all(area) ⇒ void
This method returns an undefined value.
Clears the contents and style of every cell in a range, removing the
cells entirely. Compare range_clear_contents, which keeps the style.
|
|
# File 'lib/ironcalc/native_methods.rb', line 544
|
#range_clear_contents(range) ⇒ void
This method returns an undefined value.
Clears the contents (not the style) of every cell in a range.
|
|
# File 'lib/ironcalc/native_methods.rb', line 234
|
#rename_sheet(old_name, new_name) ⇒ void
This method returns an undefined value.
Renames the sheet called old_name.
|
|
# File 'lib/ironcalc/native_methods.rb', line 478
|
#rename_sheet_by_index(sheet_index, new_name) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 485
|
#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 209
|
#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 198
|
#set_cell_style(sheet, row, column, style) ⇒ void
This method returns an undefined value.
Sets the cell style. Takes a complete style, as returned by #get_style_for_cell: read one, change it, pass it back. Keys may be Symbols or Strings.
|
|
# File 'lib/ironcalc/native_methods.rb', line 277
|
#set_column_hidden(sheet, column, hidden) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 408
|
#set_column_style(sheet, column, style) ⇒ void
This method returns an undefined value.
Sets the default style for a whole column. Takes a complete style, as #set_cell_style does.
|
|
# File 'lib/ironcalc/native_methods.rb', line 305
|
#set_column_width(sheet, column, width) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 388
|
#set_frozen_columns(sheet, frozen_columns) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 438
|
#set_frozen_rows(sheet, frozen_rows) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 444
|
#set_row_height(sheet, row, height) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 395
|
#set_row_hidden(sheet, row, hidden) ⇒ void
This method returns an undefined value.
|
|
# File 'lib/ironcalc/native_methods.rb', line 421
|
#set_row_style(sheet, row, style) ⇒ void
This method returns an undefined value.
Sets the default style for a whole row. Takes a complete style, as #set_cell_style does.
|
|
# File 'lib/ironcalc/native_methods.rb', line 314
|
#set_sheet_color(sheet, color) ⇒ void
This method returns an undefined value.
Sets the sheet tab color.
|
|
# File 'lib/ironcalc/native_methods.rb', line 455
|
#set_sheet_state(sheet, state) ⇒ void
This method returns an undefined value.
Sets a sheet's visibility. Matches the :state value reported by
get_worksheets_properties.
|
|
# File 'lib/ironcalc/native_methods.rb', line 623
|
#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.
|
|
# File 'lib/ironcalc/native_methods.rb', line 224
|
#to_bytes ⇒ String
Serializes the workbook to icalc bytes (load with IronCalc.load_from_bytes). This is IronCalc's internal format, not xlsx; see #to_xlsx_bytes.
|
|
# File 'lib/ironcalc/native_methods.rb', line 215
|
#to_xlsx_bytes ⇒ String
Serializes the workbook to xlsx bytes (load with IronCalc.load_from_xlsx_bytes).
|
|
# File 'lib/ironcalc/native_methods.rb', line 204
|
#update_cell_with_bool(sheet, row, column, value) ⇒ void
This method returns an undefined value.
Sets a boolean without input parsing.
|
|
# File 'lib/ironcalc/native_methods.rb', line 565
|
#update_cell_with_formula(sheet, row, column, formula) ⇒ void
This method returns an undefined value.
Stores a formula directly. Call evaluate afterwards.
|
|
# File 'lib/ironcalc/native_methods.rb', line 571
|
#update_cell_with_number(sheet, row, column, value) ⇒ void
This method returns an undefined value.
Sets a number without input parsing.
|
|
# File 'lib/ironcalc/native_methods.rb', line 559
|
#update_cell_with_text(sheet, row, column, value) ⇒ void
This method returns an undefined value.
Stores value as text without parsing it, so "007" stays "007" and
+"=1+1"+ stays a string. Compare set_user_input, which parses.
|
|
# File 'lib/ironcalc/native_methods.rb', line 552
|
#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 515
|