{"id":87,"date":"2026-02-27T18:14:41","date_gmt":"2026-02-27T10:14:41","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=87"},"modified":"2026-01-17T10:42:50","modified_gmt":"2026-01-17T10:42:50","slug":"how-to-set-text-properties-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-set-text-properties-using-xlwings\/","title":{"rendered":"How To Set Text Properties Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<p>In Excel, fonts are represented by the `Font` object. When setting the font, it is usually done by obtaining the `Font` object through a property, and then using the properties and methods of the object for configuration.<\/p>\n<p>\u00a0<\/p>\n<p>The main properties of the `Font` object include:\u00a0<\/p>\n<p>&#8211; Bold: Whether the font is bold. `True` for bold, `False` for not bold.<\/p>\n<p>&#8211; Color: RGB color shading.<\/p>\n<p>&#8211; ColorIndex: Index coloring. The index number of a color in the color lookup table.<\/p>\n<p>&#8211; FontStyle: Font style, such as &#8220;Bold Italic&#8221;.<\/p>\n<p>&#8211; Italic: Whether the font is italicized. `True` for italicized, `False` for not italicized.<\/p>\n<p>&#8211; Name: Font name.<\/p>\n<p>&#8211; Size: Font size.<\/p>\n<p>&#8211; Strikethrough: Whether to apply a strikethrough. `True` to apply, `False` to not apply.<\/p>\n<p>&#8211; Subscript: Whether the text is set as subscript. `True` to apply, `False` to not apply.<\/p>\n<p>&#8211; Superscript: Whether the text is set as superscript. `True` to apply, `False` to not apply.<\/p>\n<p>&#8211; ThemeColor: Theme color shading.<\/p>\n<p>&#8211; ThemeFont: Theme font.<\/p>\n<p>&#8211; TintAndShade: Darken or lighten the font color, with a value between -1 (darkest) to 1 (lightest).<\/p>\n<p>&#8211; Underline: The type of underline.\u00a0<\/p>\n<p>\u00a0 &#8211; Value -4142: No underline\u00a0<\/p>\n<p>\u00a0 &#8211; Value 2: Single underline\u00a0<\/p>\n<p>\u00a0 &#8211; Value -4119: Bold double underline\u00a0<\/p>\n<p>\u00a0 &#8211; Value 5: Close together thin double underline<\/p>\n<p>\u00a0<\/p>\n<p>sht.api.Range(&#8216;C3&#8242;).Value=&#8217;Font Test123&#8217;<\/p>\n<p>ft=sht.api.Range(&#8216;C3&#8217;).Font<\/p>\n<p>ft.Name = &#8216;Times New Roman&#8217;<\/p>\n<p>ft.ColorIndex = 3<\/p>\n<p>ft.Size = 20<\/p>\n<p>ft.Bold=True<\/p>\n<p>ft.Strikethrough = False<\/p>\n<p>ft.Underline = 5<\/p>\n<p>ft.Italic=True<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Translation transformation\n\nimport xlwings as xw    #Import xlwings package\n\napp=xw.App()\nbk=app.books.active   #Get the active workbook\nsht=bk.sheets.active    #Get the active worksheet\n\nshp=sht.api.Shapes.AddShape(1, 100, 50, 200, 100)    #Rectangular area\nshp.Fill.PresetTextured(5)    #Preset texture: Water drop\nshp.IncrementLeft(70)    #Move right by 70 units\nshp.IncrementTop(50)    #Move down by 50 units\n\n#bk.save()\n#bk.close()\n#app.kill()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"804\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-15.png\" alt=\"Set Text Properties Using xlwings\" class=\"wp-image-450\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-15.png 804w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-15-300x180.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/image-15-768x460.png 768w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Method<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/87","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=87"}],"version-history":[{"count":3,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":452,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/87\/revisions\/452"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}