Class: IronCalc::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/ironcalc/native_methods.rb,
lib/ironcalc/model.rb

Overview

The raw IronCalc API. You must call #evaluate yourself after changing inputs; misuse can leave the workbook in an inconsistent state. This mirrors the Python binding’s ‘Model`. For most uses prefer UserModel, which auto-evaluates.

Instance Method Summary collapse

Instance Method Details

#get_cell_style(sheet, row, column) ⇒ Hash

Returns the cell style as a Hash with string keys (snake_case, matching the engine’s serde field names), e.g.

{ "num_fmt" => "general", "font" => { "b" => false, ... }, ... }

Parameters:

  • sheet (Integer)

    0-based sheet index

  • row (Integer)

    1-based row

  • column (Integer)

    1-based column

Returns:

  • (Hash)

Raises:

  • (IronCalc::Error)


17
18
19
# File 'lib/ironcalc/model.rb', line 17

def get_cell_style(sheet, row, column)
  JSON.parse(get_cell_style_json(sheet, row, column))
end

#set_cell_style(sheet, row, column, style) ⇒ void

This method returns an undefined value.

Sets the cell style from a Hash (snake_case keys) or a JSON string.

Parameters:

  • sheet (Integer)

    0-based sheet index

  • row (Integer)

    1-based row

  • column (Integer)

    1-based column

  • style (Hash, String)

    the full style as a Hash or JSON string

Raises:

  • (IronCalc::Error)


29
30
31
32
# File 'lib/ironcalc/model.rb', line 29

def set_cell_style(sheet, row, column, style)
  json = style.is_a?(String) ? style : JSON.generate(style)
  set_cell_style_json(sheet, row, column, json)
end