{"id":517,"date":"2026-03-26T18:01:51","date_gmt":"2026-03-26T10:01:51","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=517"},"modified":"2026-03-23T06:18:22","modified_gmt":"2026-03-23T06:18:22","slug":"how-to-set-transparency-and-color-fill-of-areas-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-set-transparency-and-color-fill-of-areas-using-xlwings\/","title":{"rendered":"How To Set Transparency and Color Fill of Areas Using xlwings?"},"content":{"rendered":"<p>\u3010<b>Method<\/b>\u3011<\/p>\n<p>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.<\/p>\n<p>&#8211; Transparency property<\/p>\n<p>&#8211; ForeColor property<\/p>\n<p>&#8211; OneColorGradient method<\/p>\n<p>&#8211; TwoColorGradient method<\/p>\n<p>&#8211; Solid method<\/p>\n<p>sht.api.Range(&#8216;A1:B7&#8217;).Select()<\/p>\n<p>cht=sht.api.Shapes.AddChart().Chart<\/p>\n<p>ser=cht.SeriesCollection(&#8216;P1&#8217;)\u00a0\u00a0\u00a0 #First series<\/p>\n<p>ff=ser.Format.Fill<\/p>\n<p>ff.Transparency=0.7<\/p>\n<p>ser2=cht.SeriesCollection(&#8216;P2&#8217;)\u00a0\u00a0\u00a0 #Second series<\/p>\n<p>ff2=ser2.Format.Fill<\/p>\n<p>ff2.OneColorGradient(1,1,1)<\/p>\n\n\n<p>\u3010<strong>Example<\/strong>\u3011<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"880\" height=\"768\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-01-2.jpg\" alt=\"\" class=\"wp-image-1107\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-01-2.jpg 880w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-01-2-300x262.jpg 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-01-2-768x670.jpg 768w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/figure>\n\n\n\n<p>\u3010<strong>Code<\/strong>\u3011<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#Area settings - Transparency and solid gradient\n\nimport xlwings as xw\nimport os\n\nroot = os.getcwd()\napp = xw.App(visible=True, add_book=False)\nwb=app.books.open(root+r'\/P1P2.xlsx',read_only=False)\nsht=wb.sheets(1)\n\nsht.api.Range('A1:B7').Select()\ncht=sht.api.Shapes.AddChart().Chart\nser=cht.SeriesCollection('P1')    #First series\nff=ser.Format.Fill\nff.Transparency=0.7\nser2=cht.SeriesCollection('P2')    #Second series\nff2=ser2.Format.Fill\nff2.OneColorGradient(1,1,1)\n\n#wb.save()\n#wb.close()\n#app.kill()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"880\" height=\"768\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-04.jpg\" alt=\"\" class=\"wp-image-1108\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-04.jpg 880w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-04-300x262.jpg 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/2-04-768x670.jpg 768w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Method<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-517","post","type-post","status-publish","format-standard","hentry","category-xlwings-chart"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=517"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/517\/revisions"}],"predecessor-version":[{"id":1109,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/517\/revisions\/1109"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}