{"id":109,"date":"2026-03-10T17:10:23","date_gmt":"2026-03-10T09:10:23","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=109"},"modified":"2026-01-17T11:32:29","modified_gmt":"2026-01-17T11:32:29","slug":"how-to-show-data-with-conditional-formating-data-bars-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-show-data-with-conditional-formating-data-bars-using-xlwings\/","title":{"rendered":"How To Show Data With Conditional Formating Data Bars Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">rng=sht.Range(&#8216;A1:A15&#8217;)<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">rng.FormatConditions.Delete()<\/p>\n<p style=\"margin: 0in; 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;\">rng.FormatConditions.<span style=\"font-weight: bold;\">AddDatabar<\/span>()<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Conditional Formatting - Data Bars\n\nimport xlwings as xw    #Import xlwings\nimport os    #Import os\n\nroot = os.getcwd()    #Get current path\n#Create Excel application window, visible, no workbook added\napp=xw.App(visible=True, add_book=False)\n#Open data file, writable\nbk=app.books.open(fullname=root+r'\\cf.xlsx',read_only=False)\n#Get data worksheet\nsht=bk.api.Sheets(1) \n\nrng=sht.Range('A1:A15')\nrng.FormatConditions.Delete()\n\nrng.FormatConditions.AddDatabar()\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=\"713\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/image-17.png\" alt=\"Show Data With Conditional Formating Data Bars Using xlwings\" class=\"wp-image-504\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/image-17.png 713w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/image-17-300x203.png 300w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/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":[11],"tags":[],"class_list":["post-109","post","type-post","status-publish","format-standard","hentry","category-xlwings-conditional-formatting"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/109","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=109"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions"}],"predecessor-version":[{"id":505,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/109\/revisions\/505"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}