How To Implement Graphic Rotation Using xlwings?

Method

Use the `IncrementRotation` method of the `Shape` object to rotate the graphic. This method rotates the graphic around the Z-axis by a specified angle. It has one parameter, representing the angle of rotation in degrees. A positive value rotates the graphic clockwise, while a negative value rotates the graphic counterclockwise.

 

shp=sht.api.Shapes.AddShape(1, 100, 50, 200, 100)    #Rectangular area

shp.Fill.PresetTextured(5)    #Preset texture: Water drop

shp.IncrementRotation(30)    #Rotate clockwise by 30°°

Sample Code

#Scaling transformation

import xlwings as xw    #Import xlwings package

app=xw.App()
bk=app.books.active   #Get the active workbook
sht=bk.sheets.active    #Get the active worksheet

shp=sht.api.Shapes.AddShape(9, 100, 50, 200, 100)    #Elliptical area
ff=shp.Fill
ff.PresetTextured(12)    #Preset texture: Granite
shp.ScaleWidth(0.75,False)    #Width × 0.75
shp.ScaleHeight(1.75,False)    #Height × 1.75

#bk.save()
#bk.close()
#app.kill()
Implement Graphic Rotation Using xlwings
February 28, 2026 (0)


Leave a Reply

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