{"id":10,"date":"2026-01-22T18:25:59","date_gmt":"2026-01-22T10:25:59","guid":{"rendered":"https:\/\/openpyxl.com\/blog\/?p=10"},"modified":"2026-01-16T05:54:20","modified_gmt":"2026-01-16T05:54:20","slug":"how-to-add-rows-in-a-worksheet-using-openpyxl","status":"publish","type":"post","link":"https:\/\/openpyxl.com\/blog\/how-to-add-rows-in-a-worksheet-using-openpyxl.html","title":{"rendered":"How To Add Rows In a Worksheet 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 add a new row of data at the bottom of the current worksheet, use the `append` method:<\/p>\n<p lang=\"en-US\" style=\"margin: 0in; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt; color: black;\">ws.append(iterable)<\/p>\n<p style=\"margin-top: 4pt; margin-bottom: 4pt; font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">Where `iterable` is a list, tuple, dictionary, range, or generator. For a list, the elements are added to the row\u2019s cells in order. If it\u2019s a dictionary, the corresponding keys will add their values.<\/p>\n<h2>Sample Code<\/h2>\n\n\n<pre class=\"wp-block-code\"><code>#Adding Rows\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#Add two rows of list data\nws.append(&#91;10, 8, 21])\nws.append(&#91;'John', 39, 65])\n\n#Add two rows of dictionary data\nws.append({'A':'Jane', 'B':90, 'C':87})\nws.append({1:'Smith', 2:83, 3:79})\n\n#Use a for loop to continuously add row data\nfor row in range(1, 10):\n    ws.append(range(10,20))\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=\"480\" src=\"https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/4.png\" alt=\"Add Rows In a Worksheet\" class=\"wp-image-211\" srcset=\"https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/4.png 787w, https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/4-300x183.png 300w, https:\/\/openpyxl.com\/blog\/wp-content\/uploads\/2026\/01\/4-768x468.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-10","post","type-post","status-publish","format-standard","hentry","category-openpyxl-worksheet"],"_links":{"self":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/10","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=10"}],"version-history":[{"count":1,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/10\/revisions"}],"predecessor-version":[{"id":212,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/10\/revisions\/212"}],"wp:attachment":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/tags?post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}