vimsheet.model.sheet
Sheet model — a single tab in a workbook.
- class vimsheet.model.sheet.CondFormatRule(range_str, operator, value, value2=None, fmt=<factory>)[source]
Bases:
objectA conditional formatting rule applied to a range.
- Parameters:
range_str (str)
operator (str)
value (Any)
value2 (Any)
fmt (CellFormat)
- fmt: CellFormat
- class vimsheet.model.sheet.FilterRule(operator, value)[source]
Bases:
objectA column filter rule.
- class vimsheet.model.sheet.SortState(sort_keys)[source]
Bases:
objectRemembered sort configuration for a sheet.
- class vimsheet.model.sheet.Sheet(name, cells=<factory>, col_widths=<factory>, row_heights=<factory>, hidden_rows=<factory>, hidden_cols=<factory>, row_groups=<factory>, col_groups=<factory>, freeze_rows=0, freeze_cols=0, named_ranges=<factory>, cond_formats=<factory>, filters=<factory>, sort_state=None, max_row=0, max_col=0, validation=<factory>, cursor_row=0, cursor_col=0)[source]
Bases:
objectA single sheet (tab) inside a workbook.
- Parameters:
name (str)
freeze_rows (int)
freeze_cols (int)
named_ranges (NamedRangeRegistry)
cond_formats (list[CondFormatRule])
filters (dict[int, FilterRule])
sort_state (SortState | None)
max_row (int)
max_col (int)
validation (SheetValidation)
cursor_row (int)
cursor_col (int)
- named_ranges: NamedRangeRegistry
- cond_formats: list[CondFormatRule]
- filters: dict[int, FilterRule]
- validation: SheetValidation
- set_cell_value(row, col, value, formula=None, record_history=True)[source]
Set a cell’s value (and optional formula); create the cell if absent.
- set_cells_batch(updates)[source]
Set plain values for many cells in one pass, recalculating only once.
- clear_cells_batch(positions)[source]
Remove content from many cells in one pass, recalculating only once.
- insert_row(before_row)[source]
Insert a blank row before before_row, shifting cells down.
- Parameters:
before_row (int)
- Return type:
None
- delete_row(row)[source]
Delete row, shift cells up. Returns snapshot of deleted cells keyed by col.
- insert_col(before_col)[source]
Insert a blank column before before_col, shifting cells right.
- Parameters:
before_col (int)
- Return type:
None
- DEFAULT_COL_WIDTH = 10
- auto_fit_col(col)[source]
Set column width to the longest content in that column.
- Parameters:
col (int)
- Return type:
None
- used_range()[source]
Return the bounding CellRange of all non-empty cells, or None.
- Return type:
CellRange | None
- sort_by_cols(sort_keys)[source]
Sort cells in each specified column independently. Other columns unchanged.
- sort_range_columns(r1, c1, r2, c2, sort_keys)[source]
Sort each column within (r1,c1)-(r2,c2) independently. sort_keys is (col, ascending) pairs.
- __init__(name, cells=<factory>, col_widths=<factory>, row_heights=<factory>, hidden_rows=<factory>, hidden_cols=<factory>, row_groups=<factory>, col_groups=<factory>, freeze_rows=0, freeze_cols=0, named_ranges=<factory>, cond_formats=<factory>, filters=<factory>, sort_state=None, max_row=0, max_col=0, validation=<factory>, cursor_row=0, cursor_col=0)
- Parameters:
name (str)
freeze_rows (int)
freeze_cols (int)
named_ranges (NamedRangeRegistry)
cond_formats (list[CondFormatRule])
filters (dict[int, FilterRule])
sort_state (SortState | None)
max_row (int)
max_col (int)
validation (SheetValidation)
cursor_row (int)
cursor_col (int)
- Return type:
None