{"id":2278,"date":"2026-08-30T15:23:45","date_gmt":"2026-08-30T07:23:45","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2278"},"modified":"2026-03-28T12:16:36","modified_gmt":"2026-03-28T12:16:36","slug":"how-to-use-worksheetclearcircles-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-worksheetclearcircles-in-the-xlwings-api-way\/","title":{"rendered":"How to use Worksheet.ClearCircles in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>ClearCircles<\/code> method of the <code>Worksheet<\/code> object in Excel is used to remove all circles that have been applied to cells via data validation error alert circles. These circles typically appear when data validation rules are violated, visually indicating invalid entries in a worksheet. The method is particularly useful for cleaning up the visual interface after data validation errors have been corrected or when preparing a sheet for presentation or further processing. It operates on the entire worksheet, affecting all cells within it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, the <code>ClearCircles<\/code> method can be accessed through a <code>Worksheet<\/code> object. The syntax is straightforward, as it does not require any parameters. The method is called directly on the worksheet instance.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>worksheet.api.ClearCircles()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here, <code>worksheet<\/code> is an xlwings <code>Worksheet<\/code> object representing the target sheet. The <code>.api<\/code> attribute provides access to the underlying Excel object model, allowing direct invocation of the native <code>ClearCircles<\/code> method. No arguments are needed, as the action applies to all circles from data validation errors on that specific worksheet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><br>Consider a scenario where a worksheet contains data validation rules, such as restricting input in column A to whole numbers between 1 and 10. If a user enters text like &#8220;abc&#8221; in cell A5, Excel may display a red circle around that cell (depending on error alert settings). To programmatically remove all such circles after reviewing and correcting the data, you can use the following xlwings code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active Excel instance or open a workbook\napp = xw.App(visible=False) # Set to True if you want to see Excel\nwb = app.books.open('example.xlsx')\nsheet = wb.sheets&#91;'Sheet1']\n\n# Assume data validation errors exist and circles are visible\n# Clear all circles from data validation errors\nsheet.api.ClearCircles()\n\n# Save and close\nwb.save()\nwb.close()\napp.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `ClearCircles` method of the `Worksheet` object in Excel is used to remove all circles that have&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-2278","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2278","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=2278"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2278\/revisions"}],"predecessor-version":[{"id":3478,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2278\/revisions\/3478"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}