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:

>>> # Assumes an existing workbook object named book.
>>> book.names
[<Name 'MyName': =Sheet1!$A$3>]
>>> book.sheets[0].names  # sheet scope only

Added in version 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 classic xlwings, 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

Added in version 0.9.0.

property api: Any

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

Added in version 0.9.0.

property count: int

コレクションに含まれるオブジェクトの数を返します。