{"id":2196,"date":"2026-07-20T16:57:43","date_gmt":"2026-07-20T08:57:43","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=2196"},"modified":"2026-03-28T10:35:00","modified_gmt":"2026-03-28T10:35:00","slug":"how-to-use-applicationstandardfont-in-the-xlwings-api-way","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-use-applicationstandardfont-in-the-xlwings-api-way\/","title":{"rendered":"How to use Application.StandardFont in the xlwings API way"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The Application.StandardFont property in Excel refers to the default font name used for new workbooks and worksheets. Through xlwings, this property can be accessed and modified to programmatically control the standard font setting across Excel sessions. This is particularly useful for ensuring consistency in document formatting or adapting the default appearance to corporate style guidelines without manual intervention.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Functionality<\/strong><br>This property allows you to retrieve or set the name of the standard font as a string. When you change it, any new workbook created thereafter will use this font as the default for cell text. Note that existing workbooks are not automatically updated; the change applies prospectively. It affects the Excel application instance, making it a global setting.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Syntax in xlwings<\/strong><br>In xlwings, you interact with this property via the <code>app<\/code> object, which represents the Excel Application. The syntax is straightforward:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To get the current standard font: <code>app.api.StandardFont<\/code><\/li>\n\n\n\n<li>To set a new standard font: <code>app.api.StandardFont = \"font_name\"<\/code><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Here, <code>app<\/code> is your xlwings App instance. The <code>.api<\/code> attribute provides direct access to the underlying Excel object model (through pywin32 on Windows or appscript on macOS). The <code>StandardFont<\/code> property expects a string value representing a valid font name installed on the system, such as &#8220;Calibri&#8221;, &#8220;Arial&#8221;, or &#8220;Times New Roman&#8221;. There are no additional parameters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Code Examples<\/strong><br>Below are practical examples demonstrating how to use the StandardFont property with xlwings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example 1: Retrieving the Current Standard Font<\/p>\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\n\n# Get the current standard font name\ncurrent_font = app.api.StandardFont\nprint(f\"The current standard font is: {current_font}\")<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example 2: Setting a New Standard Font<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# Ensure Excel is running; start if necessary\napp = xw.App(visible=True)\n\n# Set the standard font to Arial\napp.api.StandardFont = \"Arial\"\nprint(\"Standard font changed to Arial.\")\n\n# Create a new workbook to see the effect\nwb = app.books.add()\nws = wb.sheets&#91;0]\nws.range(\"A1\").value = \"This text should be in Arial.\"\n\n# Save and close\nwb.save(\"new_workbook.xlsx\")\nwb.close()\napp.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example 3: Verifying the Change Across Sessions<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import xlwings as xw\n\n# First, set the standard font\napp = xw.App(visible=False)\napp.api.StandardFont = \"Courier New\"\napp.quit()\n\n# Restart Excel and check\napp_new = xw.App(visible=False)\nfont_check = app_new.api.StandardFont\nprint(f\"After restart, standard font is: {font_check}\") # Should be \"Courier New\"\napp_new.quit()<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Application.StandardFont property in Excel refers to the default font name used for new workbook&#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-2196","post","type-post","status-publish","format-standard","hentry","category-xlwings-api-reference"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2196","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=2196"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2196\/revisions"}],"predecessor-version":[{"id":3358,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/2196\/revisions\/3358"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=2196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=2196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=2196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}