{"id":2116,"date":"2026-06-10T15:02:29","date_gmt":"2026-06-10T07:02:29","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2116"},"modified":"2026-03-28T07:15:24","modified_gmt":"2026-03-28T07:15:24","slug":"how-to-use-applicationfixeddecimalplaces-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationfixeddecimalplaces-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.FixedDecimalPlaces in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <code>Application.FixedDecimalPlaces<\/code> property in Excel is a global setting that controls whether Excel automatically rounds numbers entered into cells to a fixed number of decimal places. When enabled, it applies to all data entry across the workbook until the setting is turned off. This feature is primarily used for rapid data entry where consistent decimal precision is required, such as in financial or inventory systems, without manually formatting each cell. It is important to note that this setting affects only new entries and does not alter existing cell values or their display formatting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the xlwings API, which provides a programmatic interface to Excel&#8217;s object model from Python, you can access and manipulate the <code>Application.FixedDecimalPlaces<\/code> property. The syntax for using this property is straightforward, as it corresponds directly to the Excel object model. The property can be set to an integer to specify the number of decimal places or to <code>False<\/code> to disable the fixed decimal rounding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>app = xw.apps.active # Get the active Excel application instance\napp.api.FixedDecimalPlaces = places<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>places<\/code><\/strong>: An integer that specifies the number of decimal places to fix. The value must be between -15 and 15, inclusive. Setting <code>places<\/code> to a positive number (e.g., 2) rounds entered numbers to that many decimal places. Setting it to <code>0<\/code> rounds to the nearest integer. Setting it to a negative number (e.g., -2) rounds to the nearest hundred. To turn off the fixed decimal setting, assign <code>False<\/code> to the property.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Parameter Details:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Value Type<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>Integer<\/td><td>Sets the fixed decimal places to the specified number (range: -15 to 15).<\/td><\/tr><tr><td>Boolean<\/td><td>Use <code>False<\/code> to disable fixed decimal rounding; <code>True<\/code> is not a valid input.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example Usage:<\/strong><br>Below are practical xlwings code examples demonstrating how to use the <code>FixedDecimalPlaces<\/code> property in different scenarios.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Enable Fixed Decimal Rounding to Two Places:<\/strong><br>This example activates the fixed decimal feature, setting it to round all new numeric entries to two decimal places. It is useful for standard currency inputs.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\napp.api.FixedDecimalPlaces = 2\n# Now, entering 123.456 in any cell will be stored as 123.46<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Disable Fixed Decimal Rounding:<\/strong><br>To turn off the fixed decimal setting, set the property to <code>False<\/code>. This reverts Excel to its normal data entry behavior.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\napp.api.FixedDecimalPlaces = False\n# New entries will no longer be automatically rounded<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Round to Nearest Hundred (Negative Decimal Places):<\/strong><br>Using a negative value allows rounding to powers of ten. Here, setting <code>-2<\/code> rounds entries to the nearest hundred.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\napp.api.FixedDecimalPlaces = -2\n# Entering 1234 will be stored as 1200<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li><strong>Check Current Fixed Decimal Setting:<\/strong><br>You can also retrieve the current value of the property to inspect the setting.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\napp = xw.apps.active\ncurrent_setting = app.api.FixedDecimalPlaces\nprint(f\"Current fixed decimal places: {current_setting}\")\n# Output might be 2, -1, or False if disabled<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The `Application.FixedDecimalPlaces` property in Excel is a global setting that controls whether Exc&#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-2116","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2116","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=2116"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2116\/revisions"}],"predecessor-version":[{"id":3238,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2116\/revisions\/3238"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}