Edit existing excel workbooks and sheets with xlrd and xlwt

后端 未结 2 1737
梦谈多话
梦谈多话 2020-11-29 01:44

In the documentation for xlrd and xlwt I have learned the following:

How to read from existing work-books/sheets:

from xlrd         


        
2条回答
  •  时光说笑
    2020-11-29 02:07

    Here's another way of doing the code above using the openpyxl module that's compatible with xlsx. From what I've seen so far, it also keeps formatting.

    from openpyxl import load_workbook
    wb = load_workbook('names.xlsx')
    ws = wb['SheetName']
    ws['A1'] = 'A1'
    wb.save('names.xlsx')
    

提交回复
热议问题