{"id":12,"date":"2026-01-23T18:02:02","date_gmt":"2026-01-23T10:02:02","guid":{"rendered":"https:\/\/xlwings.net\/blog\/?p=12"},"modified":"2026-01-17T04:25:53","modified_gmt":"2026-01-17T04:25:53","slug":"how-to-copycut-rows-and-columns-using-xlwings","status":"publish","type":"post","link":"https:\/\/xlwings.net\/blog\/how-to-copycut-rows-and-columns-using-xlwings\/","title":{"rendered":"How To Copy\/Cut Rows and Columns Using xlwings?"},"content":{"rendered":"<h2>Method<\/h2>\n<h3 style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\"><span style=\"font-weight: bold;\">Row<\/span><\/h3>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#xlwings API<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">sht.api.Rows(&#8216;2:2&#8217;).Copy()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;A7&#8217;).Select()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Paste()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 8.0pt;\">\u00a0<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Rows (&#8216;2:3&#8217;).Select()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#bk.selection.api.Cut()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;A7&#8217;).Select()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Paste()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 10.0pt;\">\u00a0<\/p>\n<h3 style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\"><span style=\"font-weight: bold;\">Column<\/span><\/h3>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Columns(&#8216;A:A&#8217;).Copy()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;E1&#8217;).Select()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Paste()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 8.0pt;\">\u00a0<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Columns(&#8216;B:C&#8217;).Select()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#bk.selection.api.Cut()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Range(&#8216;F1&#8217;).Select()<\/p>\n<p style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">#sht.api.Paste()<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Copying\/Cutting Rows and Columns \n\nimport xlwings as xw    #Import the xlwings package\n\napp=xw.App()\nbk=app.books.active    #Get the active workbook\nsht=bk.sheets.active    #Get the active worksheet\n\n#Row\n#xlwings API\nsht.api.Rows('2:2').Copy()\nsht.api.Range('A7').Select()\nsht.api.Paste()\n\n#sht.api.Rows ('2:3').Select()\n#bk.selection.api.Cut()\n#sht.api.Range('A7').Select()\n#sht.api.Paste()\n\n#Column\n#sht.api.Columns('A:A').Copy()\n#sht.api.Range('E1').Select()\n#sht.api.Paste()\n\n#sht.api.Columns('B:C').Select()\n#bk.selection.api.Cut()\n#sht.api.Range('F1').Select()\n#sht.api.Paste()\n\n#bk.close()\n#app.kill()<\/code><\/pre>\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":[6],"tags":[],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-xlwings-worksheet"],"_links":{"self":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/12","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=12"}],"version-history":[{"count":3,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/posts\/12\/revisions\/231"}],"wp:attachment":[{"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xlwings.net\/blog\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}