Names

class Names

A collection of defined name objects in the workbook.

Excel's internal _xlfn.* and _xlpm.* names are excluded. Hidden user-defined names remain available. The native collection is unchanged. Iteration snapshots name objects so new internal names cannot shift it.

Examples:

>>> import xlwings as xw
>>> book = xw.books['Book1']  # book scope and sheet scope
>>> book.names
[<Name 'MyName': =Sheet1!$A$3>]
>>> book.sheets[0].names  # sheet scope only

在 0.9.0 版本加入.

add(name, refers_to)

Defines a new name for a range, constant, or formula (including a LAMBDA).

Full support for named constants and formulas requires Excel desktop, xlwings Lite, or xlwings Server. Google Sheets supports named ranges only; Office Scripts only returns named ranges in its snapshot.

参数:
  • name (str) -- 指定作为名称的文字。名称中不能包含空格,也不能是单元格的引用。

  • refers_to (str) -- 使用英语,按照 A1表示法 描述名称引用的具体内容

返回类型:

Name

在 0.9.0 版本加入.

property api: Any

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

在 0.9.0 版本加入.

property count: int

返回集合中的对象数。