{"id":91,"date":"2026-03-01T17:30:07","date_gmt":"2026-03-01T09:30:07","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=91"},"modified":"2026-01-17T10:48:07","modified_gmt":"2026-01-17T10:48:07","slug":"how-to-implement-graphic-flipping-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-implement-graphic-flipping-using-xlwings\/","title":{"rendered":"How To Implement Graphic Flipping Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<p>Graphic flipping, also known as image reflection or symmetry transformation, is achieved using the `Flip` method of the `Shape` object. This method flips the graphic around either the horizontal or vertical axis. It has one parameter that specifies whether to flip horizontally or vertically. The corresponding values for horizontal and vertical flips are 0 and 1, respectively.<\/p>\n<p>\u00a0<\/p>\n<p>shp=sht.api.Shapes.AddShape(1, 100, 50, 200, 100)\u00a0\u00a0\u00a0 #Rectangular area<\/p>\n<p>shp.Fill.PresetTextured(22)\u00a0\u00a0\u00a0 #Preset texture: Walnut wood<\/p>\n<p>shp.Flip(0)\u00a0\u00a0\u00a0 #Horizontal flip<\/p>\n<p>shp.Flip(1)\u00a0\u00a0\u00a0 #Vertical flip<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Iterating Over Shapes in the Worksheet\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\nshp1=sht.api.Shapes.AddShape(1, 50, 50, 200, 100)    #Rectangular area\nshp2=sht.api.Shapes.AddShape(9, 30, 80, 200, 100)    #Elliptical area\nshp2.Fill.ForeColor.RGB=xw.utils.rgb_to_int((255,0,0))\nshp2.Fill.Transparency=0.7\nshp3=sht.api.Shapes.AddLine(10,10,200,120)    #Line segment\nsht.range('F1').value=&#91;'Name', 'Type', 'Top-left X', 'Top-left Y', 'Width', 'Height']  # Header\ni=0\nfor shp in sht.api.Shapes:    #Iterate through each Shape object in the worksheet\n    i+=1\n    sht.api.Cells(i+1, 'F').Value=shp.Name    #Output each Shape object's properties\n    sht.api.Cells(i+1, 'G').Value=shp.Type\n    sht.api.Cells(i+1, 'H').Value=shp.Left\n    sht.api.Cells(i+1, 'I').Value=shp.Top\n    sht.api.Cells(i+1, 'J').Value=shp.Width\n    sht.api.Cells(i+1, 'K').Value=shp.Height\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=\"787\" height=\"482\" src=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/image-1.png\" alt=\"Implement Graphic Flipping Using xlwings\" class=\"wp-image-460\" srcset=\"https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/image-1.png 787w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/image-1-300x184.png 300w, https:\/\/xlwings.net\/blog\/wp-content\/uploads\/2026\/03\/image-1-768x470.png 768w\" sizes=\"auto, (max-width: 787px) 100vw, 787px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\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-91","post","type-post","status-publish","format-standard","hentry","category-xlwings-shape"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/91","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=91"}],"version-history":[{"count":2,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/91\/revisions"}],"predecessor-version":[{"id":461,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/91\/revisions\/461"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=91"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=91"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=91"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}