Raw API Reference

In general methods in IronCalc use a 0-index base for the the sheet index and 1-index base for the row and column indexes.

evaluate()

Evaluates the model. This needs to be done after each change, otherwise the model might be on a broken state.

set_user_input(sheet: int, row: int, column: int, value: str)

Sets an input in a cell, as would be done by a user typing into a spreadsheet cell.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index (first row is 1).

  • column – The 1-based column index (column “A” is 1).

  • value – The value to set, e.g. "123" or "=A1*2".

clear_cell_contents(sheet: int, row: int, column: int)

Removes the content of the cell but leaves the style intact.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index (first row is 1).

  • column – The 1-based column index (column “A” is 1).

get_cell_content(sheet: int, row: int, column: int) str

Returns the raw content of a cell. If the cell contains a formula, the returned string starts with "=".

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index.

  • column – The 1-based column index.

Returns:

The raw content, or an empty string if the cell is empty.

get_cell_type(sheet: int, row: int, column: int) PyCellType

Returns the type of the cell (number, boolean, string, error, etc.).

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index.

  • column – The 1-based column index.

Return type:

PyCellType

get_formatted_cell_value(sheet: int, row: int, column: int) str

Returns the cell’s value as a formatted string, taking into account any number/currency/date formatting.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index.

  • column – The 1-based column index.

Returns:

Formatted string of the cell’s value.

set_cell_style(sheet: int, row: int, column: int, style: PyStyle)

Sets the style of the cell at (sheet, row, column).

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index.

  • column – The 1-based column index.

  • style – A PyStyle object specifying the style.

get_cell_style(sheet: int, row: int, column: int) PyStyle

Retrieves the style of the specified cell.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index.

  • column – The 1-based column index.

Returns:

A PyStyle object describing the cell’s style.

insert_rows(sheet: int, row: int, row_count: int)

Inserts new rows.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The position before which new rows are inserted (1-based).

  • row_count – The number of rows to insert.

insert_columns(sheet: int, column: int, column_count: int)

Inserts new columns.

Parameters:
  • sheet – The sheet index (0-based).

  • column – The position before which new columns are inserted (1-based).

  • column_count – The number of columns to insert.

delete_rows(sheet: int, row: int, row_count: int)

Deletes a range of rows.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The starting row to delete (1-based).

  • row_count – How many rows to delete.

delete_columns(sheet: int, column: int, column_count: int)

Deletes a range of columns.

Parameters:
  • sheet – The sheet index (0-based).

  • column – The starting column to delete (1-based).

  • column_count – How many columns to delete.

get_column_width(sheet: int, column: int) float

Retrieves the width of a given column.

Parameters:
  • sheet – The sheet index (0-based).

  • column – The 1-based column index.

Return type:

float

get_row_height(sheet: int, row: int) float

Retrieves the height of a given row.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index.

Return type:

float

set_column_width(sheet: int, column: int, width: float)

Sets the width of a given column.

Parameters:
  • sheet – The sheet index (0-based).

  • column – The 1-based column index.

  • width – The desired width (float).

set_row_height(sheet: int, row: int, height: float)

Sets the height of a given row.

Parameters:
  • sheet – The sheet index (0-based).

  • row – The 1-based row index.

  • height – The desired height (float).

get_frozen_columns_count(sheet: int) int

Returns the number of columns frozen (pinned) on the left side of the sheet.

Parameters:

sheet – The sheet index (0-based).

Return type:

int

get_frozen_rows_count(sheet: int) int

Returns the number of rows frozen (pinned) at the top of the sheet.

Parameters:

sheet – The sheet index (0-based).

Return type:

int

set_frozen_columns_count(sheet: int, column_count: int)

Sets how many columns are frozen (pinned) on the left.

Parameters:
  • sheet – The sheet index (0-based).

  • column_count – The number of frozen columns (0-based).

set_frozen_rows_count(sheet: int, row_count: int)

Sets how many rows are frozen (pinned) at the top.

Parameters:
  • sheet – The sheet index (0-based).

  • row_count – The number of frozen rows (0-based).

get_worksheets_properties() List[PySheetProperty]

Returns a list of PySheetProperty describing each worksheet’s name, visibility state, ID, and tab color.

Return type:

list of PySheetProperty

set_sheet_color(sheet: int, color: str)

Sets the tab color of a sheet. Use an empty string to clear the color.

Parameters:
  • sheet – The sheet index (0-based).

  • color – A color in “#RRGGBB” format, or empty to remove color.

add_sheet(sheet_name: str)

Creates a new sheet with the specified name.

Parameters:

sheet_name – The name to give the new sheet.

new_sheet()

Creates a new sheet with an auto-generated name.

delete_sheet(sheet: int)

Deletes the sheet at the given index.

Parameters:

sheet – The sheet index (0-based).

rename_sheet(sheet: int, new_name: str)

Renames the sheet at the given index.

Parameters:
  • sheet – The sheet index (0-based).

  • new_name – The new sheet name.

test_panic()

A test method that deliberately panics in Rust. Used for testing panic handling at the method level.

Raises:

WorkbookError – (wrapped Rust panic)