Class RangeValues

class ooodev.utils.data_type.range_values.RangeValues(col_start, col_end, row_start, row_end, sheet_idx=-1)[source]

Range Parts. Intended to be zero-based indexes.

Changed in version 0.32.0: Added support for __contains__ and method. If sheet_idx is set to -2 then no attempt is made to get the sheet index from spreadsheet.

New in version 0.8.2.

Parameters:
  • col_start (int) –

  • col_end (int) –

  • row_start (int) –

  • row_end (int) –

  • sheet_idx (int) –

__init__(col_start, col_end, row_start, row_end, sheet_idx=-1)
Parameters:
  • col_start (int) –

  • col_end (int) –

  • row_start (int) –

  • row_end (int) –

  • sheet_idx (int) –

Return type:

None

add_cols(num: int)[source]
add_cols(num: int, to_end: bool)
add_cols(num, to_end=True)

Gets a new instance with cols added

Parameters:
  • num (int) – Number of row to add.

  • to_end (bool, optional) – If True then adds to col_end; Otherwise, subtracts from col_start. Defaults to True.

Raises:

ValueError – If adding cols result is negative

Returns:

Instance representing added value

Return type:

RangeValues

add_rows(num: int)[source]
add_rows(num: int, to_end: bool)
add_rows(num, to_end=True)

Gets a new instance with rows added

Parameters:
  • num (int) – Number of row to add.

  • to_end (bool, optional) – If True then adds to row_end; Otherwise, subtracts from row_start. Defaults to True.

Raises:

ValueError – If adding rows result is negative

Returns:

Instance representing added value

Return type:

RangeValues

contains(cell_obj: ooodev.utils.data_type.cell_obj.CellObj)[source]
contains(cell_addr: ooo.lo.table.cell_address.CellAddress)
contains(cell_vals: ooodev.utils.data_type.cell_values.CellValues)
contains(cell_name: str)
contains(*args, **kwargs)

Gets if current instance contains a cell value.

Parameters:
  • cell_obj (CellObj) – Cell object

  • cell_addr (CellAddress) – Cell address

  • cell_vals (CellValues) – Cell Values

  • cell_name (str) – Cell name

Returns:

True if instance contains cell; Otherwise, False.

Return type:

bool

Note

If cell input contains sheet info the it is use in comparison. Otherwise sheet is ignored.

static from_range(range_val: ooo.lo.table.cell_range_address.CellRangeAddress) ooodev.utils.data_type.range_values.RangeValues[source]
static from_range(range_val: ooodev.utils.data_type.range_obj.RangeObj) ooodev.utils.data_type.range_values.RangeValues
static from_range(range_val: str) ooodev.utils.data_type.range_values.RangeValues
static from_range(range_val)

Gets a RangeValues instance from a range

Parameters:
  • range (str | mRngObj.RangeObj | CellRangeAddress) – Range as object or string (A2:G23).

  • range_val (str | mRngObj.RangeObj | CellRangeAddress) –

Returns:

Object representing range values.

Return type:

RangeValues

get_cell_range_address()[source]

Gets a Cell Range Address

Returns:

Cell range Address

Return type:

CellRangeAddress

get_range_obj()[source]

Gets a RangeObj

Returns:

Range object.

Return type:

RangeObj

is_single_cell()[source]

Gets if a instance is a single cell or a range

Returns:

True if single cell; Otherwise, False

Return type:

bool

is_single_col()[source]

Gets if instance is a single column or multi-column

Returns:

True if single column; Otherwise, False

Return type:

bool

Note

If instance is a single cell address then True is returned.

is_single_row()[source]

Gets if instance is a single row or multi-row

Returns:

True if single row; Otherwise, False

Return type:

bool

Note

If instance is a single cell address then True is returned.

subtract_cols(num: int)[source]
subtract_cols(num: int, from_end: bool)
subtract_cols(num, from_end=True)

Gets a new instance with cols subtracted

Parameters:
  • num (int) – Number of cols to subtract.

  • from_end (bool, optional) – If True then subtracts from col_end; Otherwise, adds to col_start. Defaults to True.

Raises:

ValueError – If subtracting cols result is negative

Returns:

Instance representing subtracted value

Return type:

RangeValues

subtract_rows(num: int)[source]
subtract_rows(num: int, from_end: bool)
subtract_rows(num, from_end=True)

Gets a new instance with rows subtracted

Parameters:
  • num (int) – Number of row to add.

  • from_end (bool, optional) – If True then subtracts from row_end; Otherwise, adds to row_start. Defaults to True.

Raises:

ValueError – If subtracting rows result is negative

Returns:

Instance representing subtracted value

Return type:

RangeValues

col_end: int

Column end such as 3. Must be non-negative integer

col_start: int

Column start such as 0. Must be non-negative integer

row_end: int

Row end such as 125. Must be non-negative integer

row_start: int

Row start such as 0. Must be non-negative integer

sheet_idx: int = -1

Sheet index that this range value belongs to