Shape#

class Shape(*args, **options)#

shapes 集合中的一员:

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

在 0.9.0 版本发生变更.

activate()#

激活形状(shape)。

在 0.5.0 版本加入.

property api#

返回正在使用的引擎的原生对象( pywin32appscript 对象)。

在 0.19.2 版本加入.

delete()#

删除形状。

在 0.5.0 版本加入.

property height#

返回或者设置形状的高度,单位是 point

在 0.5.0 版本加入.

property left#

返回或者设置代表形状的水平位置,单位是 point

在 0.5.0 版本加入.

property name#

返回形状的名称

在 0.5.0 版本加入.

property parent#

返回形状所属的对象。

在 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

在 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

在 0.19.2 版本加入.

property text#

Returns or sets the text of a shape.

在 0.21.4 版本加入.

property top#

返回或设置形状的垂直位置,单位为 point

在 0.5.0 版本加入.

property type#

返回形状的类型。

在 0.9.0 版本加入.

property width#

返回或者设置形状的宽度,单位是 point

在 0.5.0 版本加入.