{"id":2197,"date":"2026-07-21T07:24:26","date_gmt":"2026-07-20T23:24:26","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2197"},"modified":"2026-03-28T10:35:55","modified_gmt":"2026-03-28T10:35:55","slug":"how-to-use-applicationstandardfontsize-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationstandardfontsize-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.StandardFontSize in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The <strong>StandardFontSize<\/strong> member of the Application object in Excel allows you to get or set the default font size, measured in points, that is used for new workbooks and standard text styles. This is a global setting within the Excel application instance, meaning it affects the entire environment, not just a specific workbook. By adjusting this property, you can standardize the default appearance of text across newly created documents without manually formatting each cell. This is particularly useful for maintaining corporate branding or ensuring consistency in report generation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In xlwings, you access this property through the <code>api<\/code> property of the App object, which provides direct access to the underlying Excel object model. The property is available for both reading and writing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># To get the current standard font size\ncurrent_size = app.api.StandardFontSize\n\n# To set a new standard font size\napp.api.StandardFontSize = new_size<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>app<\/strong>: An instance of the xlwings App class representing the Excel application.<\/li>\n\n\n\n<li><strong>current_size<\/strong>: The returned value is a floating-point number representing the font size in points (e.g., 11.0).<\/li>\n\n\n\n<li><strong>new_size<\/strong>: A numeric value (integer or float) specifying the desired default font size in points. It must be a positive number, typically within the range supported by Excel (e.g., 1 to 409 points). Setting this property immediately changes the application&#8217;s default, but note that it does not retroactively alter existing workbooks; it only applies to new workbooks created thereafter.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example Usage:<\/strong><br>Here are practical xlwings code snippets demonstrating how to work with the StandardFontSize property.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Retrieving the Current Standard Font Size:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Connect to the active Excel instance or start a new one\napp = xw.apps.active # or xw.App() for a new instance\n\n# Get the current standard font size\ndefault_size = app.api.StandardFontSize\nprint(f\"The current standard font size is {default_size} points.\")<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li><strong>Setting a New Standard Font Size:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Start a new Excel application\napp = xw.App()\n\n# Set the standard font size to 14 points\napp.api.StandardFontSize = 14\n\n# Create a new workbook to see the effect\nwb = app.books.add()\nws = wb.sheets&#91;0]\n# The default font in cell A1 should now be 14 points\nprint(f\"Standard font size set to {app.api.StandardFontSize} points.\")\n\n# Save and close\nwb.save('new_workbook.xlsx')\nwb.close()\napp.quit()<\/code><\/pre>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li><strong>Modifying the Setting and Creating Multiple Workbooks:<\/strong><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\napp = xw.App(visible=False) # Run in background\n\n# Store the original setting for later restoration\noriginal_size = app.api.StandardFontSize\nprint(f\"Original standard font size: {original_size} points\")\n\n# Change to a larger font for emphasis\napp.api.StandardFontSize = 16\n\n# Generate two new workbooks with the updated default\nfor i in range(2):\n    wb = app.books.add()\n    ws = wb.sheets&#91;0]\n    ws.range('A1').value = f\"This text uses the new standard size of {app.api.StandardFontSize} points.\"\n    wb.save(f'report_{i+1}.xlsx')\n    wb.close()\n\n# Restore the original setting\napp.api.StandardFontSize = original_size\nprint(f\"Restored to original size: {app.api.StandardFontSize} points\")\n\napp.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The **StandardFontSize** member of the Application object in Excel allows you to get or set the defa&#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-2197","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2197","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=2197"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2197\/revisions"}],"predecessor-version":[{"id":3360,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2197\/revisions\/3360"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}