当前位置:   article > 正文

python将xlsx转为xls_python xlsx转xls

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')

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/888826
推荐阅读
相关标签
  

闽ICP备14008679号