Books

class Books(impl)

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]>])

在 0.9.0 版本加入.

property active: Book

返回活动工作簿。

add()

创建一个新的工作簿。新工作簿变成活动工作簿。返回一个工作簿对象。

async get_active()

Returns the active Book without pre-loading values.

This is the entry point to the async API, which reads on demand (lazy loading) instead of snapshotting the whole workbook up front. Requires xlwings Lite.

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

在 0.35.0 版本加入.

open(fullname=None, update_links=None, read_only=None, format=None, password=None, write_res_password=None, ignore_read_only_recommended=None, origin=None, delimiter=None, editable=None, notify=None, converter=None, add_to_mru=None, local=None, corrupt_load=None, json=None)

如果一个工作簿尚未打开,就打开并返回该工作簿。如果该工作簿已经打开了,不会触发异常,只是简单地返回该工作簿对象。

参数:
  • fullname (str | PathLike[str] | None) -- 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.

  • Parameters (Other)

  • see -- xlwings.Book()