{"id":2203,"date":"2026-07-24T07:09:30","date_gmt":"2026-07-23T23:09:30","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2203"},"modified":"2026-03-28T10:40:31","modified_gmt":"2026-03-28T10:40:31","slug":"how-to-use-applicationthousandsseparator-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationthousandsseparator-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.ThousandsSeparator in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <strong>ThousandsSeparator<\/strong> property of the <strong>Application<\/strong> object in Excel is a global setting that controls the character used to separate thousands in numbers when formatting and displaying numerical data. This property is part of Excel&#8217;s internationalization features, allowing customization to match regional formatting standards. For instance, in many European countries, a period (.) is used as the thousands separator, while in English-speaking countries like the United States, a comma (,) is typically used. By accessing this property via xlwings, you can programmatically read or modify the thousands separator setting for the active Excel instance, which can be useful for ensuring consistent number formatting across different locales in automated reports or data processing scripts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><br>In xlwings, you can access the <strong>ThousandsSeparator<\/strong> property through the <code>app<\/code> object, which represents the Excel application. The property is available as an attribute of the <code>app<\/code> object, and it can be both read and written. The syntax is straightforward:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To get the current thousands separator: <code>separator = app.separators['thousands']<\/code><\/li>\n\n\n\n<li>To set a new thousands separator: <code>app.separators['thousands'] = new_separator<\/code><br>Note that in xlwings, the <strong>ThousandsSeparator<\/strong> is accessed via the <code>separators<\/code> dictionary under the <code>app<\/code> object, rather than as a direct property like in VBA. This dictionary includes other separators like decimal separators as well. The <code>new_separator<\/code> parameter should be a string containing a single character (e.g., &#8220;,&#8221; or &#8220;.&#8221;), and it must be a valid separator character supported by Excel for the current system locale.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Code Examples:<\/strong><br>Here are some practical examples using xlwings to work with the <strong>ThousandsSeparator<\/strong> property:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Reading the current thousands separator:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n# Connect to the active Excel application\napp = xw.apps.active\n# Get the current thousands separator\ncurrent_separator = app.separators&#91;'thousands']\nprint(f\"The current thousands separator is: '{current_separator}'\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This code snippet retrieves and prints the thousands separator currently set in Excel, which might output something like <code>','<\/code> for a comma.<\/p>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Changing the thousands separator:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n# Connect to the active Excel application\napp = xw.apps.active\n# Set the thousands separator to a period (common in some European formats)\napp.separators&#91;'thousands'] = '.'\nprint(\"Thousands separator updated to period.\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After running this, Excel will use a period as the thousands separator for new number formatting, affecting how numbers are displayed in cells.<\/p>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Applying the thousands separator in a workbook:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n# Start a new Excel instance and open a workbook\napp = xw.App()\nworkbook = app.books.open('example.xlsx')\nsheet = workbook.sheets&#91;0]\n# Change the thousands separator to a space (less common but possible)\napp.separators&#91;'thousands'] = ' '\n# Format a cell with a number to use the new separator\nsheet.range('A1').value = 1234567\nsheet.range('A1').number_format = '#,##0'\n# The displayed value in Excel will now show as \"1 234 567\" if formatting is applied\nworkbook.save()\napp.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **ThousandsSeparator** property of the **Application** object in Excel is a global setting that &#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-2203","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2203","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=2203"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2203\/revisions"}],"predecessor-version":[{"id":3369,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2203\/revisions\/3369"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}