batpy.batpy_workbook

Module, which includes the basic workbook class

Classes

BatpyWorkbook

Base class to interact with workbooks

Module Contents

class batpy.batpy_workbook.BatpyWorkbook(batpy_workbook_path: pathlib.Path, workbook_visible: bool = False)

Base class to interact with workbooks

version
workbook
properties
__del__() → None

Destructor of batpy workbook object

Set the workbook calculation method to “automatic” and the “screen_updating” to True after object destruction.

save(path: pathlib.Path = None) → None

Save batpy workbook

Save the batpy workbook or save the batpy workbook in another path.

Parameters:

path (Path, optional) – If the path is specified, the batpy workbook will be saved under the path, by default None will overwrite the current batpy workbook.

close() → bool

Close batpy workbook

Close the batpy workbook if other workbooks are open, otherwise the Excel instance will be closed.

Returns:

True, if batpy workbook is closed.

Return type:

bool

stop_automatic_calculation() → None

Stop automatic Excel calculation

start_automatic_calculation() → None

Start automatic Excel calculation

is_version_compatible(version_to_check: semantic_version.Version, include_minor: bool = False) → bool

Check for version compatibility

Check if two versions (major.minor.patch) are compatible. Thereby a version is compatible if major is equal. If minor should also be included a version is compatible if major is equal and minor is greater or equal.

Parameters:
  • version_to_check (semantic_version.Version) – Version to be checked against self.version.

  • include_minor (bool, optional) – Check if minor version of version_to_check is greater or equal to self.version’s minor, by default False.

Returns:

True, if version is compatible.

Return type:

bool

Raises:

ValueError – If version is not compatible a ValueError will occur.

_load_user_configuration(path_to_configuration: pathlib.Path | str) → dict

Load configuration

Loads a single configuration from a TOML file or string.

Parameters:

path_to_configuration (Path | str) – Path to the TOML configuration file or configuration as string.

Returns:

Returns dictionary representation of configuration.

Return type:

dict

_write_value_direct(worksheet: str, cell_range: str, value: any) → None

Write value in batpy workbook

Write a value directly in the batpy workbook.

Parameters:
  • worksheet (str) – Name of the batpy workbook worksheet.

  • cell_range (str) – Cell range of the batpy workbook.

  • value (any) – Value to write in the batpy workbook.

_read_value_direct(worksheet: str, cell_range: str) → any

Read value from batpy workbook

Read a value directly from the batpy workbook.

Parameters:
  • worksheet (str) – Name of the batpy workbook worksheet.

  • cell_range (str) – Cell range of the batpy workbook.

Returns:

Value of the batpy workbook cell.

Return type:

any

Raises:

KeyError – Raises KeyError if the specified worksheet or range could not be found.