how to convert xls to xlsx

前端 未结 14 1326
生来不讨喜
生来不讨喜 2020-11-27 03:58

I have some *.xls(excel 2003) files, and I want to convert those files into xlsx(excel 2007).

I use the uno python package, when I save the documents, I can set the

14条回答
  •  醉话见心
    2020-11-27 04:40

    CONVERT XLS FILE TO XLSX

    Using python3.6 I have just come accross the same issue and after hours of struggle I solved it by doing the ff, you probably wont need all of the packages: (I will be as clear as posslbe)

    make sure to install the following packages before proceeding

    pip install pyexcel, pip install pyexcel-xls, pip install pyexcel-xlsx,

    pip install pyexcel-cli

    step 1:

    import pyexcel
    

    step 2: "example.xls","example.xlsx","example.xlsm"

    sheet0 = pyexcel.get_sheet(file_name="your_file_path.xls", name_columns_by_row=0)
    

    step3: create array from contents

    xlsarray = sheet.to_array() 
    

    step4: check variable contents to verify

    xlsarray
    

    step5: pass the array held in variable called (xlsarray) to a new workbook variable called(sheet1)

    sheet1 = pyexcel.Sheet(xlsarray)
    

    step6: save the new sheet ending with .xlsx (in my case i want xlsx)

    sheet1.save_as("test.xlsx")
    

提交回复
热议问题