【Method】
By referencing the `Format.Fill` property of the Series object, a `FillFormat` object is returned, representing the area object in the series. The members of the `FillFormat` object can be used to set properties for the area object.
– Transparency property
– ForeColor property
– OneColorGradient method
– TwoColorGradient method
– Solid method
sht.api.Range(‘A1:B7’).Select()
cht=sht.api.Shapes.AddChart().Chart
ser=cht.SeriesCollection(‘P1’) #First series
ff=ser.Format.Fill
ff.Transparency=0.7
ser2=cht.SeriesCollection(‘P2’) #Second series
ff2=ser2.Format.Fill
ff2.OneColorGradient(1,1,1)
【Example】

【Code】
#Area settings - Transparency and solid gradient
import xlwings as xw
import os
root = os.getcwd()
app = xw.App(visible=True, add_book=False)
wb=app.books.open(root+r'/P1P2.xlsx',read_only=False)
sht=wb.sheets(1)
sht.api.Range('A1:B7').Select()
cht=sht.api.Shapes.AddChart().Chart
ser=cht.SeriesCollection('P1') #First series
ff=ser.Format.Fill
ff.Transparency=0.7
ser2=cht.SeriesCollection('P2') #Second series
ff2=ser2.Format.Fill
ff2.OneColorGradient(1,1,1)
#wb.save()
#wb.close()
#app.kill()

Leave a Reply