Python convert (read & save) excel xlsx to xls

前端 未结 3 1756
独厮守ぢ
独厮守ぢ 2021-01-14 03:18

How can I convert an existing xlsx Excel file into xls while retaining my Excel file formatting? I use Anaconda Python 3, so I\'m not sure I can us

3条回答
  •  無奈伤痛
    2021-01-14 03:36

    You can try to use openpyxl, and install it by conda install openpyxl and it should work with python3.5* Then the following code might work

    import openpyxl as xl
    wb = xl.load_workbook("yourfile.xlsx")
    wb.save("file.xls")
    

    You can learn more from openpyxl documentation, https://openpyxl.readthedocs.io/en/default/

    Enjoy !

提交回复
热议问题