{"id":73,"date":"2026-02-20T17:03:09","date_gmt":"2026-02-20T09:03:09","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=73"},"modified":"2026-01-17T10:23:07","modified_gmt":"2026-01-17T10:23:07","slug":"how-to-set-color-using-xlwings-scheme-colors","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-set-color-using-xlwings-scheme-colors\/","title":{"rendered":"How To Set Color Using xlwings? &#8211; Scheme Colors"},"content":{"rendered":"<h2>Method<\/h2>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">Excel provides a set of colors from its color scheme that can be used to fill graphical objects. For graphical objects, the `ForeColor` and `BackColor` properties return a `ColorFormat` object, which includes a `SchemeColor` property. Each color in the color scheme has an index number, which can be assigned to the `SchemeColor` property.<\/p>\n<p style=\"margin: 0in; margin-left: .375in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 8.0pt;\">\u00a0<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">shp=sht.api.Shapes.AddShape(9, 50, 50, 100, 100)<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">shp.Fill.ForeColor.<span style=\"font-weight: bold;\">SchemeColor<\/span>=3<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">shp.Line.ForeColor.<span style=\"font-weight: bold;\">SchemeColor<\/span>=4<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Color - Scheme color\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\nshp=sht.api.Shapes.AddShape(9, 50, 50, 100, 100)\nshp.Fill.ForeColor.SchemeColor=3\nshp.Line.ForeColor.SchemeColor=4\n\n#bk.save()\n#bk.close()\n#app.kill()\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"749\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-1.png\" alt=\"Set Color Using xlwings? - Scheme Colors\" class=\"wp-image-417\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-1.png 749w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-1-300x193.png 300w\" sizes=\"auto, (max-width: 749px) 100vw, 749px\" \/><\/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-73","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/73","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=73"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":419,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions\/419"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}