{"id":79,"date":"2026-02-23T17:26:53","date_gmt":"2026-02-23T09:26:53","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=79"},"modified":"2026-01-17T10:30:54","modified_gmt":"2026-01-17T10:30:54","slug":"how-to-set-face-properties-using-xlwings-single-color-gradient-fill","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-set-face-properties-using-xlwings-single-color-gradient-fill\/","title":{"rendered":"How To Set Face Properties Using xlwings? &#8211; Single Color Gradient Fill"},"content":{"rendered":"<h2>Method<\/h2>\n<p>Use the `OneColorGradient` method of the `FillFormat` object for single-color gradient fills. A single-color gradient fill involves a variation of a single color&#8217;s intensity.<\/p>\n<p>\u00a0<\/p>\n<p>ff.OneColorGradient(Style, Variant, Degree)<\/p>\n<p>\u00a0<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p>Name<\/p>\n<\/td>\n<td>\n<p>Required\/Optional<\/p>\n<\/td>\n<td>\n<p>Data Type<\/p>\n<\/td>\n<td>\n<p>Description<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Style<\/p>\n<\/td>\n<td>\n<p>Required<\/p>\n<\/td>\n<td>\n<p>MsoGradientStyle<\/p>\n<\/td>\n<td>\n<p>Gradient style<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Variant<\/p>\n<\/td>\n<td>\n<p>Required<\/p>\n<\/td>\n<td>\n<p>Integer<\/p>\n<\/td>\n<td>\n<p>Gradient variant (1 to 4)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Degree<\/p>\n<\/td>\n<td>\n<p>Required<\/p>\n<\/td>\n<td>\n<p>Single<\/p>\n<\/td>\n<td>\n<p>Degree of gradient (0.0 &#8211; dark to 1.0 &#8211; light)<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00a0<\/p>\n<p>shp1=sht.api.Shapes.AddShape(1, 100, 50, 200, 100)\u00a0\u00a0\u00a0 #Rectangular area<\/p>\n<p>ff1=shp1.Fill<\/p>\n<p>ff1.ForeColor.RGB= xw.utils.rgb_to_int((255,0,0))<\/p>\n<p>#Solid gradient fill, white to red, gradient from bottom-right to top-left<\/p>\n<p>ff1.OneColorGradient(3, 1, 1)<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Area properties - Two Color Gradient fill\n\nimport xlwings as xw    #Import xlwings package\n\napp=xw.App()\nbk=app.books.active   #Get the active workbook\nsht=bk.sheets.active    #Get the active worksheet\n\nshp1=sht.api.Shapes.AddShape(1, 100, 50, 200, 100)    #Rectangular area\nff1=shp1.Fill\nff1.ForeColor.RGB= xw.utils.rgb_to_int((255,0,0))    #Start color\nff1.TwoColorGradient(3, 1)    #Two-color gradient fill\nff1.BackColor.RGB= xw.utils.rgb_to_int((0, 255,0))    #End color\n\nshp2=sht.api.Shapes.AddShape(9, 400, 50, 200, 100)    #Elliptical area\nff2=shp2.Fill\nff2.ForeColor.RGB= xw.utils.rgb_to_int((0,0,255))    #Start color\nff2.TwoColorGradient(3, 1)    #Two-color gradient fill\nff2.BackColor.RGB= xw.utils.rgb_to_int((0, 255,0))    #End color\n\n#bk.save()\n#bk.close()\n#app.kill()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"883\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-7.png\" alt=\"Set Face Properties Using xlwings? - Single Color Gradient Fill\" class=\"wp-image-433\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-7.png 883w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-7-300x164.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-7-768x419.png 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Method<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-79","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/79","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"predecessor-version":[{"id":435,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/79\/revisions\/435"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}