Shape#

class Shape(*args, **options)#

The shape object is a member of the shapes collection:

>>> import xlwings as xw
>>> sht = xw.books['Book1'].sheets[0]
>>> sht.shapes[0]  # or sht.shapes['ShapeName']
<Shape 'Rectangle 1' in <Sheet [Book1]Sheet1>>

Changed in version 0.9.0.

activate()#

Activates the shape.

New in version 0.5.0.

property api#

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

New in version 0.19.2.

delete()#

Deletes the shape.

New in version 0.5.0.

property height#

Returns or sets the number of points that represent the height of the shape.

New in version 0.5.0.

property left#

Returns or sets the number of points that represent the horizontal position of the shape.

New in version 0.5.0.

property name#

Returns or sets the name of the shape.

New in version 0.5.0.

property parent#

Returns the parent of the shape.

New in version 0.9.0.

scale_height(factor, relative_to_original_size=False, scale='scale_from_top_left')#
factorfloat

For example 1.5 to scale it up to 150%

relative_to_original_sizebool, optional

If False, it scales relative to current height (default). For True must be a picture or OLE object.

scalestr, optional

One of scale_from_top_left (default), scale_from_bottom_right, scale_from_middle

New in version 0.19.2.

scale_width(factor, relative_to_original_size=False, scale='scale_from_top_left')#
factorfloat

For example 1.5 to scale it up to 150%

relative_to_original_sizebool, optional

If False, it scales relative to current width (default). For True must be a picture or OLE object.

scalestr, optional

One of scale_from_top_left (default), scale_from_bottom_right, scale_from_middle

New in version 0.19.2.

property text#

Returns or sets the text of a shape.

New in version 0.21.4.

property top#

Returns or sets the number of points that represent the vertical position of the shape.

New in version 0.5.0.

property type#

Returns the type of the shape.

New in version 0.9.0.

property width#

Returns or sets the number of points that represent the width of the shape.

New in version 0.5.0.