vimsheet.model.workbook

Workbook model — a collection of sheets with session state.

class vimsheet.model.workbook.Workbook(sheets=<factory>, active_sheet_idx=0, filepath=None, modified=False, global_named_ranges=<factory>)[source]

Bases: object

Top-level container: sheets, filepath, and modification state.

Parameters:
sheets: list[Sheet]
active_sheet_idx: int = 0
filepath: Path | None = None
modified: bool = False
global_named_ranges: dict[str, str]
property active_sheet: Sheet

Return the currently active sheet.

get_sheet(name)[source]

Return the sheet with the given name, or None.

Parameters:

name (str)

Return type:

Sheet | None

get_sheet_index(name)[source]

Return the index of the sheet with name, or None.

Parameters:

name (str)

Return type:

int | None

add_sheet(name=None)[source]

Append a new blank sheet and return it.

Parameters:

name (str | None)

Return type:

Sheet

delete_sheet(name)[source]

Delete a sheet by name. Raises ValueError if it is the only sheet.

Parameters:

name (str)

Return type:

None

rename_sheet(old_name, new_name)[source]

Rename a sheet.

Parameters:
  • old_name (str)

  • new_name (str)

Return type:

None

duplicate_sheet(name=None)[source]

Duplicate a sheet by name (or active sheet if None). Appends with suffix.

Parameters:

name (str | None)

Return type:

Sheet

set_autocalc(value)[source]

Propagate autocalc setting to all sheets.

Parameters:

value (bool)

Return type:

None

go_to_next_sheet()[source]

Switch to the next sheet, wrapping around.

Return type:

None

go_to_prev_sheet()[source]

Switch to the previous sheet, wrapping around.

Return type:

None

go_to_sheet(idx)[source]

Switch to sheet at idx (0-based). Clamps to valid range.

Parameters:

idx (int)

Return type:

None

classmethod blank(sheet_name='Sheet1')[source]

Create a new blank workbook with one empty sheet.

Parameters:

sheet_name (str)

Return type:

Workbook

__init__(sheets=<factory>, active_sheet_idx=0, filepath=None, modified=False, global_named_ranges=<factory>)
Parameters:
Return type:

None