{"id":182,"date":"2026-01-20T11:40:37","date_gmt":"2026-01-20T03:40:37","guid":{"rendered":"https:\/\/openpyxl.com\/blog\/?p=182"},"modified":"2026-01-16T05:37:13","modified_gmt":"2026-01-16T05:37:13","slug":"how-to-open-xls-files-using-openpyxl","status":"publish","type":"post","link":"https:\/\/openpyxl.com\/blog\/how-to-open-xls-files-using-openpyxl.html","title":{"rendered":"How To Open .xls Files Using OpenPyXL?"},"content":{"rendered":"<h2>Method<\/h2>\n<ul style=\"direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in;\" type=\"disc\">\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span lang=\"zh-CN\" style=\"font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">Open with Excel and save as .xlsx file<\/span><span lang=\"en-US\" style=\"font-family: Calibri; font-size: 14.0pt;\">.<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span lang=\"zh-CN\" style=\"font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">Import with pandas and write to a .xlsx file<\/span><span lang=\"en-US\" style=\"font-family: Calibri; font-size: 14.0pt;\">.<\/span><\/li>\n<li style=\"margin-top: 0; margin-bottom: 0; vertical-align: middle;\"><span lang=\"zh-CN\" style=\"font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">Open with win32com<\/span><span lang=\"en-US\" style=\"font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\"> or <\/span><span lang=\"zh-CN\" style=\"font-family: \u5fae\u8f6f\u96c5\u9ed1; font-size: 14.0pt;\">xlwings and save as .xlsx file.<\/span><\/li>\n<\/ul>\n\n\n<h2 class=\"wp-block-heading\">Sample Code<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#Use pandas\n\n#\nfrom openpyxl import load_workbook\nworkbook = load_workbook(filename=\"d:\/wb2.xlsx\")\nsheet = workbook.active\nsheet.freeze_panes = 'B2'\nworkbook.save('d:\/wb2.xlsx')<\/code><\/pre>\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":[2],"tags":[],"class_list":["post-182","post","type-post","status-publish","format-standard","hentry","category-openpyxl-workbook"],"_links":{"self":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/182","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=182"}],"version-history":[{"count":4,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/182\/revisions"}],"predecessor-version":[{"id":200,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/posts\/182\/revisions\/200"}],"wp:attachment":[{"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/media?parent=182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/categories?post=182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openpyxl.com\/blog\/wp-json\/wp\/v2\/tags?post=182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}