How To Open .xls Files Using OpenPyXL?

Method

  • Open with Excel and save as .xlsx file.
  • Import with pandas and write to a .xlsx file.
  • Open with win32com or xlwings and save as .xlsx file.

Sample Code

#Use pandas

#
from openpyxl import load_workbook
workbook = load_workbook(filename="d:/wb2.xlsx")
sheet = workbook.active
sheet.freeze_panes = 'B2'
workbook.save('d:/wb2.xlsx')

Leave a Reply

Your email address will not be published. Required fields are marked *