Sheets

class Sheets(impl: Any)

全部工作表对象 sheet 的集合:

>>> import xlwings as xw
>>> xw.sheets  # active book
Sheets([<Sheet [Book1]Sheet1>, <Sheet [Book1]Sheet2>])
>>> xw.Book('Book1').sheets  # specific book
Sheets([<Sheet [Book1]Sheet1>, <Sheet [Book1]Sheet2>])

在 0.9.0 版本加入.

property active: Sheet

返回活动的工作表(Sheet)。

add(name: str | None = None, before: Sheet | None = None, after: Sheet | None = None) Sheet

创建一个新的工作表并设为活动工作表。

参数

namestr, default None

新工作表的名字,如果没有就使用Excel给的缺省名字。

beforeSheet, default None

在新增工作表前面的工作表对象。

afterSheet, default None

在新增工作表后面的工作表对象。

返回

sheetSheet

Added sheet object

async get_active() Sheet

Returns the active Sheet, fetched live from Excel.

Requires xlwings Lite.

在 0.35.0 版本加入.