{"id":63,"date":"2026-02-15T18:37:24","date_gmt":"2026-02-15T10:37:24","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=63"},"modified":"2026-01-17T06:12:49","modified_gmt":"2026-01-17T06:12:49","slug":"how-to-create-labels-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-create-labels-using-xlwings\/","title":{"rendered":"How To Create Labels Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<p>Use the `AddLabel` method of the `Shapes` object to create a label. The syntax is:\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>sht.api.Shapes.AddLabel(Orientation,Left,Top,Width,Height)<\/p>\n<p>\u00a0<\/p>\n<p>Where `sht` represents a worksheet object. This method returns a `Shape` object that represents the label.<\/p>\n<p>\u00a0<\/p>\n<table>\n<tbody>\n<tr>\n<td>\n<p>Name<\/p>\n<\/td>\n<td>\n<p>Value<\/p>\n<\/td>\n<td>\n<p>Description<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoTextOrientationDownward<\/p>\n<\/td>\n<td>\n<p>3<\/p>\n<\/td>\n<td>\n<p>Downward<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoTextOrientationHorizontal<\/p>\n<\/td>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>Horizontal<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoTextOrientationHorizontalRotatedFarEast<\/p>\n<\/td>\n<td>\n<p>6<\/p>\n<\/td>\n<td>\n<p>Horizontal and rotated for East Asian languages support<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoTextOrientationMixed<\/p>\n<\/td>\n<td>\n<p>-2<\/p>\n<\/td>\n<td>\n<p>Not supported<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoTextOrientationUpward<\/p>\n<\/td>\n<td>\n<p>2<\/p>\n<\/td>\n<td>\n<p>Upward<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoTextOrientationVertical<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<td>\n<p>Vertical<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoTextOrientationVerticalFarEast<\/p>\n<\/td>\n<td>\n<p>4<\/p>\n<\/td>\n<td>\n<p>Vertical for East Asian languages support<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00a0<\/p>\n<p>shp=sht.api.Shapes.AddLabel(1,100,20,60,150)\u00a0\u00a0\u00a0 #Add labels<\/p>\n<p>shp.TextFrame2.TextRange.Characters.Text =&#8217;Test Python Label&#8217;\u00a0\u00a0\u00a0 #Label text<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Hide formulas \n\nimport xlwings as xw    #Import the xlwings package\nimport os    #Import the os package\n\nroot = os.getcwd()    #Get the current path\n#Create an Excel application window, visible, \n#without opening a workbook  \napp=xw.App()\nbk=app.books.active\nsht=bk.api.Sheets(1)    #Get the worksheet\n\n#Hide formulas \nsht.Range('C1').Value=10\nsht.Range('A1').Formula='=C1+2'\nsht.Range('B1').Formula='=C1+5'\nrng=sht.Range('A1:B1')\nrng.FormulaHidden=True\nsht.Protect()\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=\"883\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/61.png\" alt=\"Create Labels Using xlwings\" class=\"wp-image-380\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/61.png 883w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/61-300x164.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/61-768x419.png 768w\" sizes=\"auto, (max-width: 883px) 100vw, 883px\" \/><\/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-63","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/63","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=63"}],"version-history":[{"count":3,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":381,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/63\/revisions\/381"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}