xlwings: Shapes: Curves

Use the `AddCurve` method of the Shapes object to create a curve. The method syntax is:

sht.api.Shapes.AddCurve(SafeArrayOfPoints)

Where `sht` refers to a worksheet object. The parameter `SafeArrayOfPoints` specifies the coordinates of the Bezier curve’s vertices and control points. The number of points should always be 3n + 1, where n is the number of line segments in the curve. This method returns a Shape object representing the Bezier curve.

Code:

#Drawing Curves

from comtypes.client import CreateObject

app=CreateObject('Excel.Application')
app.Visible=True
bk=app.Workbooks.Add()
sht=bk.Sheets(1)

pts=[[0,0],[72,72],[100,40],[20,50],[90,120],[60,30],[150,90]]    #Vertices
sht.Shapes.AddCurve(pts)    #Add Bezier curve

#bk.save()
#bk.close()
#app.kill()


category : xlwings: Shapes

Leave a Reply

Your email address will not be published. Required fields are marked *

Zoomed Image