How To Set Face Properties Using xlwings? – Solid Fill

Method

In Excel, a face is represented by the `FillFormat` object. You can access this object via the `Fill` property of a `Shape` object and then programmatically set its properties. 

 

You can specify the color using the `ForeColor` property and apply a solid fill using the `Solid` method.

 

shp=sht.api.Shapes.AddShape(9, 100, 50, 200, 100)

ff=shp.Fill

ff.ForeColor.RGB= xw.utils.rgb_to_int((255,0,0))

Sample Code

#Area properties - Solid color fill

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)
ff=shp.Fill
ff.ForeColor.RGB= xw.utils.rgb_to_int((255,0,0))

#bk.save()
#bk.close()
#app.kill()
Set Face Properties Using xlwings? - Solid Fill
February 23, 2026 (0)


Leave a Reply

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