{"id":2317,"date":"2026-09-19T07:16:27","date_gmt":"2026-09-18T23:16:27","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2317"},"modified":"2026-03-28T13:01:00","modified_gmt":"2026-03-28T13:01:00","slug":"how-to-use-worksheetdisplayrighttoleft-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-worksheetdisplayrighttoleft-in-the-xlwings-api-way\/","title":{"rendered":"How to use Worksheet.DisplayRightToLeft in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <strong>DisplayRightToLeft<\/strong> property of a Worksheet object in Excel is a Boolean property that controls the reading order and layout direction of the worksheet. When set to <code>True<\/code>, the worksheet is displayed in a right-to-left orientation, which is particularly useful for languages that are written from right to left, such as Arabic, Hebrew, or Farsi. This setting affects the alignment of text, the order of columns (with column A appearing on the right side), and the direction of scrolling. When set to <code>False<\/code> (the default), the worksheet uses the standard left-to-right orientation. In xlwings, this property can be accessed and modified directly through the <code>api<\/code> property of a Worksheet object, which provides access to the underlying Excel object model.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><br>The property is accessed via the <code>api<\/code> property of a Worksheet object. The syntax is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>worksheet.api.DisplayRightToLeft<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This property is both readable and writable. It accepts and returns a Boolean value:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>True<\/strong>: Enables right-to-left display.<\/li>\n\n\n\n<li><strong>False<\/strong>: Disables right-to-left display (left-to-right default).<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameters:<\/strong><br>This property does not take any parameters. It is a simple Boolean attribute.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example Usage:<\/strong><br>Below are xlwings code examples demonstrating how to get and set the DisplayRightToLeft property.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Getting the current DisplayRightToLeft setting:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Open an existing workbook or create a new one\nwb = xw.Book('example.xlsx')\nsheet = wb.sheets&#91;'Sheet1']\n\n# Get the current DisplayRightToLeft value\ncurrent_setting = sheet.api.DisplayRightToLeft\nprint(f\"Current DisplayRightToLeft setting: {current_setting}\")<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Setting DisplayRightToLeft to True (right-to-left orientation):<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Open an existing workbook\nwb = xw.Book('example.xlsx')\nsheet = wb.sheets&#91;'Sheet1']\n\n# Set the worksheet to display right-to-left\nsheet.api.DisplayRightToLeft = True\nprint(\"Worksheet is now set to right-to-left display.\")<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Toggling the DisplayRightToLeft setting:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Open an existing workbook\nwb = xw.Book('example.xlsx')\nsheet = wb.sheets&#91;'Sheet1']\n\n# Toggle the current setting\nsheet.api.DisplayRightToLeft = not sheet.api.DisplayRightToLeft\nnew_setting = sheet.api.DisplayRightToLeft\nprint(f\"Toggled DisplayRightToLeft to: {new_setting}\")<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Applying DisplayRightToLeft to multiple worksheets:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Open an existing workbook\nwb = xw.Book('example.xlsx')\n\n# Loop through all worksheets and set them to right-to-left display\nfor sheet in wb.sheets:\n    sheet.api.DisplayRightToLeft = True\n    print(f\"Set {sheet.name} to right-to-left display.\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **DisplayRightToLeft** property of a Worksheet object in Excel is a Boolean property that contro&#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-2317","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2317","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=2317"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2317\/revisions"}],"predecessor-version":[{"id":3533,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2317\/revisions\/3533"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}