Shape

class Shape(*args, **options)

The shape object is a member of the shapes collection:

>>> # Assumes an existing workbook object named book.
>>> sheet = book.sheets[0]
>>> sheet.shapes[0]  # or sheet.shapes['ShapeName']
<Shape 'Rectangle 1' in Sheet1>

バージョン 0.9.0 で変更.

activate()

Shapeをアクティブにします。

Added in version 0.5.0.

property api: Any

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

Added in version 0.19.2.

property characters: Characters

Returns the Characters object for the shape text, used to format part of the text.

delete()

Shapeを削除します。

Added in version 0.5.0.

property font: Font

Returns the Font object for the shape text, used to read or change font formatting.

async get_text()

Fetch the shape's text on demand.

None if the shape holds no text.

Requires xlwings Lite.

戻り値の型:

str | None

property height: float

Shapeの高さを表すポイント単位の数値を取得または設定します。

Added in version 0.5.0.

property left: float

Shapeの水平位置を表すポイント単位の数値を取得または設定します。

Added in version 0.5.0.

property name: str

Shapeの名前を取得または設定します。

Added in version 0.5.0.

property parent: Sheet

Shapeの親オブジェクトを返します。

Added in version 0.9.0.

scale_height(factor, relative_to_original_size=False, scale='scale_from_top_left')
パラメータ:
  • factor (float) -- 例えば、1.5なら150%に拡大します。

  • relative_to_original_size (bool) -- False の場合、現在の高さからの相対的な大きさで拡大縮小します (デフォルト)。True は図またはOLE objectでなければなりません。

  • scale (str) -- scale_from_top_left (デフォルト)、 scale_from_bottom_right 、 scale_from_middle のいずれか。

Added in version 0.19.2.

scale_width(factor, relative_to_original_size=False, scale='scale_from_top_left')
パラメータ:
  • factor (float) -- 例えば、1.5なら150%に拡大します。

  • relative_to_original_size (bool) -- False の場合、現在の幅からの相対的な大きさで拡大縮小します (デフォルト)。True は図またはOLE objectでなければなりません。

  • scale (str) -- scale_from_top_left (デフォルト)、 scale_from_bottom_right 、 scale_from_middle のいずれか。

Added in version 0.19.2.

property text: str

Shapeのテキストを取得または設定します。

Setter type:

Any

Added in version 0.21.4.

property top: float

Shapeの垂直位置を表すポイント単位の数値を取得または設定します。

Added in version 0.5.0.

property type: str

Shapeの種類を返します。

Added in version 0.9.0.

property width: float

Shapeの幅を表すポイント単位の数値を取得または設定します。

Added in version 0.5.0.