Books

class Books(impl: Any)

A collection of all book objects:

>>> import xlwings as xw
>>> xw.books  # active app
Books([<Book [Book1]>, <Book [Book2]>])
>>> xw.apps[10559].books  # specific app, get the PIDs via xw.apps.keys()
Books([<Book [Book1]>, <Book [Book2]>])

Added in version 0.9.0.

property active: Book

Returns the active Book.

add() Book

Creates a new Book. The new Book becomes the active Book. Returns a Book object.

async get_active() Book

Returns the active Book without pre-loading values (lazy loading).

Requires xlwings Lite.

Use await myrange.get_value() to read cell values on demand.

Added in version 0.35.0.

open(fullname: str | PathLike[str] | None = None, update_links: bool | None = None, read_only: bool | None = None, format: str | None = None, password: str | None = None, write_res_password: str | None = None, ignore_read_only_recommended: bool | None = None, origin: int | None = None, delimiter: str | None = None, editable: bool | None = None, notify: bool | None = None, converter: int | None = None, add_to_mru: bool | None = None, local: bool | None = None, corrupt_load: int | None = None, json: dict[str, Any] | None = None) Book

Opens a Book if it is not open yet and returns it. If it is already open, it doesn’t raise an exception but simply returns the Book object.

Parameters

fullnamestr or path-like object

filename or fully qualified filename, e.g. r'C:\path\to\file.xlsx' or 'file.xlsm'. Without a full path, it looks for the file in the current working directory.

Other Parameters

see: xlwings.Book()

Returns

Book : Book that has been opened.