美文网首页
xlrd 与 xlwt关联使用

xlrd 与 xlwt关联使用

作者: tinctorial | 来源:发表于2021-08-31 18:28 被阅读0次

    1.导入xlutils 的copy函数
    from xlutils.copy import copy

    2.读取已有xlsx文件
    file = os.getcwd() + '\xxx.xlsx'
    workBook = xlrd.open_workbook(file)

    3.复制该workBook 获取xlwt可以读取的table
    table = copy(workBook)

    4.通过workBook获取sheet
    sheet = workBook.get_sheet('sheet名')

    5.通过sheet写入数据
    sheet.write('row', 'col', 'data')

    6.保存表格
    xlwt.save('xxx.xlsx')

    相关文章

      网友评论

          本文标题:xlrd 与 xlwt关联使用

          本文链接:https://www.haomeiwen.com/subject/yknziltx.html