{"id":9,"date":"2026-01-22T11:40:54","date_gmt":"2026-01-22T03:40:54","guid":{"rendered":"https:\/\/openpyxl.com\/blog\/?p=9"},"modified":"2026-01-16T05:47:07","modified_gmt":"2026-01-16T05:47:07","slug":"how-to-copy-and-move-worksheets-using-openpyxl","status":"publish","type":"post","link":"https:\/\/openpyxl.com\/blog\/how-to-copy-and-move-worksheets-using-openpyxl.html","title":{"rendered":"How To Copy and Move Worksheets Using OpenPyXL?"},"content":{"rendered":"<h2>Method<\/h2>\n<p style=\"margin-top: 4pt; margin-bottom: 4pt; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">To copy a worksheet, use the `copy_worksheet` method:<\/p>\n<p lang=\"en-US\" style=\"margin-top: 4pt; margin-bottom: 4pt; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt; color: black;\">&gt;&gt;&gt; copy_sheet=wb.copy_worksheet(ws)<\/p>\n<p style=\"margin-top: 4pt; margin-bottom: 4pt; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">To move a worksheet (cut and paste), use the `move_sheet` method:<\/p>\n<p lang=\"en-US\" style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt; color: black;\">&gt;&gt;&gt; wb.move_sheet(ws, offset=1)<\/p>\n<p style=\"margin-top: 4pt; margin-bottom: 4pt; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">The `offset` parameter specifies the number of positions to move the worksheet. If the value is greater than 0, the source sheet moves to the right by the specified number; if it\u2019s less than 0, it moves to the left.<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Copying and Moving Worksheets\n\n#Import load_workbook function\nfrom openpyxl import Workbook\n\n#Create a new workbook\nwb=Workbook()\n#Get the active worksheet\nws=wb.active\n\n#Copy worksheets\ncopy_sheet1=wb.copy_worksheet(ws)\ncopy_sheet2=wb.copy_worksheet(ws)\n#Specify the title of the first copied worksheet\ncopy_sheet1.title='NewSheet'\n\n#Move worksheets\n#If the offset value n > 0, move n columns to the right;\n#n &lt; 0, move n columns to the left\nwb.move_sheet(ws, offset=1)\n\nwb.save('test.xlsx')\nwb.close()<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"787\" height=\"418\" src=\"https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/3.png\" alt=\"\" class=\"wp-image-209\" srcset=\"https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/3.png 787w, https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/3-300x159.png 300w, https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/3-768x408.png 768w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>OpenPyXL<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-9","post","type-post","status-publish","format-standard","hentry","category-openpyxl-worksheet"],"_links":{"self":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/9","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/comments?post=9"}],"version-history":[{"count":2,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/9\/revisions\/210"}],"wp:attachment":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/media?parent=9"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/categories?post=9"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/tags?post=9"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}