How To Set Face Properties Using xlwings? – Picture Fill

Method

Use the `UserPicture` method of the `FillFormat` object for picture fills.

 

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

ff1=shp1.Fill

ff1.UserPicture(r”D:\picpy.jpg”)    #Picture fill

Sample Code

#Area properties - Texture fill

import xlwings as xw    #Import xlwings package
import os
root = os.getcwd()
app=xw.App()
bk=app.books.active   #Get the active workbook
sht=bk.sheets.active    #Get the active worksheet

shp1=sht.api.Shapes.AddShape(1, 100, 50, 200, 100)    #Rectangular area
ff1=shp1.Fill
ff1.UserTextured(r"D:/picpy.jpg")    #Texture fill

shp2=sht.api.Shapes.AddShape(9, 400, 50, 200, 100)    #Elliptical area
ff2=shp2.Fill
ff2.UserTextured(r"D:/picpy.jpg")    #Texture fill

#bk.save()
#bk.close()
#app.kill()
How To Set Face Properties Using xlwings? - Picture Fill
February 25, 2026 (0)


Leave a Reply

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