{"id":2129,"date":"2026-06-17T07:22:40","date_gmt":"2026-06-16T23:22:40","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2129"},"modified":"2026-03-28T07:37:13","modified_gmt":"2026-03-28T07:37:13","slug":"how-to-use-applicationinternational-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationinternational-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.International in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>Application.International<\/code> property in Excel is a read-only property that returns information about the current country\/region and international settings in Excel. This is particularly useful for creating locale-aware macros or scripts that need to adapt to different regional formats, such as date formats, currency symbols, list separators, and more. In xlwings, this property can be accessed via the <code>api<\/code> object, which provides a direct gateway to Excel&#8217;s underlying object model. Understanding how to use <code>International<\/code> allows developers to write more robust and portable code that functions correctly across various international versions of Excel.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The syntax for accessing the <code>International<\/code> property in xlwings is straightforward. Since <code>International<\/code> is a property of the <code>Application<\/code> object, you first need to get a reference to the Excel application through xlwings, typically via <code>app = xw.App()<\/code> or by using the active app. Then, you can access the property using <code>app.api.International<\/code>. The key aspect is that <code>International<\/code> accepts an index argument (a constant or numeric value) that specifies which setting to return. This index corresponds to Excel&#8217;s <code>XlApplicationInternational<\/code> constants, which are enumerations defining various international parameters. For example, <code>xlCountryCode<\/code> (value 1) returns the country\/region code, while <code>xlCurrencyDigits<\/code> (value 25) returns the number of decimal digits used in currency formats. The available indices are numerous, and developers should refer to the official Excel VBA documentation for a comprehensive list, as xlwings does not redefine these constants but relies on Excel&#8217;s built-in enumerations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a table of some common <code>XlApplicationInternational<\/code> indices and their meanings, which can be used with <code>International<\/code> in xlwings:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Index Constant (VBA Name)<\/th><th>Value<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>xlCountryCode<\/td><td>1<\/td><td>Returns the country\/region code for the current system.<\/td><\/tr><tr><td>xlCountrySetting<\/td><td>2<\/td><td>Returns the country\/region setting from the Windows Control Panel.<\/td><\/tr><tr><td>xlCurrencyDigits<\/td><td>25<\/td><td>Returns the number of decimal digits used in currency formats.<\/td><\/tr><tr><td>xlCurrencyCode<\/td><td>27<\/td><td>Returns the currency symbol for the current locale.<\/td><\/tr><tr><td>xlDateSeparator<\/td><td>17<\/td><td>Returns the date separator character (e.g., &#8220;\/&#8221; or &#8220;-&#8220;).<\/td><\/tr><tr><td>xlTimeSeparator<\/td><td>18<\/td><td>Returns the time separator character (e.g., &#8220;:&#8221;).<\/td><\/tr><tr><td>xlListSeparator<\/td><td>5<\/td><td>Returns the list separator character (e.g., &#8220;,&#8221; or &#8220;;&#8221;).<\/td><\/tr><tr><td>xlDayCode<\/td><td>21<\/td><td>Returns the day symbol used in date formats.<\/td><\/tr><tr><td>xlMonthCode<\/td><td>20<\/td><td>Returns the month symbol used in date formats.<\/td><\/tr><tr><td>xlYearCode<\/td><td>19<\/td><td>Returns the year symbol used in date formats.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, you can use these indices by their numeric values directly, as the constants are not natively provided in the xlwings module. However, for clarity, you can define them in your code based on the VBA enumerations. The property returns a value that can be a string, number, or character, depending on the index. It is important to note that the behavior might vary slightly across different Excel versions, so testing in the target environment is recommended.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Below are practical examples of using the <code>Application.International<\/code> property with xlwings in Python. These examples demonstrate how to retrieve various international settings and use them in data processing or formatting tasks.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example 1: Retrieving basic locale information.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active Excel application\napp = xw.apps.active\n\n# Get the country\/region code (index 1)\ncountry_code = app.api.International&#91;1]\nprint(f\"Country\/Region Code: {country_code}\")\n\n# Get the list separator (index 5)\nlist_separator = app.api.International&#91;5]\nprint(f\"List Separator: '{list_separator}'\")\n\n# This can be used to dynamically format CSV files or split text based on locale.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example 2: Working with date and currency formats.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\napp = xw.apps.active\n\n# Get date and time separators\ndate_sep = app.api.International&#91;17] # xlDateSeparator\ntime_sep = app.api.International&#91;18] # xlTimeSeparator\nprint(f\"Date Separator: {date_sep}, Time Separator: {time_sep}\")\n\n# Get currency digits and symbol\ncurrency_digits = app.api.International&#91;25] # xlCurrencyDigits\ncurrency_symbol = app.api.International&#91;27] # xlCurrencyCode\nprint(f\"Currency Digits: {currency_digits}, Symbol: {currency_symbol}\")\n\n# Use these to format numbers in a worksheet dynamically\nsheet = app.books.active.sheets&#91;0]\ncell = sheet.range(\"A1\")\ncell.value = 1234.56\ncell.number_format = f\"#{currency_symbol}0.{'0' * currency_digits}\" # Custom format based on locale<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example 3: Adapting data parsing based on international settings.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\napp = xw.apps.active\n\n# Get the day, month, and year codes for date formats\nday_code = app.api.International&#91;21] # xlDayCode\nmonth_code = app.api.International&#91;20] # xlMonthCode\nyear_code = app.api.International&#91;19] # xlYearCode\nprint(f\"Date Format Codes: Day={day_code}, Month={month_code}, Year={year_code}\")\n\n# This information can help in parsing date strings from different locales,\n# especially when dealing with text data imported into Excel.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `Application.International` property in Excel is a read-only property that returns information 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-2129","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2129","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=2129"}],"version-history":[{"count":1,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2129\/revisions"}],"predecessor-version":[{"id":3254,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2129\/revisions\/3254"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}