{"id":60,"date":"2026-02-14T11:20:12","date_gmt":"2026-02-14T03:20:12","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=60"},"modified":"2026-01-17T06:06:41","modified_gmt":"2026-01-17T06:06:41","slug":"how-to-create-rectangles-rounded-rectangles-ellipses-and-circles-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-create-rectangles-rounded-rectangles-ellipses-and-circles-using-xlwings\/","title":{"rendered":"How To Create Rectangles, Rounded Rectangles, Ellipses, and Circles Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<p>Use the `AddShape` method of the Shapes object to create rectangles, rounded rectangles, ellipses, and circles.<\/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>msoShapeRectangle<\/p>\n<\/td>\n<td>\n<p>1<\/p>\n<\/td>\n<td>\n<p>Rectangle<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoShapeRoundedRectangle<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<td>\n<p>Rounded Rectangle<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>msoShapeOval<\/p>\n<\/td>\n<td>\n<p>9<\/p>\n<\/td>\n<td>\n<p>Ellipse<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u00a0<\/p>\n<p>sht.api.Shapes.AddShape(1, 50, 50, 100, 200)\u00a0\u00a0\u00a0 #Draw a rectangle face<\/p>\n<p>sht.api.Shapes.AddShape(5, 100, 100, 100, 200)\u00a0\u00a0\u00a0 #Draw a rounded rectangle face<\/p>\n<p>sht.api.Shapes.AddShape(9, 150, 150, 100, 200)\u00a0\u00a0\u00a0 #Draw an ellipse face<\/p>\n<p>sht.api.Shapes.AddShape(9, 200, 200, 100, 100)\u00a0\u00a0\u00a0 #Draw a circle face<\/p>\n<p>\u00a0<\/p>\n<p>shp1=sht.api.Shapes.AddShape(1, 250, 50, 100, 200)\u00a0\u00a0\u00a0 #Draw a rectangle<\/p>\n<p>shp2=sht.api.Shapes.AddShape(5, 300, 100, 100, 200)\u00a0\u00a0\u00a0 #Draw a rounded rectangle<\/p>\n<p>shp3=sht.api.Shapes.AddShape(9, 350, 150, 100, 200)\u00a0\u00a0\u00a0 #Draw an ellipse<\/p>\n<p>shp4=sht.api.Shapes.AddShape(9, 400, 200, 100, 100)\u00a0\u00a0\u00a0 #Draw a circle<\/p>\n<p>shp1.Fill.Visible=False<\/p>\n<p>shp2.Fill.Visible=False<\/p>\n<p>shp3.Fill.Visible=False<\/p>\n<p>shp4.Fill.Visible=False<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Copy and paste formulas\n\nimport xlwings as xw    #Import the xlwings package\nfrom xlwings import constants as con\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(visible=True, add_book=False)\n#Open a data file, writable\nbk=app.books.open(fullname=root+r'\\Formula2.xlsx',read_only=False)\nsht=bk.api.Sheets(1)    #Get the worksheet\n\n#Copy and paste formulas\nsht.Range('B3:E5').Copy()\nsht.Range('D7:G9').PasteSpecial(Paste=con.PasteType.xlPasteFormulas)\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=\"821\" height=\"706\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/58.png\" alt=\"Create Rectangles, Rounded Rectangles, Ellipses, and Circles Using xlwings\" class=\"wp-image-371\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/58.png 821w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/58-300x258.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/02\/58-768x660.png 768w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/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-60","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/60","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=60"}],"version-history":[{"count":3,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":372,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/60\/revisions\/372"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}