Sheets

class Sheets

A collection of all sheet objects:

>>> 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=None, before=None, after=None)

Creates a new Sheet and makes it the active sheet. Returns the added sheet.

参数:
  • name (str | None) -- 新工作表的名字,如果没有就使用Excel给的缺省名字。

  • before (Sheet | None) -- 在新增工作表前面的工作表对象。

  • after (Sheet | None) -- 在新增工作表后面的工作表对象。

返回类型:

Sheet

property api: Any

Returns the native object (pywin32 or appscript obj) of the engine being used.

property count: int

返回集合中的对象数。

async get_active()

Returns the active Sheet, fetched live from Excel.

Requires xlwings Lite.

在 0.35.0 版本加入.

返回类型:

Sheet