{"id":2380,"date":"2026-10-20T16:05:01","date_gmt":"2026-10-20T08:05:01","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2380"},"modified":"2026-03-29T10:05:30","modified_gmt":"2026-03-29T10:05:30","slug":"how-to-use-rangeclearoutline-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-rangeclearoutline-in-the-xlwings-api-way\/","title":{"rendered":"How to use Range.ClearOutline in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>ClearOutline<\/code> member of the Range object in the Excel object model is a method used to remove any grouping or outlining that has been applied to a specified range of cells. Outlining in Excel allows users to collapse and expand rows or columns to hide or show detail data, often used in summarizing reports. The <code>ClearOutline<\/code> method effectively clears these groupings, returning the range to a flat, ungrouped state without altering the actual data within the cells. This can be useful when preparing data for further analysis or when resetting the view of a worksheet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, the <code>ClearOutline<\/code> method is accessed through the <code>api<\/code> property of a Range object, which provides direct access to the underlying Excel object model. The syntax for calling this method in xlwings is straightforward, as it does not require any parameters. It is invoked on a Range object that represents the cells from which you want to remove outlining.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>range_object.api.ClearOutline()<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>range_object<\/code>: This is an xlwings Range object, typically obtained using <code>sheet.range()<\/code> or similar methods, specifying the cells (e.g., by address like &#8220;A1:D10&#8221;) where outlining should be cleared.<\/li>\n\n\n\n<li>The method takes no arguments; it directly acts on the range to clear any existing row or column outlines.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example Usage:<\/strong><br>Suppose you have an Excel workbook where rows 2 to 10 are grouped together in an outline (e.g., with a collapse\/expand button). To clear this outlining using xlwings, you can use the following 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.apps.active\nwb = app.books&#91;'YourWorkbook.xlsx'] # Replace with your workbook name\nsheet = wb.sheets&#91;'Sheet1'] # Replace with your sheet name\n\n# Define the range that has outlining (e.g., rows 2 to 10)\ntarget_range = sheet.range('2:10') # This selects entire rows 2 through 10\n\n# Clear the outlining from the specified range\ntarget_range.api.ClearOutline()\n\n# Save and close if needed\nwb.save()\nwb.close()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `ClearOutline` member of the Range object in the Excel object model is a method used to remove a&#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-2380","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2380","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=2380"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2380\/revisions"}],"predecessor-version":[{"id":3625,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2380\/revisions\/3625"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}