python将xlsx转为xls

import pandas as pd
import openpyxl
import xlwt
import time

wb=openpyxl.load_workbook(r'D:\demo.xlsx')
print(wb)

new_wb=xlwt.Workbook()

for sheet_name in wb.sheetnames:
    ws=wb[sheet_name]
    new_ws=new_wb.add_sheet(sheet_name)
    for row in ws.iter_rows():
        for cell in row:
            new_ws.write(cell.row-1,cell.col_idx-1,cell.value)
new_wb.save(r'D:\demotest.xls')

你可能感兴趣的:(python,excel)